diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..8c2e5df7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,13 @@ +# Set the default behavior (used when a rule below doesn't match) +* text=auto + +# Go files +*.go text eol=lf +*.mod text eol=lf +*.sum text eol=lf + +# Some Windows-specific files should always be CRLF +*.bat text eol=crlf + +# Shell scripts +*.sh text eol=lf diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 00000000..ff7d702e --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,37 @@ +name: Go +on: [push] +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + + - name: go build + run: go build -v ./... + + - name: go fmt + run: go fmt ./... + + - name: go vet + run: go vet ./... + + - name: go test + run: go test ./... diff --git a/.gitignore b/.gitignore index f1c181ec..ea5c68eb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out + +.idea/ diff --git a/README.md b/README.md index b81a84e5..ccc5bb51 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,73 @@ +[![Go](https://github.com/microsoft/azure-devops-go-api/workflows/Go/badge.svg)](https://github.com/microsoft/azure-devops-go-api/actions) +[![Build Status](https://dev.azure.com/mseng/vsts-cli/_apis/build/status/microsoft.azure-devops-go-api?branchName=dev)](https://dev.azure.com/mseng/vsts-cli/_build/latest?definitionId=9110&branchName=dev) +[![Go Report Card](https://goreportcard.com/badge/github.com/microsoft/azure-devops-go-api)](https://goreportcard.com/report/github.com/microsoft/azure-devops-go-api) + +# Azure DevOps Go API +This repository contains Go APIs for interacting with and managing Azure DevOps. + +## Get started +To use the API, establish a connection using a [personal access token](https://docs.microsoft.com/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops) and the URL to your Azure DevOps organization. Then get a client using the connection and make API calls. + +``` +package main + +import ( + "context" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/core" + "log" +) + +func main() { + organizationUrl := "https://dev.azure.com/myorg" // todo: replace value with your organization url + personalAccessToken := "XXXXXXXXXXXXXXXXXXXXXXX" // todo: replace value with your PAT + + // Create a connection to your organization + connection := azuredevops.NewPatConnection(organizationUrl, personalAccessToken) + + ctx := context.Background() + + // Create a client to interact with the Core area + coreClient, err := core.NewClient(ctx, connection) + if err != nil { + log.Fatal(err) + } + + // Get first page of the list of team projects for your organization + responseValue, err := coreClient.GetProjects(ctx, core.GetProjectsArgs{}) + if err != nil { + log.Fatal(err) + } + + index := 0 + for responseValue != nil { + // Log the page of team project names + for _, teamProjectReference := range (*responseValue).Value { + log.Printf("Name[%v] = %v", index, *teamProjectReference.Name) + index++ + } + + // if continuationToken has a value, then there is at least one more page of projects to get + if responseValue.ContinuationToken != "" { + // Get next page of team projects + projectArgs := core.GetProjectsArgs{ + ContinuationToken: &responseValue.ContinuationToken, + } + responseValue, err = coreClient.GetProjects(ctx, projectArgs) + if err != nil { + log.Fatal(err) + } + } else { + responseValue = nil + } + } +} +``` + +## API documentation + +This Go library provides a thin wrapper around the Azure DevOps REST APIs. See the [Azure DevOps REST API reference](https://docs.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.1) for details on calling different APIs. + # Contributing diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..7090dd55 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,48 @@ +# Go +# Build your Go project. +# Add steps that test, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/go + +trigger: +- master +- dev + +pool: + vmImage: 'ubuntu-latest' + +variables: + GOBIN: '$(GOPATH)/bin' # Go binaries path + GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path + modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code + +steps: +- script: | + printenv | sort + displayName: 'Log Environment Variables' + +- script: | + mkdir -p '$(GOBIN)' + mkdir -p '$(GOPATH)/pkg' + mkdir -p '$(modulePath)' + shopt -s extglob + shopt -s dotglob + mv !(gopath) '$(modulePath)' + echo '##vso[task.prependpath]$(GOBIN)' + echo '##vso[task.prependpath]$(GOROOT)/bin' + displayName: 'Set up the Go workspace' + +- script: | + go version + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + go build -v ./... + workingDirectory: '$(modulePath)' + displayName: 'Get dependencies, then build' + +- script: | + go test ./... + workingDirectory: '$(modulePath)' + displayName: 'Run unit tests' \ No newline at end of file diff --git a/azuredevops/accounts/client.go b/azuredevops/accounts/client.go new file mode 100644 index 00000000..c0f80127 --- /dev/null +++ b/azuredevops/accounts/client.go @@ -0,0 +1,71 @@ +// -------------------------------------------------------------------------------------------- +// 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 accounts + +import ( + "context" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" +) + +var ResourceAreaId, _ = uuid.Parse("0d55247a-1c47-4462-9b1f-5e2125590ee6") + +type Client interface { + // Get a list of accounts for a specific owner or a specific member. + GetAccounts(context.Context, GetAccountsArgs) (*[]Account, 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 +} + +// Get a list of accounts for a specific owner or a specific member. +func (client *ClientImpl) GetAccounts(ctx context.Context, args GetAccountsArgs) (*[]Account, error) { + queryParams := url.Values{} + if args.OwnerId != nil { + queryParams.Add("ownerId", (*args.OwnerId).String()) + } + if args.MemberId != nil { + queryParams.Add("memberId", (*args.MemberId).String()) + } + if args.Properties != nil { + queryParams.Add("properties", *args.Properties) + } + locationId, _ := uuid.Parse("229a6a53-b428-4ffb-a835-e8f36b5b4b1e") + 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 []Account + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAccounts function +type GetAccountsArgs struct { + // (optional) ID for the owner of the accounts. + OwnerId *uuid.UUID + // (optional) ID for a member of the accounts. + MemberId *uuid.UUID + // (optional) + Properties *string +} diff --git a/azuredevops/accounts/models.go b/azuredevops/accounts/models.go new file mode 100644 index 00000000..6108c1cd --- /dev/null +++ b/azuredevops/accounts/models.go @@ -0,0 +1,124 @@ +// -------------------------------------------------------------------------------------------- +// 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 accounts + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" +) + +type Account struct { + // Identifier for an Account + AccountId *uuid.UUID `json:"accountId,omitempty"` + // Name for an account + AccountName *string `json:"accountName,omitempty"` + // Owner of account + AccountOwner *uuid.UUID `json:"accountOwner,omitempty"` + // Current account status + AccountStatus *AccountStatus `json:"accountStatus,omitempty"` + // Type of account: Personal, Organization + AccountType *AccountType `json:"accountType,omitempty"` + // Uri for an account + AccountUri *string `json:"accountUri,omitempty"` + // Who created the account + CreatedBy *uuid.UUID `json:"createdBy,omitempty"` + // Date account was created + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + HasMoved *bool `json:"hasMoved,omitempty"` + // Identity of last person to update the account + LastUpdatedBy *uuid.UUID `json:"lastUpdatedBy,omitempty"` + // Date account was last updated + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Namespace for an account + NamespaceId *uuid.UUID `json:"namespaceId,omitempty"` + NewCollectionId *uuid.UUID `json:"newCollectionId,omitempty"` + // Organization that created the account + OrganizationName *string `json:"organizationName,omitempty"` + // Extended properties + Properties interface{} `json:"properties,omitempty"` + // Reason for current status + StatusReason *string `json:"statusReason,omitempty"` +} + +type AccountCreateInfoInternal struct { + AccountName *string `json:"accountName,omitempty"` + Creator *uuid.UUID `json:"creator,omitempty"` + Organization *string `json:"organization,omitempty"` + Preferences *AccountPreferencesInternal `json:"preferences,omitempty"` + Properties interface{} `json:"properties,omitempty"` + ServiceDefinitions *[]azuredevops.KeyValuePair `json:"serviceDefinitions,omitempty"` +} + +type AccountPreferencesInternal struct { + Culture interface{} `json:"culture,omitempty"` + Language interface{} `json:"language,omitempty"` + TimeZone interface{} `json:"timeZone,omitempty"` +} + +type AccountStatus string + +type accountStatusValuesType struct { + None AccountStatus + Enabled AccountStatus + Disabled AccountStatus + Deleted AccountStatus + Moved AccountStatus +} + +var AccountStatusValues = accountStatusValuesType{ + None: "none", + // This hosting account is active and assigned to a customer. + Enabled: "enabled", + // This hosting account is disabled. + Disabled: "disabled", + // This account is part of deletion batch and scheduled for deletion. + Deleted: "deleted", + // This account is not mastered locally and has physically moved. + Moved: "moved", +} + +type AccountType string + +type accountTypeValuesType struct { + Personal AccountType + Organization AccountType +} + +var AccountTypeValues = accountTypeValuesType{ + Personal: "personal", + Organization: "organization", +} + +type AccountUserStatus string + +type accountUserStatusValuesType struct { + None AccountUserStatus + Active AccountUserStatus + Disabled AccountUserStatus + Deleted AccountUserStatus + Pending AccountUserStatus + Expired AccountUserStatus + PendingDisabled AccountUserStatus +} + +var AccountUserStatusValues = accountUserStatusValuesType{ + None: "none", + // User has signed in at least once to the VSTS account + Active: "active", + // User cannot sign in; primarily used by admin to temporarily remove a user due to absence or license reallocation + Disabled: "disabled", + // User is removed from the VSTS account by the VSTS account admin + Deleted: "deleted", + // User is invited to join the VSTS account by the VSTS account admin, but has not signed up/signed in yet + Pending: "pending", + // User can sign in; primarily used when license is in expired state and we give a grace period + Expired: "expired", + // User is disabled; if reenabled, they will still be in the Pending state + PendingDisabled: "pendingDisabled", +} diff --git a/azuredevops/audit/client.go b/azuredevops/audit/client.go new file mode 100644 index 00000000..1707e064 --- /dev/null +++ b/azuredevops/audit/client.go @@ -0,0 +1,117 @@ +// -------------------------------------------------------------------------------------------- +// 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 audit + +import ( + "context" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "io" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("94ff054d-5ee1-413d-9341-3f4a7827de2e") + +type Client interface { + // [Preview API] Downloads audit log entries. + DownloadLog(context.Context, DownloadLogArgs) (io.ReadCloser, error) + // [Preview API] Queries audit log entries + QueryLog(context.Context, QueryLogArgs) (*AuditLogQueryResult, 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] Downloads audit log entries. +func (client *ClientImpl) DownloadLog(ctx context.Context, args DownloadLogArgs) (io.ReadCloser, error) { + queryParams := url.Values{} + if args.Format == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "format"} + } + queryParams.Add("format", *args.Format) + if args.StartTime != nil { + queryParams.Add("startTime", (*args.StartTime).String()) + } + if args.EndTime != nil { + queryParams.Add("endTime", (*args.EndTime).String()) + } + locationId, _ := uuid.Parse("b7b98a76-04e8-4f4d-ac72-9d46492caaac") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/octet-stream", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the DownloadLog function +type DownloadLogArgs struct { + // (required) File format for download. Can be "json" or "csv". + Format *string + // (optional) Start time of download window. Optional + StartTime *azuredevops.Time + // (optional) End time of download window. Optional + EndTime *azuredevops.Time +} + +// [Preview API] Queries audit log entries +func (client *ClientImpl) QueryLog(ctx context.Context, args QueryLogArgs) (*AuditLogQueryResult, error) { + queryParams := url.Values{} + if args.StartTime != nil { + queryParams.Add("startTime", (*args.StartTime).String()) + } + if args.EndTime != nil { + queryParams.Add("endTime", (*args.EndTime).String()) + } + if args.BatchSize != nil { + queryParams.Add("batchSize", strconv.Itoa(*args.BatchSize)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.SkipAggregation != nil { + queryParams.Add("skipAggregation", strconv.FormatBool(*args.SkipAggregation)) + } + locationId, _ := uuid.Parse("4e5fa14f-7097-4b73-9c85-00abc7353c61") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue AuditLogQueryResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryLog function +type QueryLogArgs struct { + // (optional) Start time of download window. Optional + StartTime *azuredevops.Time + // (optional) End time of download window. Optional + EndTime *azuredevops.Time + // (optional) Max number of results to return. Optional + BatchSize *int + // (optional) Token used for returning next set of results from previous query. Optional + ContinuationToken *string + // (optional) Skips aggregating events and leaves them as individual entries instead. By default events are aggregated. Event types that are aggregated: AuditLog.AccessLog. + SkipAggregation *bool +} diff --git a/azuredevops/audit/models.go b/azuredevops/audit/models.go new file mode 100644 index 00000000..47254e70 --- /dev/null +++ b/azuredevops/audit/models.go @@ -0,0 +1,91 @@ +// -------------------------------------------------------------------------------------------- +// 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 audit + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" +) + +// Defines all the categories an AuditAction can be +type AuditActionCategory string + +type auditActionCategoryValuesType struct { + Unknown AuditActionCategory + Modify AuditActionCategory + Remove AuditActionCategory + Create AuditActionCategory + Access AuditActionCategory +} + +var AuditActionCategoryValues = auditActionCategoryValuesType{ + // The category is not known + Unknown: "unknown", + // An artifact has been Modified + Modify: "modify", + // An artifact has been Removed + Remove: "remove", + // An artifact has been Created + Create: "create", + // An artifact has been Accessed + Access: "access", +} + +// The object returned when the audit log is queried. It contains the log and the information needed to query more audit entries. +type AuditLogQueryResult struct { + // The continuation token to pass to get the next set of results + ContinuationToken *string `json:"continuationToken,omitempty"` + // The list of audit log entries + DecoratedAuditLogEntries *[]DecoratedAuditLogEntry `json:"decoratedAuditLogEntries,omitempty"` + // True when there are more matching results to be fetched, false otherwise. + HasMore *bool `json:"hasMore,omitempty"` +} + +type DecoratedAuditLogEntry struct { + // The action if for the event, i.e Git.CreateRepo, Project.RenameProject + ActionId *string `json:"actionId,omitempty"` + // ActivityId + ActivityId *uuid.UUID `json:"activityId,omitempty"` + // The Actor's CUID + ActorCUID *uuid.UUID `json:"actorCUID,omitempty"` + // DisplayName of the user who initiated the action + ActorDisplayName *string `json:"actorDisplayName,omitempty"` + // URL of Actor's Profile image + ActorImageUrl *string `json:"actorImageUrl,omitempty"` + // The Actor's User Id + ActorUserId *uuid.UUID `json:"actorUserId,omitempty"` + // Area of Azure DevOps the action occurred + Area *string `json:"area,omitempty"` + // Type of authentication used by the actor + AuthenticationMechanism *string `json:"authenticationMechanism,omitempty"` + // Type of action executed + Category *AuditActionCategory `json:"category,omitempty"` + // DisplayName of the category + CategoryDisplayName *string `json:"categoryDisplayName,omitempty"` + // This allows related audit entries to be grouped together. Generally this occurs when a single action causes a cascade of audit entries. For example, project creation. + CorrelationId *uuid.UUID `json:"correlationId,omitempty"` + // External data such as CUIDs, item names, etc. + Data *map[string]interface{} `json:"data,omitempty"` + // Decorated details + Details *string `json:"details,omitempty"` + // EventId - Needs to be unique per service + Id *string `json:"id,omitempty"` + // IP Address where the event was originated + IpAddress *string `json:"ipAddress,omitempty"` + // DisplayName of the scope + ScopeDisplayName *string `json:"scopeDisplayName,omitempty"` + // The organization or project Id + ScopeId *uuid.UUID `json:"scopeId,omitempty"` + // The type of the scope, Organization or Project + ScopeType *string `json:"scopeType,omitempty"` + // The time when the event occurred in UTC + Timestamp *azuredevops.Time `json:"timestamp,omitempty"` + // The user agent from the request + UserAgent *string `json:"userAgent,omitempty"` +} diff --git a/azuredevops/build/client.go b/azuredevops/build/client.go new file mode 100644 index 00000000..24fa136f --- /dev/null +++ b/azuredevops/build/client.go @@ -0,0 +1,3393 @@ +// -------------------------------------------------------------------------------------------- +// 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 build + +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/webapi" + "io" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("965220d5-5bb9-42cf-8d67-9b146df2a5a4") + +type Client interface { + // Adds a tag to a build. + AddBuildTag(context.Context, AddBuildTagArgs) (*[]string, error) + // Adds tags to a build. + AddBuildTags(context.Context, AddBuildTagsArgs) (*[]string, error) + // [Preview API] Adds a tag to a definition + AddDefinitionTag(context.Context, AddDefinitionTagArgs) (*[]string, error) + // [Preview API] Adds multiple tags to a definition. + AddDefinitionTags(context.Context, AddDefinitionTagsArgs) (*[]string, error) + // [Preview API] + AuthorizeDefinitionResources(context.Context, AuthorizeDefinitionResourcesArgs) (*[]DefinitionResourceReference, error) + // [Preview API] + AuthorizeProjectResources(context.Context, AuthorizeProjectResourcesArgs) (*[]DefinitionResourceReference, error) + // Associates an artifact with a build. + CreateArtifact(context.Context, CreateArtifactArgs) (*BuildArtifact, error) + // Creates a new definition. + CreateDefinition(context.Context, CreateDefinitionArgs) (*BuildDefinition, error) + // [Preview API] Creates a new folder. + CreateFolder(context.Context, CreateFolderArgs) (*Folder, error) + // Deletes a build. + DeleteBuild(context.Context, DeleteBuildArgs) error + // Removes a tag from a build. + DeleteBuildTag(context.Context, DeleteBuildTagArgs) (*[]string, error) + // Deletes a definition and all associated builds. + DeleteDefinition(context.Context, DeleteDefinitionArgs) error + // [Preview API] Removes a tag from a definition. + DeleteDefinitionTag(context.Context, DeleteDefinitionTagArgs) (*[]string, error) + // [Preview API] Deletes a definition folder. Definitions and their corresponding builds will also be deleted. + DeleteFolder(context.Context, DeleteFolderArgs) error + // Deletes a build definition template. + DeleteTemplate(context.Context, DeleteTemplateArgs) error + // Gets a specific artifact for a build. + GetArtifact(context.Context, GetArtifactArgs) (*BuildArtifact, error) + // Gets a specific artifact for a build. + GetArtifactContentZip(context.Context, GetArtifactContentZipArgs) (io.ReadCloser, error) + // Gets all artifacts for a build. + GetArtifacts(context.Context, GetArtifactsArgs) (*[]BuildArtifact, error) + // [Preview API] Gets a specific attachment. + GetAttachment(context.Context, GetAttachmentArgs) (io.ReadCloser, error) + // [Preview API] Gets the list of attachments of a specific type that are associated with a build. + GetAttachments(context.Context, GetAttachmentsArgs) (*[]Attachment, error) + // Gets a build + GetBuild(context.Context, GetBuildArgs) (*Build, error) + // [Preview API] Gets a badge that indicates the status of the most recent build for the specified branch. + GetBuildBadge(context.Context, GetBuildBadgeArgs) (*BuildBadge, error) + // [Preview API] Gets a badge that indicates the status of the most recent build for the specified branch. + GetBuildBadgeData(context.Context, GetBuildBadgeDataArgs) (*string, error) + // Gets the changes associated with a build + GetBuildChanges(context.Context, GetBuildChangesArgs) (*GetBuildChangesResponseValue, error) + // Gets a controller + GetBuildController(context.Context, GetBuildControllerArgs) (*BuildController, error) + // Gets controller, optionally filtered by name + GetBuildControllers(context.Context, GetBuildControllersArgs) (*[]BuildController, error) + // Gets an individual log file for a build. + GetBuildLog(context.Context, GetBuildLogArgs) (io.ReadCloser, error) + // Gets an individual log file for a build. + GetBuildLogLines(context.Context, GetBuildLogLinesArgs) (*[]string, error) + // Gets the logs for a build. + GetBuildLogs(context.Context, GetBuildLogsArgs) (*[]BuildLog, error) + // Gets the logs for a build. + GetBuildLogsZip(context.Context, GetBuildLogsZipArgs) (io.ReadCloser, error) + // Gets an individual log file for a build. + GetBuildLogZip(context.Context, GetBuildLogZipArgs) (io.ReadCloser, error) + // Gets all build definition options supported by the system. + GetBuildOptionDefinitions(context.Context, GetBuildOptionDefinitionsArgs) (*[]BuildOptionDefinition, error) + // [Preview API] Gets properties for a build. + GetBuildProperties(context.Context, GetBuildPropertiesArgs) (interface{}, error) + // [Preview API] Gets a build report. + GetBuildReport(context.Context, GetBuildReportArgs) (*BuildReportMetadata, error) + // [Preview API] Gets a build report. + GetBuildReportHtmlContent(context.Context, GetBuildReportHtmlContentArgs) (io.ReadCloser, error) + // Gets a list of builds. + GetBuilds(context.Context, GetBuildsArgs) (*GetBuildsResponseValue, error) + // Gets the build settings. + GetBuildSettings(context.Context, GetBuildSettingsArgs) (*BuildSettings, error) + // Gets the tags for a build. + GetBuildTags(context.Context, GetBuildTagsArgs) (*[]string, error) + // Gets details for a build + GetBuildTimeline(context.Context, GetBuildTimelineArgs) (*Timeline, error) + // Gets the work items associated with a build. + GetBuildWorkItemsRefs(context.Context, GetBuildWorkItemsRefsArgs) (*[]webapi.ResourceRef, error) + // Gets the work items associated with a build, filtered to specific commits. + GetBuildWorkItemsRefsFromCommits(context.Context, GetBuildWorkItemsRefsFromCommitsArgs) (*[]webapi.ResourceRef, error) + // [Preview API] Gets the changes made to the repository between two given builds. + GetChangesBetweenBuilds(context.Context, GetChangesBetweenBuildsArgs) (*[]Change, error) + // Gets a definition, optionally at a specific revision. + GetDefinition(context.Context, GetDefinitionArgs) (*BuildDefinition, error) + // [Preview API] Gets build metrics for a definition. + GetDefinitionMetrics(context.Context, GetDefinitionMetricsArgs) (*[]BuildMetric, error) + // [Preview API] Gets properties for a definition. + GetDefinitionProperties(context.Context, GetDefinitionPropertiesArgs) (interface{}, error) + // [Preview API] + GetDefinitionResources(context.Context, GetDefinitionResourcesArgs) (*[]DefinitionResourceReference, error) + // Gets all revisions of a definition. + GetDefinitionRevisions(context.Context, GetDefinitionRevisionsArgs) (*[]BuildDefinitionRevision, error) + // Gets a list of definitions. + GetDefinitions(context.Context, GetDefinitionsArgs) (*GetDefinitionsResponseValue, error) + // [Preview API] Gets the tags for a definition. + GetDefinitionTags(context.Context, GetDefinitionTagsArgs) (*[]string, error) + // Gets a file from the build. + GetFile(context.Context, GetFileArgs) (io.ReadCloser, error) + // [Preview API] Gets the contents of a file in the given source code repository. + GetFileContents(context.Context, GetFileContentsArgs) (io.ReadCloser, error) + // [Preview API] Gets a list of build definition folders. + GetFolders(context.Context, GetFoldersArgs) (*[]Folder, error) + // [Preview API] Gets the latest build for a definition, optionally scoped to a specific branch. + GetLatestBuild(context.Context, GetLatestBuildArgs) (*Build, error) + // [Preview API] Gets the contents of a directory in the given source code repository. + GetPathContents(context.Context, GetPathContentsArgs) (*[]SourceRepositoryItem, error) + // [Preview API] Gets build metrics for a project. + GetProjectMetrics(context.Context, GetProjectMetricsArgs) (*[]BuildMetric, error) + // [Preview API] + GetProjectResources(context.Context, GetProjectResourcesArgs) (*[]DefinitionResourceReference, error) + // [Preview API] Gets a pull request object from source provider. + GetPullRequest(context.Context, GetPullRequestArgs) (*PullRequest, error) + // [Preview API] Gets information about build resources in the system. + GetResourceUsage(context.Context, GetResourceUsageArgs) (*BuildResourceUsage, error) + // [Preview API]

Gets the build status for a definition, optionally scoped to a specific branch, stage, job, and configuration.

If there are more than one, then it is required to pass in a stageName value when specifying a jobName, and the same rule then applies for both if passing a configuration parameter.

+ GetStatusBadge(context.Context, GetStatusBadgeArgs) (*string, error) + // Gets a list of all build and definition tags in the project. + GetTags(context.Context, GetTagsArgs) (*[]string, error) + // Gets a specific build definition template. + GetTemplate(context.Context, GetTemplateArgs) (*BuildDefinitionTemplate, error) + // Gets all definition templates. + GetTemplates(context.Context, GetTemplatesArgs) (*[]BuildDefinitionTemplate, error) + // [Preview API] Gets all the work items between two builds. + GetWorkItemsBetweenBuilds(context.Context, GetWorkItemsBetweenBuildsArgs) (*[]webapi.ResourceRef, error) + // [Preview API] Gets a list of branches for the given source code repository. + ListBranches(context.Context, ListBranchesArgs) (*[]string, error) + // [Preview API] Gets a list of source code repositories. + ListRepositories(context.Context, ListRepositoriesArgs) (*SourceRepositories, error) + // [Preview API] Get a list of source providers and their capabilities. + ListSourceProviders(context.Context, ListSourceProvidersArgs) (*[]SourceProviderAttributes, error) + // [Preview API] Gets a list of webhooks installed in the given source code repository. + ListWebhooks(context.Context, ListWebhooksArgs) (*[]RepositoryWebhook, error) + // Queues a build + QueueBuild(context.Context, QueueBuildArgs) (*Build, error) + // Restores a deleted definition + RestoreDefinition(context.Context, RestoreDefinitionArgs) (*BuildDefinition, error) + // [Preview API] Recreates the webhooks for the specified triggers in the given source code repository. + RestoreWebhooks(context.Context, RestoreWebhooksArgs) error + // Updates an existing build definition template. + SaveTemplate(context.Context, SaveTemplateArgs) (*BuildDefinitionTemplate, error) + // Updates a build. + UpdateBuild(context.Context, UpdateBuildArgs) (*Build, error) + // [Preview API] Updates properties for a build. + UpdateBuildProperties(context.Context, UpdateBuildPropertiesArgs) (interface{}, error) + // Updates multiple builds. + UpdateBuilds(context.Context, UpdateBuildsArgs) (*[]Build, error) + // Updates the build settings. + UpdateBuildSettings(context.Context, UpdateBuildSettingsArgs) (*BuildSettings, error) + // Updates an existing definition. + UpdateDefinition(context.Context, UpdateDefinitionArgs) (*BuildDefinition, error) + // [Preview API] Updates properties for a definition. + UpdateDefinitionProperties(context.Context, UpdateDefinitionPropertiesArgs) (interface{}, error) + // [Preview API] Updates an existing folder at given existing path + UpdateFolder(context.Context, UpdateFolderArgs) (*Folder, 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 +} + +// Adds a tag to a build. +func (client *ClientImpl) AddBuildTag(ctx context.Context, args AddBuildTagArgs) (*[]string, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + if args.Tag == nil || *args.Tag == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Tag"} + } + routeValues["tag"] = *args.Tag + + locationId, _ := uuid.Parse("6e6114b2-8161-44c8-8f6c-c5505782427f") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, nil, 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 AddBuildTag function +type AddBuildTagArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (required) The tag to add. + Tag *string +} + +// Adds tags to a build. +func (client *ClientImpl) AddBuildTags(ctx context.Context, args AddBuildTagsArgs) (*[]string, error) { + if args.Tags == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Tags"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + body, marshalErr := json.Marshal(*args.Tags) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("6e6114b2-8161-44c8-8f6c-c5505782427f") + 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 []string + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddBuildTags function +type AddBuildTagsArgs struct { + // (required) The tags to add. + Tags *[]string + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int +} + +// [Preview API] Adds a tag to a definition +func (client *ClientImpl) AddDefinitionTag(ctx context.Context, args AddDefinitionTagArgs) (*[]string, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + if args.Tag == nil || *args.Tag == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Tag"} + } + routeValues["tag"] = *args.Tag + + locationId, _ := uuid.Parse("cb894432-134a-4d31-a839-83beceaace4b") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.2", routeValues, nil, 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 AddDefinitionTag function +type AddDefinitionTagArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the definition. + DefinitionId *int + // (required) The tag to add. + Tag *string +} + +// [Preview API] Adds multiple tags to a definition. +func (client *ClientImpl) AddDefinitionTags(ctx context.Context, args AddDefinitionTagsArgs) (*[]string, error) { + if args.Tags == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Tags"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + body, marshalErr := json.Marshal(*args.Tags) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("cb894432-134a-4d31-a839-83beceaace4b") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []string + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddDefinitionTags function +type AddDefinitionTagsArgs struct { + // (required) The tags to add. + Tags *[]string + // (required) Project ID or project name + Project *string + // (required) The ID of the definition. + DefinitionId *int +} + +// [Preview API] +func (client *ClientImpl) AuthorizeDefinitionResources(ctx context.Context, args AuthorizeDefinitionResourcesArgs) (*[]DefinitionResourceReference, error) { + if args.Resources == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Resources"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + body, marshalErr := json.Marshal(*args.Resources) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ea623316-1967-45eb-89ab-e9e6110cf2d6") + 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 []DefinitionResourceReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AuthorizeDefinitionResources function +type AuthorizeDefinitionResourcesArgs struct { + // (required) + Resources *[]DefinitionResourceReference + // (required) Project ID or project name + Project *string + // (required) + DefinitionId *int +} + +// [Preview API] +func (client *ClientImpl) AuthorizeProjectResources(ctx context.Context, args AuthorizeProjectResourcesArgs) (*[]DefinitionResourceReference, error) { + if args.Resources == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Resources"} + } + 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.Resources) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("398c85bc-81aa-4822-947c-a194a05f0fef") + 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 []DefinitionResourceReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AuthorizeProjectResources function +type AuthorizeProjectResourcesArgs struct { + // (required) + Resources *[]DefinitionResourceReference + // (required) Project ID or project name + Project *string +} + +// Associates an artifact with a build. +func (client *ClientImpl) CreateArtifact(ctx context.Context, args CreateArtifactArgs) (*BuildArtifact, error) { + if args.Artifact == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Artifact"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + body, marshalErr := json.Marshal(*args.Artifact) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1db06c96-014e-44e1-ac91-90b2d4b3e984") + 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 BuildArtifact + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateArtifact function +type CreateArtifactArgs struct { + // (required) The artifact. + Artifact *BuildArtifact + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int +} + +// Creates a new definition. +func (client *ClientImpl) CreateDefinition(ctx context.Context, args CreateDefinitionArgs) (*BuildDefinition, error) { + if args.Definition == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Definition"} + } + 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.DefinitionToCloneId != nil { + queryParams.Add("definitionToCloneId", strconv.Itoa(*args.DefinitionToCloneId)) + } + if args.DefinitionToCloneRevision != nil { + queryParams.Add("definitionToCloneRevision", strconv.Itoa(*args.DefinitionToCloneRevision)) + } + body, marshalErr := json.Marshal(*args.Definition) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("dbeaf647-6167-421a-bda9-c9327b25e2e6") + 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 BuildDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateDefinition function +type CreateDefinitionArgs struct { + // (required) The definition. + Definition *BuildDefinition + // (required) Project ID or project name + Project *string + // (optional) + DefinitionToCloneId *int + // (optional) + DefinitionToCloneRevision *int +} + +// [Preview API] Creates a new folder. +func (client *ClientImpl) CreateFolder(ctx context.Context, args CreateFolderArgs) (*Folder, error) { + if args.Folder == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Folder"} + } + 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.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + body, marshalErr := json.Marshal(*args.Folder) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a906531b-d2da-4f55-bda7-f3e676cc50d9") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.2", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Folder + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateFolder function +type CreateFolderArgs struct { + // (required) The folder. + Folder *Folder + // (required) Project ID or project name + Project *string + // (required) The full path of the folder. + Path *string +} + +// Deletes a build. +func (client *ClientImpl) DeleteBuild(ctx context.Context, args DeleteBuildArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.BuildId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + locationId, _ := uuid.Parse("0cd358e1-9217-4d94-8269-1c1ee6f93dcf") + _, 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 DeleteBuild function +type DeleteBuildArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int +} + +// Removes a tag from a build. +func (client *ClientImpl) DeleteBuildTag(ctx context.Context, args DeleteBuildTagArgs) (*[]string, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + if args.Tag == nil || *args.Tag == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Tag"} + } + routeValues["tag"] = *args.Tag + + locationId, _ := uuid.Parse("6e6114b2-8161-44c8-8f6c-c5505782427f") + 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 []string + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the DeleteBuildTag function +type DeleteBuildTagArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (required) The tag to remove. + Tag *string +} + +// Deletes a definition and all associated builds. +func (client *ClientImpl) DeleteDefinition(ctx context.Context, args DeleteDefinitionArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DefinitionId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + locationId, _ := uuid.Parse("dbeaf647-6167-421a-bda9-c9327b25e2e6") + _, 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 DeleteDefinition function +type DeleteDefinitionArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the definition. + DefinitionId *int +} + +// [Preview API] Removes a tag from a definition. +func (client *ClientImpl) DeleteDefinitionTag(ctx context.Context, args DeleteDefinitionTagArgs) (*[]string, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + if args.Tag == nil || *args.Tag == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Tag"} + } + routeValues["tag"] = *args.Tag + + locationId, _ := uuid.Parse("cb894432-134a-4d31-a839-83beceaace4b") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.2", routeValues, nil, 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 DeleteDefinitionTag function +type DeleteDefinitionTagArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the definition. + DefinitionId *int + // (required) The tag to remove. + Tag *string +} + +// [Preview API] Deletes a definition folder. Definitions and their corresponding builds will also be deleted. +func (client *ClientImpl) DeleteFolder(ctx context.Context, args DeleteFolderArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.Path == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + locationId, _ := uuid.Parse("a906531b-d2da-4f55-bda7-f3e676cc50d9") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteFolder function +type DeleteFolderArgs struct { + // (required) Project ID or project name + Project *string + // (required) The full path to the folder. + Path *string +} + +// Deletes a build definition template. +func (client *ClientImpl) DeleteTemplate(ctx context.Context, args DeleteTemplateArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.TemplateId == nil || *args.TemplateId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TemplateId"} + } + routeValues["templateId"] = *args.TemplateId + + locationId, _ := uuid.Parse("e884571e-7f92-4d6a-9274-3f5649900835") + _, 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 DeleteTemplate function +type DeleteTemplateArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the template. + TemplateId *string +} + +// Gets a specific artifact for a build. +func (client *ClientImpl) GetArtifact(ctx context.Context, args GetArtifactArgs) (*BuildArtifact, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + queryParams := url.Values{} + if args.ArtifactName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "artifactName"} + } + queryParams.Add("artifactName", *args.ArtifactName) + locationId, _ := uuid.Parse("1db06c96-014e-44e1-ac91-90b2d4b3e984") + 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 BuildArtifact + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetArtifact function +type GetArtifactArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (required) The name of the artifact. + ArtifactName *string +} + +// Gets a specific artifact for a build. +func (client *ClientImpl) GetArtifactContentZip(ctx context.Context, args GetArtifactContentZipArgs) (io.ReadCloser, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + queryParams := url.Values{} + if args.ArtifactName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "artifactName"} + } + queryParams.Add("artifactName", *args.ArtifactName) + locationId, _ := uuid.Parse("1db06c96-014e-44e1-ac91-90b2d4b3e984") + 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 GetArtifactContentZip function +type GetArtifactContentZipArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (required) The name of the artifact. + ArtifactName *string +} + +// Gets all artifacts for a build. +func (client *ClientImpl) GetArtifacts(ctx context.Context, args GetArtifactsArgs) (*[]BuildArtifact, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + locationId, _ := uuid.Parse("1db06c96-014e-44e1-ac91-90b2d4b3e984") + 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 []BuildArtifact + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetArtifacts function +type GetArtifactsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int +} + +// [Preview API] Gets a specific attachment. +func (client *ClientImpl) GetAttachment(ctx context.Context, args GetAttachmentArgs) (io.ReadCloser, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + if args.TimelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} + } + routeValues["timelineId"] = (*args.TimelineId).String() + if args.RecordId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RecordId"} + } + routeValues["recordId"] = (*args.RecordId).String() + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + locationId, _ := uuid.Parse("af5122d3-3438-485e-a25a-2dbbfde84ee6") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/octet-stream", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetAttachment function +type GetAttachmentArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (required) The ID of the timeline. + TimelineId *uuid.UUID + // (required) The ID of the timeline record. + RecordId *uuid.UUID + // (required) The type of the attachment. + Type *string + // (required) The name of the attachment. + Name *string +} + +// [Preview API] Gets the list of attachments of a specific type that are associated with a build. +func (client *ClientImpl) GetAttachments(ctx context.Context, args GetAttachmentsArgs) (*[]Attachment, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + + locationId, _ := uuid.Parse("f2192269-89fa-4f94-baf6-8fb128c55159") + 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 []Attachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAttachments function +type GetAttachmentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (required) The type of attachment. + Type *string +} + +// Gets a build +func (client *ClientImpl) GetBuild(ctx context.Context, args GetBuildArgs) (*Build, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + queryParams := url.Values{} + if args.PropertyFilters != nil { + queryParams.Add("propertyFilters", *args.PropertyFilters) + } + locationId, _ := uuid.Parse("0cd358e1-9217-4d94-8269-1c1ee6f93dcf") + 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 Build + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuild function +type GetBuildArgs struct { + // (required) Project ID or project name + Project *string + // (required) + BuildId *int + // (optional) + PropertyFilters *string +} + +// [Preview API] Gets a badge that indicates the status of the most recent build for the specified branch. +func (client *ClientImpl) GetBuildBadge(ctx context.Context, args GetBuildBadgeArgs) (*BuildBadge, 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.RepoType == nil || *args.RepoType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepoType"} + } + routeValues["repoType"] = *args.RepoType + + queryParams := url.Values{} + if args.RepoId != nil { + queryParams.Add("repoId", *args.RepoId) + } + if args.BranchName != nil { + queryParams.Add("branchName", *args.BranchName) + } + locationId, _ := uuid.Parse("21b3b9ce-fad5-4567-9ad0-80679794e003") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue BuildBadge + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildBadge function +type GetBuildBadgeArgs struct { + // (required) Project ID or project name + Project *string + // (required) The repository type. + RepoType *string + // (optional) The repository ID. + RepoId *string + // (optional) The branch name. + BranchName *string +} + +// [Preview API] Gets a badge that indicates the status of the most recent build for the specified branch. +func (client *ClientImpl) GetBuildBadgeData(ctx context.Context, args GetBuildBadgeDataArgs) (*string, 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.RepoType == nil || *args.RepoType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RepoType"} + } + routeValues["repoType"] = *args.RepoType + + queryParams := url.Values{} + if args.RepoId != nil { + queryParams.Add("repoId", *args.RepoId) + } + if args.BranchName != nil { + queryParams.Add("branchName", *args.BranchName) + } + locationId, _ := uuid.Parse("21b3b9ce-fad5-4567-9ad0-80679794e003") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", 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 GetBuildBadgeData function +type GetBuildBadgeDataArgs struct { + // (required) Project ID or project name + Project *string + // (required) The repository type. + RepoType *string + // (optional) The repository ID. + RepoId *string + // (optional) The branch name. + BranchName *string +} + +// Gets the changes associated with a build +func (client *ClientImpl) GetBuildChanges(ctx context.Context, args GetBuildChangesArgs) (*GetBuildChangesResponseValue, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + queryParams := url.Values{} + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.IncludeSourceChange != nil { + queryParams.Add("includeSourceChange", strconv.FormatBool(*args.IncludeSourceChange)) + } + locationId, _ := uuid.Parse("54572c7b-bbd3-45d4-80dc-28be08941620") + 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 GetBuildChangesResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetBuildChanges function +type GetBuildChangesArgs struct { + // (required) Project ID or project name + Project *string + // (required) + BuildId *int + // (optional) + ContinuationToken *string + // (optional) The maximum number of changes to return + Top *int + // (optional) + IncludeSourceChange *bool +} + +// Return type for the GetBuildChanges function +type GetBuildChangesResponseValue struct { + Value []Change + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// Gets a controller +func (client *ClientImpl) GetBuildController(ctx context.Context, args GetBuildControllerArgs) (*BuildController, error) { + routeValues := make(map[string]string) + if args.ControllerId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ControllerId"} + } + routeValues["controllerId"] = strconv.Itoa(*args.ControllerId) + + locationId, _ := uuid.Parse("fcac1932-2ee1-437f-9b6f-7f696be858f6") + 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 BuildController + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildController function +type GetBuildControllerArgs struct { + // (required) + ControllerId *int +} + +// Gets controller, optionally filtered by name +func (client *ClientImpl) GetBuildControllers(ctx context.Context, args GetBuildControllersArgs) (*[]BuildController, error) { + queryParams := url.Values{} + if args.Name != nil { + queryParams.Add("name", *args.Name) + } + locationId, _ := uuid.Parse("fcac1932-2ee1-437f-9b6f-7f696be858f6") + 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 []BuildController + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildControllers function +type GetBuildControllersArgs struct { + // (optional) + Name *string +} + +// Gets an individual log file for a build. +func (client *ClientImpl) GetBuildLog(ctx context.Context, args GetBuildLogArgs) (io.ReadCloser, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + if args.LogId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.LogId"} + } + routeValues["logId"] = strconv.Itoa(*args.LogId) + + queryParams := url.Values{} + if args.StartLine != nil { + queryParams.Add("startLine", strconv.FormatUint(*args.StartLine, 10)) + } + if args.EndLine != nil { + queryParams.Add("endLine", strconv.FormatUint(*args.EndLine, 10)) + } + locationId, _ := uuid.Parse("35a80daf-7f30-45fc-86e8-6b813d9c90df") + 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 GetBuildLog function +type GetBuildLogArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (required) The ID of the log file. + LogId *int + // (optional) The start line. + StartLine *uint64 + // (optional) The end line. + EndLine *uint64 +} + +// Gets an individual log file for a build. +func (client *ClientImpl) GetBuildLogLines(ctx context.Context, args GetBuildLogLinesArgs) (*[]string, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + if args.LogId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.LogId"} + } + routeValues["logId"] = strconv.Itoa(*args.LogId) + + queryParams := url.Values{} + if args.StartLine != nil { + queryParams.Add("startLine", strconv.FormatUint(*args.StartLine, 10)) + } + if args.EndLine != nil { + queryParams.Add("endLine", strconv.FormatUint(*args.EndLine, 10)) + } + locationId, _ := uuid.Parse("35a80daf-7f30-45fc-86e8-6b813d9c90df") + 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 []string + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildLogLines function +type GetBuildLogLinesArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (required) The ID of the log file. + LogId *int + // (optional) The start line. + StartLine *uint64 + // (optional) The end line. + EndLine *uint64 +} + +// Gets the logs for a build. +func (client *ClientImpl) GetBuildLogs(ctx context.Context, args GetBuildLogsArgs) (*[]BuildLog, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + locationId, _ := uuid.Parse("35a80daf-7f30-45fc-86e8-6b813d9c90df") + 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 []BuildLog + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildLogs function +type GetBuildLogsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int +} + +// Gets the logs for a build. +func (client *ClientImpl) GetBuildLogsZip(ctx context.Context, args GetBuildLogsZipArgs) (io.ReadCloser, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + locationId, _ := uuid.Parse("35a80daf-7f30-45fc-86e8-6b813d9c90df") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetBuildLogsZip function +type GetBuildLogsZipArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int +} + +// Gets an individual log file for a build. +func (client *ClientImpl) GetBuildLogZip(ctx context.Context, args GetBuildLogZipArgs) (io.ReadCloser, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + if args.LogId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.LogId"} + } + routeValues["logId"] = strconv.Itoa(*args.LogId) + + queryParams := url.Values{} + if args.StartLine != nil { + queryParams.Add("startLine", strconv.FormatUint(*args.StartLine, 10)) + } + if args.EndLine != nil { + queryParams.Add("endLine", strconv.FormatUint(*args.EndLine, 10)) + } + locationId, _ := uuid.Parse("35a80daf-7f30-45fc-86e8-6b813d9c90df") + 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 GetBuildLogZip function +type GetBuildLogZipArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (required) The ID of the log file. + LogId *int + // (optional) The start line. + StartLine *uint64 + // (optional) The end line. + EndLine *uint64 +} + +// Gets all build definition options supported by the system. +func (client *ClientImpl) GetBuildOptionDefinitions(ctx context.Context, args GetBuildOptionDefinitionsArgs) (*[]BuildOptionDefinition, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + locationId, _ := uuid.Parse("591cb5a4-2d46-4f3a-a697-5cd42b6bd332") + 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 []BuildOptionDefinition + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildOptionDefinitions function +type GetBuildOptionDefinitionsArgs struct { + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Gets properties for a build. +func (client *ClientImpl) GetBuildProperties(ctx context.Context, args GetBuildPropertiesArgs) (interface{}, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + queryParams := url.Values{} + if args.Filter != nil { + listAsString := strings.Join((*args.Filter)[:], ",") + queryParams.Add("filter", listAsString) + } + locationId, _ := uuid.Parse("0a6312e9-0627-49b7-8083-7d74a64849c9") + 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 interface{} + err = client.Client.UnmarshalBody(resp, responseValue) + return responseValue, err +} + +// Arguments for the GetBuildProperties function +type GetBuildPropertiesArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (optional) A comma-delimited list of properties. If specified, filters to these specific properties. + Filter *[]string +} + +// [Preview API] Gets a build report. +func (client *ClientImpl) GetBuildReport(ctx context.Context, args GetBuildReportArgs) (*BuildReportMetadata, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + queryParams := url.Values{} + if args.Type != nil { + queryParams.Add("type", *args.Type) + } + locationId, _ := uuid.Parse("45bcaa88-67e1-4042-a035-56d3b4a7d44c") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue BuildReportMetadata + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildReport function +type GetBuildReportArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (optional) + Type *string +} + +// [Preview API] Gets a build report. +func (client *ClientImpl) GetBuildReportHtmlContent(ctx context.Context, args GetBuildReportHtmlContentArgs) (io.ReadCloser, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + queryParams := url.Values{} + if args.Type != nil { + queryParams.Add("type", *args.Type) + } + locationId, _ := uuid.Parse("45bcaa88-67e1-4042-a035-56d3b4a7d44c") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "text/html", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetBuildReportHtmlContent function +type GetBuildReportHtmlContentArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (optional) + Type *string +} + +// Gets a list of builds. +func (client *ClientImpl) GetBuilds(ctx context.Context, args GetBuildsArgs) (*GetBuildsResponseValue, 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.Definitions != nil { + var stringList []string + for _, item := range *args.Definitions { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("definitions", listAsString) + } + if args.Queues != nil { + var stringList []string + for _, item := range *args.Queues { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("queues", listAsString) + } + if args.BuildNumber != nil { + queryParams.Add("buildNumber", *args.BuildNumber) + } + if args.MinTime != nil { + queryParams.Add("minTime", (*args.MinTime).String()) + } + if args.MaxTime != nil { + queryParams.Add("maxTime", (*args.MaxTime).String()) + } + if args.RequestedFor != nil { + queryParams.Add("requestedFor", *args.RequestedFor) + } + if args.ReasonFilter != nil { + queryParams.Add("reasonFilter", string(*args.ReasonFilter)) + } + if args.StatusFilter != nil { + queryParams.Add("statusFilter", string(*args.StatusFilter)) + } + if args.ResultFilter != nil { + queryParams.Add("resultFilter", string(*args.ResultFilter)) + } + if args.TagFilters != nil { + listAsString := strings.Join((*args.TagFilters)[:], ",") + queryParams.Add("tagFilters", listAsString) + } + if args.Properties != nil { + listAsString := strings.Join((*args.Properties)[:], ",") + queryParams.Add("properties", listAsString) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.MaxBuildsPerDefinition != nil { + queryParams.Add("maxBuildsPerDefinition", strconv.Itoa(*args.MaxBuildsPerDefinition)) + } + if args.DeletedFilter != nil { + queryParams.Add("deletedFilter", string(*args.DeletedFilter)) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + if args.BranchName != nil { + queryParams.Add("branchName", *args.BranchName) + } + if args.BuildIds != nil { + var stringList []string + for _, item := range *args.BuildIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("buildIds", listAsString) + } + if args.RepositoryId != nil { + queryParams.Add("repositoryId", *args.RepositoryId) + } + if args.RepositoryType != nil { + queryParams.Add("repositoryType", *args.RepositoryType) + } + locationId, _ := uuid.Parse("0cd358e1-9217-4d94-8269-1c1ee6f93dcf") + 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 GetBuildsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetBuilds function +type GetBuildsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) A comma-delimited list of definition IDs. If specified, filters to builds for these definitions. + Definitions *[]int + // (optional) A comma-delimited list of queue IDs. If specified, filters to builds that ran against these queues. + Queues *[]int + // (optional) If specified, filters to builds that match this build number. Append * to do a prefix search. + BuildNumber *string + // (optional) If specified, filters to builds that finished/started/queued after this date based on the queryOrder specified. + MinTime *azuredevops.Time + // (optional) If specified, filters to builds that finished/started/queued before this date based on the queryOrder specified. + MaxTime *azuredevops.Time + // (optional) If specified, filters to builds requested for the specified user. + RequestedFor *string + // (optional) If specified, filters to builds that match this reason. + ReasonFilter *BuildReason + // (optional) If specified, filters to builds that match this status. + StatusFilter *BuildStatus + // (optional) If specified, filters to builds that match this result. + ResultFilter *BuildResult + // (optional) A comma-delimited list of tags. If specified, filters to builds that have the specified tags. + TagFilters *[]string + // (optional) A comma-delimited list of properties to retrieve. + Properties *[]string + // (optional) The maximum number of builds to return. + Top *int + // (optional) A continuation token, returned by a previous call to this method, that can be used to return the next set of builds. + ContinuationToken *string + // (optional) The maximum number of builds to return per definition. + MaxBuildsPerDefinition *int + // (optional) Indicates whether to exclude, include, or only return deleted builds. + DeletedFilter *QueryDeletedOption + // (optional) The order in which builds should be returned. + QueryOrder *BuildQueryOrder + // (optional) If specified, filters to builds that built branches that built this branch. + BranchName *string + // (optional) A comma-delimited list that specifies the IDs of builds to retrieve. + BuildIds *[]int + // (optional) If specified, filters to builds that built from this repository. + RepositoryId *string + // (optional) If specified, filters to builds that built from repositories of this type. + RepositoryType *string +} + +// Return type for the GetBuilds function +type GetBuildsResponseValue struct { + Value []Build + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// Gets the build settings. +func (client *ClientImpl) GetBuildSettings(ctx context.Context, args GetBuildSettingsArgs) (*BuildSettings, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + locationId, _ := uuid.Parse("aa8c1c9c-ef8b-474a-b8c4-785c7b191d0d") + 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 BuildSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildSettings function +type GetBuildSettingsArgs struct { + // (optional) Project ID or project name + Project *string +} + +// Gets the tags for a build. +func (client *ClientImpl) GetBuildTags(ctx context.Context, args GetBuildTagsArgs) (*[]string, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + locationId, _ := uuid.Parse("6e6114b2-8161-44c8-8f6c-c5505782427f") + 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 []string + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildTags function +type GetBuildTagsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int +} + +// Gets details for a build +func (client *ClientImpl) GetBuildTimeline(ctx context.Context, args GetBuildTimelineArgs) (*Timeline, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + if args.TimelineId != nil { + routeValues["timelineId"] = (*args.TimelineId).String() + } + + queryParams := url.Values{} + if args.ChangeId != nil { + queryParams.Add("changeId", strconv.Itoa(*args.ChangeId)) + } + if args.PlanId != nil { + queryParams.Add("planId", (*args.PlanId).String()) + } + locationId, _ := uuid.Parse("8baac422-4c6e-4de5-8532-db96d92acffa") + 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 Timeline + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildTimeline function +type GetBuildTimelineArgs struct { + // (required) Project ID or project name + Project *string + // (required) + BuildId *int + // (optional) + TimelineId *uuid.UUID + // (optional) + ChangeId *int + // (optional) + PlanId *uuid.UUID +} + +// Gets the work items associated with a build. +func (client *ClientImpl) GetBuildWorkItemsRefs(ctx context.Context, args GetBuildWorkItemsRefsArgs) (*[]webapi.ResourceRef, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + locationId, _ := uuid.Parse("5a21f5d2-5642-47e4-a0bd-1356e6731bee") + 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.ResourceRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildWorkItemsRefs function +type GetBuildWorkItemsRefsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (optional) The maximum number of work items to return. + Top *int +} + +// Gets the work items associated with a build, filtered to specific commits. +func (client *ClientImpl) GetBuildWorkItemsRefsFromCommits(ctx context.Context, args GetBuildWorkItemsRefsFromCommitsArgs) (*[]webapi.ResourceRef, error) { + if args.CommitIds == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommitIds"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + body, marshalErr := json.Marshal(*args.CommitIds) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("5a21f5d2-5642-47e4-a0bd-1356e6731bee") + 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 []webapi.ResourceRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildWorkItemsRefsFromCommits function +type GetBuildWorkItemsRefsFromCommitsArgs struct { + // (required) A comma-delimited list of commit IDs. + CommitIds *[]string + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (optional) The maximum number of work items to return, or the number of commits to consider if no commit IDs are specified. + Top *int +} + +// [Preview API] Gets the changes made to the repository between two given builds. +func (client *ClientImpl) GetChangesBetweenBuilds(ctx context.Context, args GetChangesBetweenBuildsArgs) (*[]Change, 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.FromBuildId != nil { + queryParams.Add("fromBuildId", strconv.Itoa(*args.FromBuildId)) + } + if args.ToBuildId != nil { + queryParams.Add("toBuildId", strconv.Itoa(*args.ToBuildId)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + locationId, _ := uuid.Parse("f10f0ea5-18a1-43ec-a8fb-2042c7be9b43") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Change + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetChangesBetweenBuilds function +type GetChangesBetweenBuildsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) The ID of the first build. + FromBuildId *int + // (optional) The ID of the last build. + ToBuildId *int + // (optional) The maximum number of changes to return. + Top *int +} + +// Gets a definition, optionally at a specific revision. +func (client *ClientImpl) GetDefinition(ctx context.Context, args GetDefinitionArgs) (*BuildDefinition, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + queryParams := url.Values{} + if args.Revision != nil { + queryParams.Add("revision", strconv.Itoa(*args.Revision)) + } + if args.MinMetricsTime != nil { + queryParams.Add("minMetricsTime", (*args.MinMetricsTime).String()) + } + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + if args.IncludeLatestBuilds != nil { + queryParams.Add("includeLatestBuilds", strconv.FormatBool(*args.IncludeLatestBuilds)) + } + locationId, _ := uuid.Parse("dbeaf647-6167-421a-bda9-c9327b25e2e6") + 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 BuildDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDefinition function +type GetDefinitionArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the definition. + DefinitionId *int + // (optional) The revision number to retrieve. If this is not specified, the latest version will be returned. + Revision *int + // (optional) If specified, indicates the date from which metrics should be included. + MinMetricsTime *azuredevops.Time + // (optional) A comma-delimited list of properties to include in the results. + PropertyFilters *[]string + // (optional) + IncludeLatestBuilds *bool +} + +// [Preview API] Gets build metrics for a definition. +func (client *ClientImpl) GetDefinitionMetrics(ctx context.Context, args GetDefinitionMetricsArgs) (*[]BuildMetric, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + queryParams := url.Values{} + if args.MinMetricsTime != nil { + queryParams.Add("minMetricsTime", (*args.MinMetricsTime).String()) + } + locationId, _ := uuid.Parse("d973b939-0ce0-4fec-91d8-da3940fa1827") + 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 []BuildMetric + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDefinitionMetrics function +type GetDefinitionMetricsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the definition. + DefinitionId *int + // (optional) The date from which to calculate metrics. + MinMetricsTime *azuredevops.Time +} + +// [Preview API] Gets properties for a definition. +func (client *ClientImpl) GetDefinitionProperties(ctx context.Context, args GetDefinitionPropertiesArgs) (interface{}, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + queryParams := url.Values{} + if args.Filter != nil { + listAsString := strings.Join((*args.Filter)[:], ",") + queryParams.Add("filter", listAsString) + } + locationId, _ := uuid.Parse("d9826ad7-2a68-46a9-a6e9-677698777895") + 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 interface{} + err = client.Client.UnmarshalBody(resp, responseValue) + return responseValue, err +} + +// Arguments for the GetDefinitionProperties function +type GetDefinitionPropertiesArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the definition. + DefinitionId *int + // (optional) A comma-delimited list of properties. If specified, filters to these specific properties. + Filter *[]string +} + +// [Preview API] +func (client *ClientImpl) GetDefinitionResources(ctx context.Context, args GetDefinitionResourcesArgs) (*[]DefinitionResourceReference, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + locationId, _ := uuid.Parse("ea623316-1967-45eb-89ab-e9e6110cf2d6") + 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 []DefinitionResourceReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDefinitionResources function +type GetDefinitionResourcesArgs struct { + // (required) Project ID or project name + Project *string + // (required) + DefinitionId *int +} + +// Gets all revisions of a definition. +func (client *ClientImpl) GetDefinitionRevisions(ctx context.Context, args GetDefinitionRevisionsArgs) (*[]BuildDefinitionRevision, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + locationId, _ := uuid.Parse("7c116775-52e5-453e-8c5d-914d9762d8c4") + 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 []BuildDefinitionRevision + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDefinitionRevisions function +type GetDefinitionRevisionsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the definition. + DefinitionId *int +} + +// Gets a list of definitions. +func (client *ClientImpl) GetDefinitions(ctx context.Context, args GetDefinitionsArgs) (*GetDefinitionsResponseValue, 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.Name != nil { + queryParams.Add("name", *args.Name) + } + if args.RepositoryId != nil { + queryParams.Add("repositoryId", *args.RepositoryId) + } + if args.RepositoryType != nil { + queryParams.Add("repositoryType", *args.RepositoryType) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.MinMetricsTime != nil { + queryParams.Add("minMetricsTime", (*args.MinMetricsTime).String()) + } + if args.DefinitionIds != nil { + var stringList []string + for _, item := range *args.DefinitionIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("definitionIds", listAsString) + } + if args.Path != nil { + queryParams.Add("path", *args.Path) + } + if args.BuiltAfter != nil { + queryParams.Add("builtAfter", (*args.BuiltAfter).String()) + } + if args.NotBuiltAfter != nil { + queryParams.Add("notBuiltAfter", (*args.NotBuiltAfter).String()) + } + if args.IncludeAllProperties != nil { + queryParams.Add("includeAllProperties", strconv.FormatBool(*args.IncludeAllProperties)) + } + if args.IncludeLatestBuilds != nil { + queryParams.Add("includeLatestBuilds", strconv.FormatBool(*args.IncludeLatestBuilds)) + } + if args.TaskIdFilter != nil { + queryParams.Add("taskIdFilter", (*args.TaskIdFilter).String()) + } + if args.ProcessType != nil { + queryParams.Add("processType", strconv.Itoa(*args.ProcessType)) + } + if args.YamlFilename != nil { + queryParams.Add("yamlFilename", *args.YamlFilename) + } + locationId, _ := uuid.Parse("dbeaf647-6167-421a-bda9-c9327b25e2e6") + 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 GetDefinitionsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetDefinitions function +type GetDefinitionsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) If specified, filters to definitions whose names match this pattern. + Name *string + // (optional) A repository ID. If specified, filters to definitions that use this repository. + RepositoryId *string + // (optional) If specified, filters to definitions that have a repository of this type. + RepositoryType *string + // (optional) Indicates the order in which definitions should be returned. + QueryOrder *DefinitionQueryOrder + // (optional) The maximum number of definitions to return. + Top *int + // (optional) A continuation token, returned by a previous call to this method, that can be used to return the next set of definitions. + ContinuationToken *string + // (optional) If specified, indicates the date from which metrics should be included. + MinMetricsTime *azuredevops.Time + // (optional) A comma-delimited list that specifies the IDs of definitions to retrieve. + DefinitionIds *[]int + // (optional) If specified, filters to definitions under this folder. + Path *string + // (optional) If specified, filters to definitions that have builds after this date. + BuiltAfter *azuredevops.Time + // (optional) If specified, filters to definitions that do not have builds after this date. + NotBuiltAfter *azuredevops.Time + // (optional) Indicates whether the full definitions should be returned. By default, shallow representations of the definitions are returned. + IncludeAllProperties *bool + // (optional) Indicates whether to return the latest and latest completed builds for this definition. + IncludeLatestBuilds *bool + // (optional) If specified, filters to definitions that use the specified task. + TaskIdFilter *uuid.UUID + // (optional) If specified, filters to definitions with the given process type. + ProcessType *int + // (optional) If specified, filters to YAML definitions that match the given filename. + YamlFilename *string +} + +// Return type for the GetDefinitions function +type GetDefinitionsResponseValue struct { + Value []BuildDefinitionReference + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Gets the tags for a definition. +func (client *ClientImpl) GetDefinitionTags(ctx context.Context, args GetDefinitionTagsArgs) (*[]string, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + queryParams := url.Values{} + if args.Revision != nil { + queryParams.Add("revision", strconv.Itoa(*args.Revision)) + } + locationId, _ := uuid.Parse("cb894432-134a-4d31-a839-83beceaace4b") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", 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 GetDefinitionTags function +type GetDefinitionTagsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the definition. + DefinitionId *int + // (optional) The definition revision number. If not specified, uses the latest revision of the definition. + Revision *int +} + +// Gets a file from the build. +func (client *ClientImpl) GetFile(ctx context.Context, args GetFileArgs) (io.ReadCloser, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + queryParams := url.Values{} + if args.ArtifactName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "artifactName"} + } + queryParams.Add("artifactName", *args.ArtifactName) + if args.FileId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "fileId"} + } + queryParams.Add("fileId", *args.FileId) + if args.FileName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "fileName"} + } + queryParams.Add("fileName", *args.FileName) + locationId, _ := uuid.Parse("1db06c96-014e-44e1-ac91-90b2d4b3e984") + 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 GetFile function +type GetFileArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (required) The name of the artifact. + ArtifactName *string + // (required) The primary key for the file. + FileId *string + // (required) The name that the file will be set to. + FileName *string +} + +// [Preview API] Gets the contents of a file in the given source code repository. +func (client *ClientImpl) GetFileContents(ctx context.Context, args GetFileContentsArgs) (io.ReadCloser, 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.ProviderName == nil || *args.ProviderName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProviderName"} + } + routeValues["providerName"] = *args.ProviderName + + queryParams := url.Values{} + if args.ServiceEndpointId != nil { + queryParams.Add("serviceEndpointId", (*args.ServiceEndpointId).String()) + } + if args.Repository != nil { + queryParams.Add("repository", *args.Repository) + } + if args.CommitOrBranch != nil { + queryParams.Add("commitOrBranch", *args.CommitOrBranch) + } + if args.Path != nil { + queryParams.Add("path", *args.Path) + } + locationId, _ := uuid.Parse("29d12225-b1d9-425f-b668-6c594a981313") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "text/plain", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetFileContents function +type GetFileContentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The name of the source provider. + ProviderName *string + // (optional) If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. + ServiceEndpointId *uuid.UUID + // (optional) If specified, the vendor-specific identifier or the name of the repository to get branches. Can only be omitted for providers that do not support multiple repositories. + Repository *string + // (optional) The identifier of the commit or branch from which a file's contents are retrieved. + CommitOrBranch *string + // (optional) The path to the file to retrieve, relative to the root of the repository. + Path *string +} + +// [Preview API] Gets a list of build definition folders. +func (client *ClientImpl) GetFolders(ctx context.Context, args GetFoldersArgs) (*[]Folder, 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.Path != nil && *args.Path != "" { + routeValues["path"] = *args.Path + } + + queryParams := url.Values{} + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + locationId, _ := uuid.Parse("a906531b-d2da-4f55-bda7-f3e676cc50d9") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Folder + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFolders function +type GetFoldersArgs struct { + // (required) Project ID or project name + Project *string + // (optional) The path to start with. + Path *string + // (optional) The order in which folders should be returned. + QueryOrder *FolderQueryOrder +} + +// [Preview API] Gets the latest build for a definition, optionally scoped to a specific branch. +func (client *ClientImpl) GetLatestBuild(ctx context.Context, args GetLatestBuildArgs) (*Build, 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.Definition == nil || *args.Definition == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Definition"} + } + routeValues["definition"] = *args.Definition + + queryParams := url.Values{} + if args.BranchName != nil { + queryParams.Add("branchName", *args.BranchName) + } + locationId, _ := uuid.Parse("54481611-01f4-47f3-998f-160da0f0c229") + 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 Build + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetLatestBuild function +type GetLatestBuildArgs struct { + // (required) Project ID or project name + Project *string + // (required) definition name with optional leading folder path, or the definition id + Definition *string + // (optional) optional parameter that indicates the specific branch to use + BranchName *string +} + +// [Preview API] Gets the contents of a directory in the given source code repository. +func (client *ClientImpl) GetPathContents(ctx context.Context, args GetPathContentsArgs) (*[]SourceRepositoryItem, 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.ProviderName == nil || *args.ProviderName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProviderName"} + } + routeValues["providerName"] = *args.ProviderName + + queryParams := url.Values{} + if args.ServiceEndpointId != nil { + queryParams.Add("serviceEndpointId", (*args.ServiceEndpointId).String()) + } + if args.Repository != nil { + queryParams.Add("repository", *args.Repository) + } + if args.CommitOrBranch != nil { + queryParams.Add("commitOrBranch", *args.CommitOrBranch) + } + if args.Path != nil { + queryParams.Add("path", *args.Path) + } + locationId, _ := uuid.Parse("7944d6fb-df01-4709-920a-7a189aa34037") + 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 []SourceRepositoryItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPathContents function +type GetPathContentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The name of the source provider. + ProviderName *string + // (optional) If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. + ServiceEndpointId *uuid.UUID + // (optional) If specified, the vendor-specific identifier or the name of the repository to get branches. Can only be omitted for providers that do not support multiple repositories. + Repository *string + // (optional) The identifier of the commit or branch from which a file's contents are retrieved. + CommitOrBranch *string + // (optional) The path contents to list, relative to the root of the repository. + Path *string +} + +// [Preview API] Gets build metrics for a project. +func (client *ClientImpl) GetProjectMetrics(ctx context.Context, args GetProjectMetricsArgs) (*[]BuildMetric, 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.MetricAggregationType != nil && *args.MetricAggregationType != "" { + routeValues["metricAggregationType"] = *args.MetricAggregationType + } + + queryParams := url.Values{} + if args.MinMetricsTime != nil { + queryParams.Add("minMetricsTime", (*args.MinMetricsTime).String()) + } + locationId, _ := uuid.Parse("7433fae7-a6bc-41dc-a6e2-eef9005ce41a") + 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 []BuildMetric + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProjectMetrics function +type GetProjectMetricsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) The aggregation type to use (hourly, daily). + MetricAggregationType *string + // (optional) The date from which to calculate metrics. + MinMetricsTime *azuredevops.Time +} + +// [Preview API] +func (client *ClientImpl) GetProjectResources(ctx context.Context, args GetProjectResourcesArgs) (*[]DefinitionResourceReference, 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.Type != nil { + queryParams.Add("type", *args.Type) + } + if args.Id != nil { + queryParams.Add("id", *args.Id) + } + locationId, _ := uuid.Parse("398c85bc-81aa-4822-947c-a194a05f0fef") + 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 []DefinitionResourceReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProjectResources function +type GetProjectResourcesArgs struct { + // (required) Project ID or project name + Project *string + // (optional) + Type *string + // (optional) + Id *string +} + +// [Preview API] Gets a pull request object from source provider. +func (client *ClientImpl) GetPullRequest(ctx context.Context, args GetPullRequestArgs) (*PullRequest, 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.ProviderName == nil || *args.ProviderName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProviderName"} + } + routeValues["providerName"] = *args.ProviderName + if args.PullRequestId == nil || *args.PullRequestId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PullRequestId"} + } + routeValues["pullRequestId"] = *args.PullRequestId + + queryParams := url.Values{} + if args.RepositoryId != nil { + queryParams.Add("repositoryId", *args.RepositoryId) + } + if args.ServiceEndpointId != nil { + queryParams.Add("serviceEndpointId", (*args.ServiceEndpointId).String()) + } + locationId, _ := uuid.Parse("d8763ec7-9ff0-4fb4-b2b2-9d757906ff14") + 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 PullRequest + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPullRequest function +type GetPullRequestArgs struct { + // (required) Project ID or project name + Project *string + // (required) The name of the source provider. + ProviderName *string + // (required) Vendor-specific id of the pull request. + PullRequestId *string + // (optional) Vendor-specific identifier or the name of the repository that contains the pull request. + RepositoryId *string + // (optional) If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. + ServiceEndpointId *uuid.UUID +} + +// [Preview API] Gets information about build resources in the system. +func (client *ClientImpl) GetResourceUsage(ctx context.Context, args GetResourceUsageArgs) (*BuildResourceUsage, error) { + locationId, _ := uuid.Parse("3813d06c-9e36-4ea1-aac3-61a485d60e3d") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", nil, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue BuildResourceUsage + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetResourceUsage function +type GetResourceUsageArgs struct { +} + +// [Preview API]

Gets the build status for a definition, optionally scoped to a specific branch, stage, job, and configuration.

If there are more than one, then it is required to pass in a stageName value when specifying a jobName, and the same rule then applies for both if passing a configuration parameter.

+func (client *ClientImpl) GetStatusBadge(ctx context.Context, args GetStatusBadgeArgs) (*string, 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.Definition == nil || *args.Definition == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Definition"} + } + routeValues["definition"] = *args.Definition + + queryParams := url.Values{} + if args.BranchName != nil { + queryParams.Add("branchName", *args.BranchName) + } + if args.StageName != nil { + queryParams.Add("stageName", *args.StageName) + } + if args.JobName != nil { + queryParams.Add("jobName", *args.JobName) + } + if args.Configuration != nil { + queryParams.Add("configuration", *args.Configuration) + } + if args.Label != nil { + queryParams.Add("label", *args.Label) + } + locationId, _ := uuid.Parse("07acfdce-4757-4439-b422-ddd13a2fcc10") + 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 GetStatusBadge function +type GetStatusBadgeArgs struct { + // (required) Project ID or project name + Project *string + // (required) Either the definition name with optional leading folder path, or the definition id. + Definition *string + // (optional) Only consider the most recent build for this branch. + BranchName *string + // (optional) Use this stage within the pipeline to render the status. + StageName *string + // (optional) Use this job within a stage of the pipeline to render the status. + JobName *string + // (optional) Use this job configuration to render the status + Configuration *string + // (optional) Replaces the default text on the left side of the badge. + Label *string +} + +// Gets a list of all build and definition tags in the project. +func (client *ClientImpl) GetTags(ctx context.Context, args GetTagsArgs) (*[]string, 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("d84ac5c6-edc7-43d5-adc9-1b34be5dea09") + 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 []string + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTags function +type GetTagsArgs struct { + // (required) Project ID or project name + Project *string +} + +// Gets a specific build definition template. +func (client *ClientImpl) GetTemplate(ctx context.Context, args GetTemplateArgs) (*BuildDefinitionTemplate, 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.TemplateId == nil || *args.TemplateId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TemplateId"} + } + routeValues["templateId"] = *args.TemplateId + + locationId, _ := uuid.Parse("e884571e-7f92-4d6a-9274-3f5649900835") + 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 BuildDefinitionTemplate + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTemplate function +type GetTemplateArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the requested template. + TemplateId *string +} + +// Gets all definition templates. +func (client *ClientImpl) GetTemplates(ctx context.Context, args GetTemplatesArgs) (*[]BuildDefinitionTemplate, 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("e884571e-7f92-4d6a-9274-3f5649900835") + 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 []BuildDefinitionTemplate + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTemplates function +type GetTemplatesArgs struct { + // (required) Project ID or project name + Project *string +} + +// [Preview API] Gets all the work items between two builds. +func (client *ClientImpl) GetWorkItemsBetweenBuilds(ctx context.Context, args GetWorkItemsBetweenBuildsArgs) (*[]webapi.ResourceRef, 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.FromBuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "fromBuildId"} + } + queryParams.Add("fromBuildId", strconv.Itoa(*args.FromBuildId)) + if args.ToBuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "toBuildId"} + } + queryParams.Add("toBuildId", strconv.Itoa(*args.ToBuildId)) + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + locationId, _ := uuid.Parse("52ba8915-5518-42e3-a4bb-b0182d159e2d") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, 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 GetWorkItemsBetweenBuilds function +type GetWorkItemsBetweenBuildsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The ID of the first build. + FromBuildId *int + // (required) The ID of the last build. + ToBuildId *int + // (optional) The maximum number of work items to return. + Top *int +} + +// [Preview API] Gets a list of branches for the given source code repository. +func (client *ClientImpl) ListBranches(ctx context.Context, args ListBranchesArgs) (*[]string, 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.ProviderName == nil || *args.ProviderName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProviderName"} + } + routeValues["providerName"] = *args.ProviderName + + queryParams := url.Values{} + if args.ServiceEndpointId != nil { + queryParams.Add("serviceEndpointId", (*args.ServiceEndpointId).String()) + } + if args.Repository != nil { + queryParams.Add("repository", *args.Repository) + } + if args.BranchName != nil { + queryParams.Add("branchName", *args.BranchName) + } + locationId, _ := uuid.Parse("e05d4403-9b81-4244-8763-20fde28d1976") + 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 ListBranches function +type ListBranchesArgs struct { + // (required) Project ID or project name + Project *string + // (required) The name of the source provider. + ProviderName *string + // (optional) If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. + ServiceEndpointId *uuid.UUID + // (optional) The vendor-specific identifier or the name of the repository to get branches. Can only be omitted for providers that do not support multiple repositories. + Repository *string + // (optional) If supplied, the name of the branch to check for specifically. + BranchName *string +} + +// [Preview API] Gets a list of source code repositories. +func (client *ClientImpl) ListRepositories(ctx context.Context, args ListRepositoriesArgs) (*SourceRepositories, 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.ProviderName == nil || *args.ProviderName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProviderName"} + } + routeValues["providerName"] = *args.ProviderName + + queryParams := url.Values{} + if args.ServiceEndpointId != nil { + queryParams.Add("serviceEndpointId", (*args.ServiceEndpointId).String()) + } + if args.Repository != nil { + queryParams.Add("repository", *args.Repository) + } + if args.ResultSet != nil { + queryParams.Add("resultSet", string(*args.ResultSet)) + } + if args.PageResults != nil { + queryParams.Add("pageResults", strconv.FormatBool(*args.PageResults)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("d44d1680-f978-4834-9b93-8c6e132329c9") + 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 SourceRepositories + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListRepositories function +type ListRepositoriesArgs struct { + // (required) Project ID or project name + Project *string + // (required) The name of the source provider. + ProviderName *string + // (optional) If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. + ServiceEndpointId *uuid.UUID + // (optional) If specified, the vendor-specific identifier or the name of a single repository to get. + Repository *string + // (optional) 'top' for the repositories most relevant for the endpoint. If not set, all repositories are returned. Ignored if 'repository' is set. + ResultSet *ResultSet + // (optional) If set to true, this will limit the set of results and will return a continuation token to continue the query. + PageResults *bool + // (optional) When paging results, this is a continuation token, returned by a previous call to this method, that can be used to return the next set of repositories. + ContinuationToken *string +} + +// [Preview API] Get a list of source providers and their capabilities. +func (client *ClientImpl) ListSourceProviders(ctx context.Context, args ListSourceProvidersArgs) (*[]SourceProviderAttributes, 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("3ce81729-954f-423d-a581-9fea01d25186") + 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 []SourceProviderAttributes + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListSourceProviders function +type ListSourceProvidersArgs struct { + // (required) Project ID or project name + Project *string +} + +// [Preview API] Gets a list of webhooks installed in the given source code repository. +func (client *ClientImpl) ListWebhooks(ctx context.Context, args ListWebhooksArgs) (*[]RepositoryWebhook, 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.ProviderName == nil || *args.ProviderName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProviderName"} + } + routeValues["providerName"] = *args.ProviderName + + queryParams := url.Values{} + if args.ServiceEndpointId != nil { + queryParams.Add("serviceEndpointId", (*args.ServiceEndpointId).String()) + } + if args.Repository != nil { + queryParams.Add("repository", *args.Repository) + } + locationId, _ := uuid.Parse("8f20ff82-9498-4812-9f6e-9c01bdc50e99") + 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 []RepositoryWebhook + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListWebhooks function +type ListWebhooksArgs struct { + // (required) Project ID or project name + Project *string + // (required) The name of the source provider. + ProviderName *string + // (optional) If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. + ServiceEndpointId *uuid.UUID + // (optional) If specified, the vendor-specific identifier or the name of the repository to get webhooks. Can only be omitted for providers that do not support multiple repositories. + Repository *string +} + +// Queues a build +func (client *ClientImpl) QueueBuild(ctx context.Context, args QueueBuildArgs) (*Build, error) { + if args.Build == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Build"} + } + 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.IgnoreWarnings != nil { + queryParams.Add("ignoreWarnings", strconv.FormatBool(*args.IgnoreWarnings)) + } + if args.CheckInTicket != nil { + queryParams.Add("checkInTicket", *args.CheckInTicket) + } + if args.SourceBuildId != nil { + queryParams.Add("sourceBuildId", strconv.Itoa(*args.SourceBuildId)) + } + body, marshalErr := json.Marshal(*args.Build) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("0cd358e1-9217-4d94-8269-1c1ee6f93dcf") + 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 Build + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueueBuild function +type QueueBuildArgs struct { + // (required) + Build *Build + // (required) Project ID or project name + Project *string + // (optional) + IgnoreWarnings *bool + // (optional) + CheckInTicket *string + // (optional) + SourceBuildId *int +} + +// Restores a deleted definition +func (client *ClientImpl) RestoreDefinition(ctx context.Context, args RestoreDefinitionArgs) (*BuildDefinition, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + queryParams := url.Values{} + if args.Deleted == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "deleted"} + } + queryParams.Add("deleted", strconv.FormatBool(*args.Deleted)) + locationId, _ := uuid.Parse("dbeaf647-6167-421a-bda9-c9327b25e2e6") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue BuildDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the RestoreDefinition function +type RestoreDefinitionArgs struct { + // (required) Project ID or project name + Project *string + // (required) The identifier of the definition to restore. + DefinitionId *int + // (required) When false, restores a deleted definition. + Deleted *bool +} + +// [Preview API] Recreates the webhooks for the specified triggers in the given source code repository. +func (client *ClientImpl) RestoreWebhooks(ctx context.Context, args RestoreWebhooksArgs) error { + if args.TriggerTypes == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.TriggerTypes"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ProviderName == nil || *args.ProviderName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ProviderName"} + } + routeValues["providerName"] = *args.ProviderName + + queryParams := url.Values{} + if args.ServiceEndpointId != nil { + queryParams.Add("serviceEndpointId", (*args.ServiceEndpointId).String()) + } + if args.Repository != nil { + queryParams.Add("repository", *args.Repository) + } + body, marshalErr := json.Marshal(*args.TriggerTypes) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("793bceb8-9736-4030-bd2f-fb3ce6d6b478") + _, 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 err + } + + return nil +} + +// Arguments for the RestoreWebhooks function +type RestoreWebhooksArgs struct { + // (required) The types of triggers to restore webhooks for. + TriggerTypes *[]DefinitionTriggerType + // (required) Project ID or project name + Project *string + // (required) The name of the source provider. + ProviderName *string + // (optional) If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TFVC or TFGit. + ServiceEndpointId *uuid.UUID + // (optional) If specified, the vendor-specific identifier or the name of the repository to get webhooks. Can only be omitted for providers that do not support multiple repositories. + Repository *string +} + +// Updates an existing build definition template. +func (client *ClientImpl) SaveTemplate(ctx context.Context, args SaveTemplateArgs) (*BuildDefinitionTemplate, error) { + if args.Template == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Template"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.TemplateId == nil || *args.TemplateId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TemplateId"} + } + routeValues["templateId"] = *args.TemplateId + + body, marshalErr := json.Marshal(*args.Template) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e884571e-7f92-4d6a-9274-3f5649900835") + 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 BuildDefinitionTemplate + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the SaveTemplate function +type SaveTemplateArgs struct { + // (required) The new version of the template. + Template *BuildDefinitionTemplate + // (required) Project ID or project name + Project *string + // (required) The ID of the template. + TemplateId *string +} + +// Updates a build. +func (client *ClientImpl) UpdateBuild(ctx context.Context, args UpdateBuildArgs) (*Build, error) { + if args.Build == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Build"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + queryParams := url.Values{} + if args.Retry != nil { + queryParams.Add("retry", strconv.FormatBool(*args.Retry)) + } + body, marshalErr := json.Marshal(*args.Build) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("0cd358e1-9217-4d94-8269-1c1ee6f93dcf") + 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 Build + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateBuild function +type UpdateBuildArgs struct { + // (required) The build. + Build *Build + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int + // (optional) + Retry *bool +} + +// [Preview API] Updates properties for a build. +func (client *ClientImpl) UpdateBuildProperties(ctx context.Context, args UpdateBuildPropertiesArgs) (interface{}, error) { + if args.Document == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Document"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BuildId"} + } + routeValues["buildId"] = strconv.Itoa(*args.BuildId) + + body, marshalErr := json.Marshal(*args.Document) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("0a6312e9-0627-49b7-8083-7d74a64849c9") + 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 UpdateBuildProperties function +type UpdateBuildPropertiesArgs struct { + // (required) A json-patch document describing the properties to update. + Document *[]webapi.JsonPatchOperation + // (required) Project ID or project name + Project *string + // (required) The ID of the build. + BuildId *int +} + +// Updates multiple builds. +func (client *ClientImpl) UpdateBuilds(ctx context.Context, args UpdateBuildsArgs) (*[]Build, error) { + if args.Builds == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Builds"} + } + 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.Builds) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("0cd358e1-9217-4d94-8269-1c1ee6f93dcf") + 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 []Build + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateBuilds function +type UpdateBuildsArgs struct { + // (required) The builds to update. + Builds *[]Build + // (required) Project ID or project name + Project *string +} + +// Updates the build settings. +func (client *ClientImpl) UpdateBuildSettings(ctx context.Context, args UpdateBuildSettingsArgs) (*BuildSettings, error) { + if args.Settings == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Settings"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.Settings) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("aa8c1c9c-ef8b-474a-b8c4-785c7b191d0d") + 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 BuildSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateBuildSettings function +type UpdateBuildSettingsArgs struct { + // (required) The new settings. + Settings *BuildSettings + // (optional) Project ID or project name + Project *string +} + +// Updates an existing definition. +func (client *ClientImpl) UpdateDefinition(ctx context.Context, args UpdateDefinitionArgs) (*BuildDefinition, error) { + if args.Definition == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Definition"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + queryParams := url.Values{} + if args.SecretsSourceDefinitionId != nil { + queryParams.Add("secretsSourceDefinitionId", strconv.Itoa(*args.SecretsSourceDefinitionId)) + } + if args.SecretsSourceDefinitionRevision != nil { + queryParams.Add("secretsSourceDefinitionRevision", strconv.Itoa(*args.SecretsSourceDefinitionRevision)) + } + body, marshalErr := json.Marshal(*args.Definition) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("dbeaf647-6167-421a-bda9-c9327b25e2e6") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue BuildDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateDefinition function +type UpdateDefinitionArgs struct { + // (required) The new version of the definition. + Definition *BuildDefinition + // (required) Project ID or project name + Project *string + // (required) The ID of the definition. + DefinitionId *int + // (optional) + SecretsSourceDefinitionId *int + // (optional) + SecretsSourceDefinitionRevision *int +} + +// [Preview API] Updates properties for a definition. +func (client *ClientImpl) UpdateDefinitionProperties(ctx context.Context, args UpdateDefinitionPropertiesArgs) (interface{}, error) { + if args.Document == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Document"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + body, marshalErr := json.Marshal(*args.Document) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d9826ad7-2a68-46a9-a6e9-677698777895") + 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 UpdateDefinitionProperties function +type UpdateDefinitionPropertiesArgs struct { + // (required) A json-patch document describing the properties to update. + Document *[]webapi.JsonPatchOperation + // (required) Project ID or project name + Project *string + // (required) The ID of the definition. + DefinitionId *int +} + +// [Preview API] Updates an existing folder at given existing path +func (client *ClientImpl) UpdateFolder(ctx context.Context, args UpdateFolderArgs) (*Folder, error) { + if args.Folder == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Folder"} + } + 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.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + body, marshalErr := json.Marshal(*args.Folder) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a906531b-d2da-4f55-bda7-f3e676cc50d9") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Folder + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateFolder function +type UpdateFolderArgs struct { + // (required) The new version of the folder. + Folder *Folder + // (required) Project ID or project name + Project *string + // (required) The full path to the folder. + Path *string +} diff --git a/azuredevops/build/models.go b/azuredevops/build/models.go new file mode 100644 index 00000000..05f6d955 --- /dev/null +++ b/azuredevops/build/models.go @@ -0,0 +1,2339 @@ +// -------------------------------------------------------------------------------------------- +// 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 build + +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/distributedtaskcommon" + "github.com/microsoft/azure-devops-go-api/azuredevops/git" + "github.com/microsoft/azure-devops-go-api/azuredevops/test" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +// Represents a queue for running builds. +type AgentPoolQueue struct { + Links interface{} `json:"_links,omitempty"` + // The ID of the queue. + Id *int `json:"id,omitempty"` + // The name of the queue. + Name *string `json:"name,omitempty"` + // The pool used by this queue. + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + // The full http link to the resource. + Url *string `json:"url,omitempty"` +} + +// Represents a reference to an agent queue. +type AgentPoolQueueReference struct { + // An alias to be used when referencing the resource. + Alias *string `json:"alias,omitempty"` + // The ID of the queue. + Id *int `json:"id,omitempty"` +} + +// Describes how a phase should run against an agent queue. +type AgentPoolQueueTarget struct { + // The type of the target. + Type *int `json:"type,omitempty"` + // Agent specification of the target. + AgentSpecification *AgentSpecification `json:"agentSpecification,omitempty"` + // Enables scripts and other processes launched while executing phase to access the OAuth token + AllowScriptsAuthAccessOption *bool `json:"allowScriptsAuthAccessOption,omitempty"` + Demands *[]interface{} `json:"demands,omitempty"` + // The execution options. + ExecutionOptions *AgentTargetExecutionOptions `json:"executionOptions,omitempty"` + // The queue. + Queue *AgentPoolQueue `json:"queue,omitempty"` +} + +// Specification of the agent defined by the pool provider. +type AgentSpecification struct { + // Agent specification unique identifier. + Identifier *string `json:"identifier,omitempty"` +} + +type AgentStatus string + +type agentStatusValuesType struct { + Unavailable AgentStatus + Available AgentStatus + Offline AgentStatus +} + +var AgentStatusValues = agentStatusValuesType{ + // Indicates that the build agent cannot be contacted. + Unavailable: "unavailable", + // Indicates that the build agent is currently available. + Available: "available", + // Indicates that the build agent has taken itself offline. + Offline: "offline", +} + +// Additional options for running phases against an agent queue. +type AgentTargetExecutionOptions struct { + // Indicates the type of execution options. + Type *int `json:"type,omitempty"` +} + +type ArtifactResource struct { + Links interface{} `json:"_links,omitempty"` + // Type-specific data about the artifact. + Data *string `json:"data,omitempty"` + // A link to download the resource. + DownloadUrl *string `json:"downloadUrl,omitempty"` + // Type-specific properties of the artifact. + Properties *map[string]string `json:"properties,omitempty"` + // The type of the resource: File container, version control folder, UNC path, etc. + Type *string `json:"type,omitempty"` + // The full http link to the resource. + Url *string `json:"url,omitempty"` +} + +// Represents an attachment to a build. +type Attachment struct { + Links interface{} `json:"_links,omitempty"` + // The name of the attachment. + Name *string `json:"name,omitempty"` +} + +type AuditAction string + +type auditActionValuesType struct { + Add AuditAction + Update AuditAction + Delete AuditAction +} + +var AuditActionValues = auditActionValuesType{ + Add: "add", + Update: "update", + Delete: "delete", +} + +// Data representation of a build. +type Build struct { + Links interface{} `json:"_links,omitempty"` + // The agent specification for the build. + AgentSpecification *AgentSpecification `json:"agentSpecification,omitempty"` + // The build number/name of the build. + BuildNumber *string `json:"buildNumber,omitempty"` + // The build number revision. + BuildNumberRevision *int `json:"buildNumberRevision,omitempty"` + // The build controller. This is only set if the definition type is Xaml. + Controller *BuildController `json:"controller,omitempty"` + // The definition associated with the build. + Definition *DefinitionReference `json:"definition,omitempty"` + // Indicates whether the build has been deleted. + Deleted *bool `json:"deleted,omitempty"` + // The identity of the process or person that deleted the build. + DeletedBy *webapi.IdentityRef `json:"deletedBy,omitempty"` + // The date the build was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // The description of how the build was deleted. + DeletedReason *string `json:"deletedReason,omitempty"` + // A list of demands that represents the agent capabilities required by this build. + Demands *[]interface{} `json:"demands,omitempty"` + // The time that the build was completed. + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + // The ID of the build. + Id *int `json:"id,omitempty"` + // Indicates whether the build should be skipped by retention policies. + KeepForever *bool `json:"keepForever,omitempty"` + // The identity representing the process or person that last changed the build. + LastChangedBy *webapi.IdentityRef `json:"lastChangedBy,omitempty"` + // The date the build was last changed. + LastChangedDate *azuredevops.Time `json:"lastChangedDate,omitempty"` + // Information about the build logs. + Logs *BuildLogReference `json:"logs,omitempty"` + // The orchestration plan for the build. + OrchestrationPlan *TaskOrchestrationPlanReference `json:"orchestrationPlan,omitempty"` + // The parameters for the build. + Parameters *string `json:"parameters,omitempty"` + // Orchestration plans associated with the build (build, cleanup) + Plans *[]TaskOrchestrationPlanReference `json:"plans,omitempty"` + // The build's priority. + Priority *QueuePriority `json:"priority,omitempty"` + // The team project. + Project *core.TeamProjectReference `json:"project,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // The quality of the xaml build (good, bad, etc.) + Quality *string `json:"quality,omitempty"` + // The queue. This is only set if the definition type is Build. + Queue *AgentPoolQueue `json:"queue,omitempty"` + // Additional options for queueing the build. + QueueOptions *QueueOptions `json:"queueOptions,omitempty"` + // The current position of the build in the queue. + QueuePosition *int `json:"queuePosition,omitempty"` + // The time that the build was queued. + QueueTime *azuredevops.Time `json:"queueTime,omitempty"` + // The reason that the build was created. + Reason *BuildReason `json:"reason,omitempty"` + // The repository. + Repository *BuildRepository `json:"repository,omitempty"` + // The identity that queued the build. + RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` + // The identity on whose behalf the build was queued. + RequestedFor *webapi.IdentityRef `json:"requestedFor,omitempty"` + // The build result. + Result *BuildResult `json:"result,omitempty"` + // Indicates whether the build is retained by a release. + RetainedByRelease *bool `json:"retainedByRelease,omitempty"` + // The source branch. + SourceBranch *string `json:"sourceBranch,omitempty"` + // The source version. + SourceVersion *string `json:"sourceVersion,omitempty"` + // The time that the build was started. + StartTime *azuredevops.Time `json:"startTime,omitempty"` + // The status of the build. + Status *BuildStatus `json:"status,omitempty"` + Tags *[]string `json:"tags,omitempty"` + // The build that triggered this build via a Build completion trigger. + TriggeredByBuild *Build `json:"triggeredByBuild,omitempty"` + // Sourceprovider-specific information about what triggered the build + TriggerInfo *map[string]string `json:"triggerInfo,omitempty"` + // The URI of the build. + Uri *string `json:"uri,omitempty"` + // The REST URL of the build. + Url *string `json:"url,omitempty"` + ValidationResults *[]BuildRequestValidationResult `json:"validationResults,omitempty"` +} + +type BuildAgent struct { + BuildDirectory *string `json:"buildDirectory,omitempty"` + Controller *XamlBuildControllerReference `json:"controller,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + Description *string `json:"description,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Id *int `json:"id,omitempty"` + MessageQueueUrl *string `json:"messageQueueUrl,omitempty"` + Name *string `json:"name,omitempty"` + ReservedForBuild *string `json:"reservedForBuild,omitempty"` + Server *XamlBuildServerReference `json:"server,omitempty"` + Status *AgentStatus `json:"status,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` + Uri *string `json:"uri,omitempty"` + Url *string `json:"url,omitempty"` +} + +type BuildAgentReference struct { + // Id of the resource + Id *int `json:"id,omitempty"` + // Name of the linked resource (definition name, controller name, etc.) + Name *string `json:"name,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` +} + +// Represents an artifact produced by a build. +type BuildArtifact struct { + // The artifact ID. + Id *int `json:"id,omitempty"` + // The name of the artifact. + Name *string `json:"name,omitempty"` + // The actual resource. + Resource *ArtifactResource `json:"resource,omitempty"` + // The artifact source, which will be the ID of the job that produced this artifact. + Source *string `json:"source,omitempty"` +} + +// Represents the desired scope of authorization for a build. +type BuildAuthorizationScope string + +type buildAuthorizationScopeValuesType struct { + ProjectCollection BuildAuthorizationScope + Project BuildAuthorizationScope +} + +var BuildAuthorizationScopeValues = buildAuthorizationScopeValuesType{ + // The identity used should have build service account permissions scoped to the project collection. This is useful when resources for a single build are spread across multiple projects. + ProjectCollection: "projectCollection", + // The identity used should have build service account permissions scoped to the project in which the build definition resides. This is useful for isolation of build jobs to a particular team project to avoid any unintentional escalation of privilege attacks during a build. + Project: "project", +} + +// Represents a build badge. +type BuildBadge struct { + // The ID of the build represented by this badge. + BuildId *int `json:"buildId,omitempty"` + // A link to the SVG resource. + ImageUrl *string `json:"imageUrl,omitempty"` +} + +type BuildCompletedEvent struct { + BuildId *int `json:"buildId,omitempty"` + Build *Build `json:"build,omitempty"` + // Changes associated with a build used for build notifications + Changes *[]Change `json:"changes,omitempty"` + // Pull request for the build used for build notifications + PullRequest *PullRequest `json:"pullRequest,omitempty"` + // Test results associated with a build used for build notifications + TestResults *test.AggregatedResultsAnalysis `json:"testResults,omitempty"` + // Timeline records associated with a build used for build notifications + TimelineRecords *[]TimelineRecord `json:"timelineRecords,omitempty"` + // Work items associated with a build used for build notifications + WorkItems *[]git.AssociatedWorkItem `json:"workItems,omitempty"` +} + +// Represents a build completion trigger. +type BuildCompletionTrigger struct { + // The type of the trigger. + TriggerType *DefinitionTriggerType `json:"triggerType,omitempty"` + BranchFilters *[]string `json:"branchFilters,omitempty"` + // A reference to the definition that should trigger builds for this definition. + Definition *DefinitionReference `json:"definition,omitempty"` + RequiresSuccessfulBuild *bool `json:"requiresSuccessfulBuild,omitempty"` +} + +type BuildController struct { + // Id of the resource + Id *int `json:"id,omitempty"` + // Name of the linked resource (definition name, controller name, etc.) + Name *string `json:"name,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` + Links interface{} `json:"_links,omitempty"` + // The date the controller was created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // The description of the controller. + Description *string `json:"description,omitempty"` + // Indicates whether the controller is enabled. + Enabled *bool `json:"enabled,omitempty"` + // The status of the controller. + Status *ControllerStatus `json:"status,omitempty"` + // The date the controller was last updated. + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` + // The controller's URI. + Uri *string `json:"uri,omitempty"` +} + +// Represents a build definition. +type BuildDefinition struct { + // The date this version of the definition was created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // The ID of the referenced definition. + Id *int `json:"id,omitempty"` + // The name of the referenced definition. + Name *string `json:"name,omitempty"` + // The folder path of the definition. + Path *string `json:"path,omitempty"` + // A reference to the project. + Project *core.TeamProjectReference `json:"project,omitempty"` + // A value that indicates whether builds can be queued against this definition. + QueueStatus *DefinitionQueueStatus `json:"queueStatus,omitempty"` + // The definition revision number. + Revision *int `json:"revision,omitempty"` + // The type of the definition. + Type *DefinitionType `json:"type,omitempty"` + // The definition's URI. + Uri *string `json:"uri,omitempty"` + // The REST URL of the definition. + Url *string `json:"url,omitempty"` + Links interface{} `json:"_links,omitempty"` + // The author of the definition. + AuthoredBy *webapi.IdentityRef `json:"authoredBy,omitempty"` + // A reference to the definition that this definition is a draft of, if this is a draft definition. + DraftOf *DefinitionReference `json:"draftOf,omitempty"` + // The list of drafts associated with this definition, if this is not a draft definition. + Drafts *[]DefinitionReference `json:"drafts,omitempty"` + LatestBuild *Build `json:"latestBuild,omitempty"` + LatestCompletedBuild *Build `json:"latestCompletedBuild,omitempty"` + Metrics *[]BuildMetric `json:"metrics,omitempty"` + // The quality of the definition document (draft, etc.) + Quality *DefinitionQuality `json:"quality,omitempty"` + // The default queue for builds run against this definition. + Queue *AgentPoolQueue `json:"queue,omitempty"` + // Indicates whether badges are enabled for this definition. + BadgeEnabled *bool `json:"badgeEnabled,omitempty"` + // The build number format. + BuildNumberFormat *string `json:"buildNumberFormat,omitempty"` + // A save-time comment for the definition. + Comment *string `json:"comment,omitempty"` + Demands *[]interface{} `json:"demands,omitempty"` + // The description. + Description *string `json:"description,omitempty"` + // The drop location for the definition. + DropLocation *string `json:"dropLocation,omitempty"` + // The job authorization scope for builds queued against this definition. + JobAuthorizationScope *BuildAuthorizationScope `json:"jobAuthorizationScope,omitempty"` + // The job cancel timeout (in minutes) for builds cancelled by user for this definition. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // The job execution timeout (in minutes) for builds queued against this definition. + JobTimeoutInMinutes *int `json:"jobTimeoutInMinutes,omitempty"` + Options *[]BuildOption `json:"options,omitempty"` + // The build process. + Process interface{} `json:"process,omitempty"` + // The process parameters for this definition. + ProcessParameters *distributedtaskcommon.ProcessParameters `json:"processParameters,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // The repository. + Repository *BuildRepository `json:"repository,omitempty"` + RetentionRules *[]RetentionPolicy `json:"retentionRules,omitempty"` + Tags *[]string `json:"tags,omitempty"` + Triggers *[]interface{} `json:"triggers,omitempty"` + VariableGroups *[]VariableGroup `json:"variableGroups,omitempty"` + Variables *map[string]BuildDefinitionVariable `json:"variables,omitempty"` +} + +// For back-compat with extensions that use the old Steps format instead of Process and Phases +type BuildDefinition3_2 struct { + // The date this version of the definition was created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // The ID of the referenced definition. + Id *int `json:"id,omitempty"` + // The name of the referenced definition. + Name *string `json:"name,omitempty"` + // The folder path of the definition. + Path *string `json:"path,omitempty"` + // A reference to the project. + Project *core.TeamProjectReference `json:"project,omitempty"` + // A value that indicates whether builds can be queued against this definition. + QueueStatus *DefinitionQueueStatus `json:"queueStatus,omitempty"` + // The definition revision number. + Revision *int `json:"revision,omitempty"` + // The type of the definition. + Type *DefinitionType `json:"type,omitempty"` + // The definition's URI. + Uri *string `json:"uri,omitempty"` + // The REST URL of the definition. + Url *string `json:"url,omitempty"` + Links interface{} `json:"_links,omitempty"` + // The author of the definition. + AuthoredBy *webapi.IdentityRef `json:"authoredBy,omitempty"` + // A reference to the definition that this definition is a draft of, if this is a draft definition. + DraftOf *DefinitionReference `json:"draftOf,omitempty"` + // The list of drafts associated with this definition, if this is not a draft definition. + Drafts *[]DefinitionReference `json:"drafts,omitempty"` + Metrics *[]BuildMetric `json:"metrics,omitempty"` + // The quality of the definition document (draft, etc.) + Quality *DefinitionQuality `json:"quality,omitempty"` + // The default queue for builds run against this definition. + Queue *AgentPoolQueue `json:"queue,omitempty"` + // Indicates whether badges are enabled for this definition + BadgeEnabled *bool `json:"badgeEnabled,omitempty"` + Build *[]BuildDefinitionStep `json:"build,omitempty"` + // The build number format + BuildNumberFormat *string `json:"buildNumberFormat,omitempty"` + // The comment entered when saving the definition + Comment *string `json:"comment,omitempty"` + Demands *[]interface{} `json:"demands,omitempty"` + // The description + Description *string `json:"description,omitempty"` + // The drop location for the definition + DropLocation *string `json:"dropLocation,omitempty"` + // The job authorization scope for builds which are queued against this definition + JobAuthorizationScope *BuildAuthorizationScope `json:"jobAuthorizationScope,omitempty"` + // The job cancel timeout in minutes for builds which are cancelled by user for this definition + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // The job execution timeout in minutes for builds which are queued against this definition + JobTimeoutInMinutes *int `json:"jobTimeoutInMinutes,omitempty"` + LatestBuild *Build `json:"latestBuild,omitempty"` + LatestCompletedBuild *Build `json:"latestCompletedBuild,omitempty"` + Options *[]BuildOption `json:"options,omitempty"` + // Process Parameters + ProcessParameters *distributedtaskcommon.ProcessParameters `json:"processParameters,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // The repository + Repository *BuildRepository `json:"repository,omitempty"` + RetentionRules *[]RetentionPolicy `json:"retentionRules,omitempty"` + Tags *[]string `json:"tags,omitempty"` + Triggers *[]interface{} `json:"triggers,omitempty"` + Variables *map[string]BuildDefinitionVariable `json:"variables,omitempty"` +} + +// Represents a reference to a build definition. +type BuildDefinitionReference struct { + // The date this version of the definition was created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // The ID of the referenced definition. + Id *int `json:"id,omitempty"` + // The name of the referenced definition. + Name *string `json:"name,omitempty"` + // The folder path of the definition. + Path *string `json:"path,omitempty"` + // A reference to the project. + Project *core.TeamProjectReference `json:"project,omitempty"` + // A value that indicates whether builds can be queued against this definition. + QueueStatus *DefinitionQueueStatus `json:"queueStatus,omitempty"` + // The definition revision number. + Revision *int `json:"revision,omitempty"` + // The type of the definition. + Type *DefinitionType `json:"type,omitempty"` + // The definition's URI. + Uri *string `json:"uri,omitempty"` + // The REST URL of the definition. + Url *string `json:"url,omitempty"` + Links interface{} `json:"_links,omitempty"` + // The author of the definition. + AuthoredBy *webapi.IdentityRef `json:"authoredBy,omitempty"` + // A reference to the definition that this definition is a draft of, if this is a draft definition. + DraftOf *DefinitionReference `json:"draftOf,omitempty"` + // The list of drafts associated with this definition, if this is not a draft definition. + Drafts *[]DefinitionReference `json:"drafts,omitempty"` + LatestBuild *Build `json:"latestBuild,omitempty"` + LatestCompletedBuild *Build `json:"latestCompletedBuild,omitempty"` + Metrics *[]BuildMetric `json:"metrics,omitempty"` + // The quality of the definition document (draft, etc.) + Quality *DefinitionQuality `json:"quality,omitempty"` + // The default queue for builds run against this definition. + Queue *AgentPoolQueue `json:"queue,omitempty"` +} + +// For back-compat with extensions that use the old Steps format instead of Process and Phases +type BuildDefinitionReference3_2 struct { + // The date this version of the definition was created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // The ID of the referenced definition. + Id *int `json:"id,omitempty"` + // The name of the referenced definition. + Name *string `json:"name,omitempty"` + // The folder path of the definition. + Path *string `json:"path,omitempty"` + // A reference to the project. + Project *core.TeamProjectReference `json:"project,omitempty"` + // A value that indicates whether builds can be queued against this definition. + QueueStatus *DefinitionQueueStatus `json:"queueStatus,omitempty"` + // The definition revision number. + Revision *int `json:"revision,omitempty"` + // The type of the definition. + Type *DefinitionType `json:"type,omitempty"` + // The definition's URI. + Uri *string `json:"uri,omitempty"` + // The REST URL of the definition. + Url *string `json:"url,omitempty"` + Links interface{} `json:"_links,omitempty"` + // The author of the definition. + AuthoredBy *webapi.IdentityRef `json:"authoredBy,omitempty"` + // A reference to the definition that this definition is a draft of, if this is a draft definition. + DraftOf *DefinitionReference `json:"draftOf,omitempty"` + // The list of drafts associated with this definition, if this is not a draft definition. + Drafts *[]DefinitionReference `json:"drafts,omitempty"` + Metrics *[]BuildMetric `json:"metrics,omitempty"` + // The quality of the definition document (draft, etc.) + Quality *DefinitionQuality `json:"quality,omitempty"` + // The default queue for builds run against this definition. + Queue *AgentPoolQueue `json:"queue,omitempty"` +} + +// Represents a revision of a build definition. +type BuildDefinitionRevision struct { + // The identity of the person or process that changed the definition. + ChangedBy *webapi.IdentityRef `json:"changedBy,omitempty"` + // The date and time that the definition was changed. + ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` + // The change type (add, edit, delete). + ChangeType *AuditAction `json:"changeType,omitempty"` + // The comment associated with the change. + Comment *string `json:"comment,omitempty"` + // A link to the definition at this revision. + DefinitionUrl *string `json:"definitionUrl,omitempty"` + // The name of the definition. + Name *string `json:"name,omitempty"` + // The revision number. + Revision *int `json:"revision,omitempty"` +} + +type BuildDefinitionSourceProvider struct { + // Uri of the associated definition + DefinitionUri *string `json:"definitionUri,omitempty"` + // fields associated with this build definition + Fields *map[string]string `json:"fields,omitempty"` + // Id of this source provider + Id *int `json:"id,omitempty"` + // The lst time this source provider was modified + LastModified *azuredevops.Time `json:"lastModified,omitempty"` + // Name of the source provider + Name *string `json:"name,omitempty"` + // Which trigger types are supported by this definition source provider + SupportedTriggerTypes *DefinitionTriggerType `json:"supportedTriggerTypes,omitempty"` +} + +// Represents a step in a build phase. +type BuildDefinitionStep struct { + // Indicates whether this step should run even if a previous step fails. + AlwaysRun *bool `json:"alwaysRun,omitempty"` + // A condition that determines whether this step should run. + Condition *string `json:"condition,omitempty"` + // Indicates whether the phase should continue even if this step fails. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // The display name for this step. + DisplayName *string `json:"displayName,omitempty"` + // Indicates whether the step is enabled. + Enabled *bool `json:"enabled,omitempty"` + Environment *map[string]string `json:"environment,omitempty"` + Inputs *map[string]string `json:"inputs,omitempty"` + // The reference name for this step. + RefName *string `json:"refName,omitempty"` + // The task associated with this step. + Task *TaskDefinitionReference `json:"task,omitempty"` + // The time, in minutes, that this step is allowed to run. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` +} + +// Represents a template from which new build definitions can be created. +type BuildDefinitionTemplate struct { + // Indicates whether the template can be deleted. + CanDelete *bool `json:"canDelete,omitempty"` + // The template category. + Category *string `json:"category,omitempty"` + // An optional hosted agent queue for the template to use by default. + DefaultHostedQueue *string `json:"defaultHostedQueue,omitempty"` + // A description of the template. + Description *string `json:"description,omitempty"` + Icons *map[string]string `json:"icons,omitempty"` + // The ID of the task whose icon is used when showing this template in the UI. + IconTaskId *uuid.UUID `json:"iconTaskId,omitempty"` + // The ID of the template. + Id *string `json:"id,omitempty"` + // The name of the template. + Name *string `json:"name,omitempty"` + // The actual template. + Template *BuildDefinition `json:"template,omitempty"` +} + +// For back-compat with extensions that use the old Steps format instead of Process and Phases +type BuildDefinitionTemplate3_2 struct { + CanDelete *bool `json:"canDelete,omitempty"` + Category *string `json:"category,omitempty"` + DefaultHostedQueue *string `json:"defaultHostedQueue,omitempty"` + Description *string `json:"description,omitempty"` + Icons *map[string]string `json:"icons,omitempty"` + IconTaskId *uuid.UUID `json:"iconTaskId,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Template *BuildDefinition3_2 `json:"template,omitempty"` +} + +// Represents a variable used by a build definition. +type BuildDefinitionVariable struct { + // Indicates whether the value can be set at queue time. + AllowOverride *bool `json:"allowOverride,omitempty"` + // Indicates whether the variable's value is a secret. + IsSecret *bool `json:"isSecret,omitempty"` + // The value of the variable. + Value *string `json:"value,omitempty"` +} + +type BuildDeletedEvent struct { + BuildId *int `json:"buildId,omitempty"` + Build *Build `json:"build,omitempty"` +} + +type BuildDeployment struct { + Deployment *BuildSummary `json:"deployment,omitempty"` + SourceBuild *XamlBuildReference `json:"sourceBuild,omitempty"` +} + +type BuildEvent struct { + Data *[]string `json:"data,omitempty"` + Identifier *string `json:"identifier,omitempty"` +} + +// Represents a build log. +type BuildLog struct { + // The ID of the log. + Id *int `json:"id,omitempty"` + // The type of the log location. + Type *string `json:"type,omitempty"` + // A full link to the log resource. + Url *string `json:"url,omitempty"` + // The date and time the log was created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // The date and time the log was last changed. + LastChangedOn *azuredevops.Time `json:"lastChangedOn,omitempty"` + // The number of lines in the log. + LineCount *uint64 `json:"lineCount,omitempty"` +} + +// Represents a reference to a build log. +type BuildLogReference struct { + // The ID of the log. + Id *int `json:"id,omitempty"` + // The type of the log location. + Type *string `json:"type,omitempty"` + // A full link to the log resource. + Url *string `json:"url,omitempty"` +} + +// Represents metadata about builds in the system. +type BuildMetric struct { + // The date for the scope. + Date *azuredevops.Time `json:"date,omitempty"` + // The value. + IntValue *int `json:"intValue,omitempty"` + // The name of the metric. + Name *string `json:"name,omitempty"` + // The scope. + Scope *string `json:"scope,omitempty"` +} + +// Represents the application of an optional behavior to a build definition. +type BuildOption struct { + // A reference to the build option. + Definition *BuildOptionDefinitionReference `json:"definition,omitempty"` + // Indicates whether the behavior is enabled. + Enabled *bool `json:"enabled,omitempty"` + Inputs *map[string]string `json:"inputs,omitempty"` +} + +// Represents an optional behavior that can be applied to a build definition. +type BuildOptionDefinition struct { + // The ID of the referenced build option. + Id *uuid.UUID `json:"id,omitempty"` + // The description. + Description *string `json:"description,omitempty"` + // The list of input groups defined for the build option. + Groups *[]BuildOptionGroupDefinition `json:"groups,omitempty"` + // The list of inputs defined for the build option. + Inputs *[]BuildOptionInputDefinition `json:"inputs,omitempty"` + // The name of the build option. + Name *string `json:"name,omitempty"` + // A value that indicates the relative order in which the behavior should be applied. + Ordinal *int `json:"ordinal,omitempty"` +} + +// Represents a reference to a build option definition. +type BuildOptionDefinitionReference struct { + // The ID of the referenced build option. + Id *uuid.UUID `json:"id,omitempty"` +} + +// Represents a group of inputs for a build option. +type BuildOptionGroupDefinition struct { + // The name of the group to display in the UI. + DisplayName *string `json:"displayName,omitempty"` + // Indicates whether the group is initially displayed as expanded in the UI. + IsExpanded *bool `json:"isExpanded,omitempty"` + // The internal name of the group. + Name *string `json:"name,omitempty"` +} + +// Represents an input for a build option. +type BuildOptionInputDefinition struct { + // The default value. + DefaultValue *string `json:"defaultValue,omitempty"` + // The name of the input group that this input belongs to. + GroupName *string `json:"groupName,omitempty"` + Help *map[string]string `json:"help,omitempty"` + // The label for the input. + Label *string `json:"label,omitempty"` + // The name of the input. + Name *string `json:"name,omitempty"` + Options *map[string]string `json:"options,omitempty"` + // Indicates whether the input is required to have a value. + Required *bool `json:"required,omitempty"` + // Indicates the type of the input value. + Type *BuildOptionInputType `json:"type,omitempty"` + // The rule that is applied to determine whether the input is visible in the UI. + VisibleRule *string `json:"visibleRule,omitempty"` +} + +type BuildOptionInputType string + +type buildOptionInputTypeValuesType struct { + String BuildOptionInputType + Boolean BuildOptionInputType + StringList BuildOptionInputType + Radio BuildOptionInputType + PickList BuildOptionInputType + MultiLine BuildOptionInputType + BranchFilter BuildOptionInputType +} + +var BuildOptionInputTypeValues = buildOptionInputTypeValuesType{ + String: "string", + Boolean: "boolean", + StringList: "stringList", + Radio: "radio", + PickList: "pickList", + MultiLine: "multiLine", + BranchFilter: "branchFilter", +} + +type BuildPhaseStatus string + +type buildPhaseStatusValuesType struct { + Unknown BuildPhaseStatus + Failed BuildPhaseStatus + Succeeded BuildPhaseStatus +} + +var BuildPhaseStatusValues = buildPhaseStatusValuesType{ + // The state is not known. + Unknown: "unknown", + // The build phase completed unsuccessfully. + Failed: "failed", + // The build phase completed successfully. + Succeeded: "succeeded", +} + +// Represents a build process. +type BuildProcess struct { + // The type of the process. + Type *int `json:"type,omitempty"` +} + +// Represents resources used by a build process. +type BuildProcessResources struct { + Endpoints *[]ServiceEndpointReference `json:"endpoints,omitempty"` + Files *[]SecureFileReference `json:"files,omitempty"` + Queues *[]AgentPoolQueueReference `json:"queues,omitempty"` + VariableGroups *[]VariableGroupReference `json:"variableGroups,omitempty"` +} + +type BuildProcessTemplate struct { + Description *string `json:"description,omitempty"` + FileExists *bool `json:"fileExists,omitempty"` + Id *int `json:"id,omitempty"` + Parameters *string `json:"parameters,omitempty"` + ServerPath *string `json:"serverPath,omitempty"` + SupportedReasons *BuildReason `json:"supportedReasons,omitempty"` + TeamProject *string `json:"teamProject,omitempty"` + TemplateType *ProcessTemplateType `json:"templateType,omitempty"` + Url *string `json:"url,omitempty"` + Version *string `json:"version,omitempty"` +} + +// Specifies the desired ordering of builds. +type BuildQueryOrder string + +type buildQueryOrderValuesType struct { + FinishTimeAscending BuildQueryOrder + FinishTimeDescending BuildQueryOrder + QueueTimeDescending BuildQueryOrder + QueueTimeAscending BuildQueryOrder + StartTimeDescending BuildQueryOrder + StartTimeAscending BuildQueryOrder +} + +var BuildQueryOrderValues = buildQueryOrderValuesType{ + // Order by finish time ascending. + FinishTimeAscending: "finishTimeAscending", + // Order by finish time descending. + FinishTimeDescending: "finishTimeDescending", + // Order by queue time descending. + QueueTimeDescending: "queueTimeDescending", + // Order by queue time ascending. + QueueTimeAscending: "queueTimeAscending", + // Order by start time descending. + StartTimeDescending: "startTimeDescending", + // Order by start time ascending. + StartTimeAscending: "startTimeAscending", +} + +type BuildQueuedEvent struct { + BuildId *int `json:"buildId,omitempty"` + Build *Build `json:"build,omitempty"` +} + +type BuildReason string + +type buildReasonValuesType struct { + None BuildReason + Manual BuildReason + IndividualCI BuildReason + BatchedCI BuildReason + Schedule BuildReason + ScheduleForced BuildReason + UserCreated BuildReason + ValidateShelveset BuildReason + CheckInShelveset BuildReason + PullRequest BuildReason + BuildCompletion BuildReason + Triggered BuildReason + All BuildReason +} + +var BuildReasonValues = buildReasonValuesType{ + // No reason. This value should not be used. + None: "none", + // The build was started manually. + Manual: "manual", + // The build was started for the trigger TriggerType.ContinuousIntegration. + IndividualCI: "individualCI", + // The build was started for the trigger TriggerType.BatchedContinuousIntegration. + BatchedCI: "batchedCI", + // The build was started for the trigger TriggerType.Schedule. + Schedule: "schedule", + // The build was started for the trigger TriggerType.ScheduleForced. + ScheduleForced: "scheduleForced", + // The build was created by a user. + UserCreated: "userCreated", + // The build was started manually for private validation. + ValidateShelveset: "validateShelveset", + // The build was started for the trigger ContinuousIntegrationType.Gated. + CheckInShelveset: "checkInShelveset", + // The build was started by a pull request. Added in resource version 3. + PullRequest: "pullRequest", + // The build was started when another build completed. + BuildCompletion: "buildCompletion", + // The build was triggered for retention policy purposes. + Triggered: "triggered", + // All reasons. + All: "all", +} + +// Represents a reference to a build. +type BuildReference struct { + Links interface{} `json:"_links,omitempty"` + // The build number. + BuildNumber *string `json:"buildNumber,omitempty"` + // Indicates whether the build has been deleted. + Deleted *bool `json:"deleted,omitempty"` + // The time that the build was completed. + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + // The ID of the build. + Id *int `json:"id,omitempty"` + // The time that the build was queued. + QueueTime *azuredevops.Time `json:"queueTime,omitempty"` + // The identity on whose behalf the build was queued. + RequestedFor *webapi.IdentityRef `json:"requestedFor,omitempty"` + // The build result. + Result *BuildResult `json:"result,omitempty"` + // The time that the build was started. + StartTime *azuredevops.Time `json:"startTime,omitempty"` + // The build status. + Status *BuildStatus `json:"status,omitempty"` +} + +// Represents information about a build report. +type BuildReportMetadata struct { + // The Id of the build. + BuildId *int `json:"buildId,omitempty"` + // The content of the report. + Content *string `json:"content,omitempty"` + // The type of the report. + Type *string `json:"type,omitempty"` +} + +// Represents a repository used by a build definition. +type BuildRepository struct { + // Indicates whether to checkout submodules. + CheckoutSubmodules *bool `json:"checkoutSubmodules,omitempty"` + // Indicates whether to clean the target folder when getting code from the repository. + Clean *string `json:"clean,omitempty"` + // The name of the default branch. + DefaultBranch *string `json:"defaultBranch,omitempty"` + // The ID of the repository. + Id *string `json:"id,omitempty"` + // The friendly name of the repository. + Name *string `json:"name,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + // The root folder. + RootFolder *string `json:"rootFolder,omitempty"` + // The type of the repository. + Type *string `json:"type,omitempty"` + // The URL of the repository. + Url *string `json:"url,omitempty"` +} + +// Represents the result of validating a build request. +type BuildRequestValidationResult struct { + // The message associated with the result. + Message *string `json:"message,omitempty"` + // The result. + Result *ValidationResult `json:"result,omitempty"` +} + +// Represents information about resources used by builds in the system. +type BuildResourceUsage struct { + // The number of build agents. + DistributedTaskAgents *int `json:"distributedTaskAgents,omitempty"` + // The number of paid private agent slots. + PaidPrivateAgentSlots *int `json:"paidPrivateAgentSlots,omitempty"` + // The total usage. + TotalUsage *int `json:"totalUsage,omitempty"` + // The number of XAML controllers. + XamlControllers *int `json:"xamlControllers,omitempty"` +} + +// This is not a Flags enum because we don't want to set multiple statuses on a build. However, when adding values, please stick to powers of 2 as if it were a Flags enum This will ensure that things that key off multiple result types (like labelling sources) continue to work +type BuildResult string + +type buildResultValuesType struct { + None BuildResult + Succeeded BuildResult + PartiallySucceeded BuildResult + Failed BuildResult + Canceled BuildResult +} + +var BuildResultValues = buildResultValuesType{ + // No result + None: "none", + // The build completed successfully. + Succeeded: "succeeded", + // The build completed compilation successfully but had other errors. + PartiallySucceeded: "partiallySucceeded", + // The build completed unsuccessfully. + Failed: "failed", + // The build was canceled before starting. + Canceled: "canceled", +} + +type BuildsDeletedEvent struct { + BuildIds *[]int `json:"buildIds,omitempty"` + // The ID of the definition. + DefinitionId *int `json:"definitionId,omitempty"` + // The ID of the project. + ProjectId *uuid.UUID `json:"projectId,omitempty"` +} + +type BuildsDeletedEvent1 struct { + BuildIds *[]int `json:"buildIds,omitempty"` + // The ID of the definition. + DefinitionId *int `json:"definitionId,omitempty"` + // The ID of the project. + ProjectId *uuid.UUID `json:"projectId,omitempty"` +} + +type BuildServer struct { + Agents *[]BuildAgentReference `json:"agents,omitempty"` + Controller *XamlBuildControllerReference `json:"controller,omitempty"` + Id *int `json:"id,omitempty"` + IsVirtual *bool `json:"isVirtual,omitempty"` + MessageQueueUrl *string `json:"messageQueueUrl,omitempty"` + Name *string `json:"name,omitempty"` + RequireClientCertificates *bool `json:"requireClientCertificates,omitempty"` + Status *ServiceHostStatus `json:"status,omitempty"` + StatusChangedDate *azuredevops.Time `json:"statusChangedDate,omitempty"` + Uri *string `json:"uri,omitempty"` + Url *string `json:"url,omitempty"` + Version *int `json:"version,omitempty"` +} + +// Represents system-wide build settings. +type BuildSettings struct { + // The number of days to keep records of deleted builds. + DaysToKeepDeletedBuildsBeforeDestroy *int `json:"daysToKeepDeletedBuildsBeforeDestroy,omitempty"` + // The default retention policy. + DefaultRetentionPolicy *RetentionPolicy `json:"defaultRetentionPolicy,omitempty"` + // The maximum retention policy. + MaximumRetentionPolicy *RetentionPolicy `json:"maximumRetentionPolicy,omitempty"` +} + +type BuildStatus string + +type buildStatusValuesType struct { + None BuildStatus + InProgress BuildStatus + Completed BuildStatus + Cancelling BuildStatus + Postponed BuildStatus + NotStarted BuildStatus + All BuildStatus +} + +var BuildStatusValues = buildStatusValuesType{ + // No status. + None: "none", + // The build is currently in progress. + InProgress: "inProgress", + // The build has completed. + Completed: "completed", + // The build is cancelling + Cancelling: "cancelling", + // The build is inactive in the queue. + Postponed: "postponed", + // The build has not yet started. + NotStarted: "notStarted", + // All status. + All: "all", +} + +type BuildSummary struct { + Build *XamlBuildReference `json:"build,omitempty"` + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + KeepForever *bool `json:"keepForever,omitempty"` + Quality *string `json:"quality,omitempty"` + Reason *BuildReason `json:"reason,omitempty"` + RequestedFor *webapi.IdentityRef `json:"requestedFor,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + Status *BuildStatus `json:"status,omitempty"` +} + +type BuildTagsAddedEvent struct { + BuildId *int `json:"buildId,omitempty"` + Build *Build `json:"build,omitempty"` + AllTags *[]string `json:"allTags,omitempty"` + NewTags *[]string `json:"newTags,omitempty"` +} + +// Represents a trigger for a buld definition. +type BuildTrigger struct { + // The type of the trigger. + TriggerType *DefinitionTriggerType `json:"triggerType,omitempty"` +} + +type BuildUpdatedEvent struct { + BuildId *int `json:"buildId,omitempty"` + Build *Build `json:"build,omitempty"` +} + +// Represents a workspace mapping. +type BuildWorkspace struct { + Mappings *[]MappingDetails `json:"mappings,omitempty"` +} + +// Represents a change associated with a build. +type Change struct { + // The author of the change. + Author *webapi.IdentityRef `json:"author,omitempty"` + // The location of a user-friendly representation of the resource. + DisplayUri *string `json:"displayUri,omitempty"` + // The identifier for the change. For a commit, this would be the SHA1. For a TFVC changeset, this would be the changeset ID. + Id *string `json:"id,omitempty"` + // The location of the full representation of the resource. + Location *string `json:"location,omitempty"` + // The description of the change. This might be a commit message or changeset description. + Message *string `json:"message,omitempty"` + // Indicates whether the message was truncated. + MessageTruncated *bool `json:"messageTruncated,omitempty"` + // The person or process that pushed the change. + Pusher *string `json:"pusher,omitempty"` + // The timestamp for the change. + Timestamp *azuredevops.Time `json:"timestamp,omitempty"` + // The type of change. "commit", "changeset", etc. + Type *string `json:"type,omitempty"` +} + +type ConsoleLogEvent struct { + BuildId *int `json:"buildId,omitempty"` + Lines *[]string `json:"lines,omitempty"` + StepRecordId *uuid.UUID `json:"stepRecordId,omitempty"` + TimelineId *uuid.UUID `json:"timelineId,omitempty"` + TimelineRecordId *uuid.UUID `json:"timelineRecordId,omitempty"` +} + +type ContinuousDeploymentDefinition struct { + // The connected service associated with the continuous deployment + ConnectedService *core.WebApiConnectedServiceRef `json:"connectedService,omitempty"` + // The definition associated with the continuous deployment + Definition *XamlDefinitionReference `json:"definition,omitempty"` + GitBranch *string `json:"gitBranch,omitempty"` + HostedServiceName *string `json:"hostedServiceName,omitempty"` + Project *core.TeamProjectReference `json:"project,omitempty"` + RepositoryId *string `json:"repositoryId,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + Website *string `json:"website,omitempty"` + Webspace *string `json:"webspace,omitempty"` +} + +// Represents a continuous integration (CI) trigger. +type ContinuousIntegrationTrigger struct { + // The type of the trigger. + TriggerType *DefinitionTriggerType `json:"triggerType,omitempty"` + // Indicates whether changes should be batched while another CI build is running. + BatchChanges *bool `json:"batchChanges,omitempty"` + BranchFilters *[]string `json:"branchFilters,omitempty"` + // The maximum number of simultaneous CI builds that will run per branch. + MaxConcurrentBuildsPerBranch *int `json:"maxConcurrentBuildsPerBranch,omitempty"` + PathFilters *[]string `json:"pathFilters,omitempty"` + // The polling interval, in seconds. + PollingInterval *int `json:"pollingInterval,omitempty"` + // The ID of the job used to poll an external repository. + PollingJobId *uuid.UUID `json:"pollingJobId,omitempty"` + SettingsSourceType *int `json:"settingsSourceType,omitempty"` +} + +type ControllerStatus string + +type controllerStatusValuesType struct { + Unavailable ControllerStatus + Available ControllerStatus + Offline ControllerStatus +} + +var ControllerStatusValues = controllerStatusValuesType{ + // Indicates that the build controller cannot be contacted. + Unavailable: "unavailable", + // Indicates that the build controller is currently available. + Available: "available", + // Indicates that the build controller has taken itself offline. + Offline: "offline", +} + +type DefinitionQuality string + +type definitionQualityValuesType struct { + Definition DefinitionQuality + Draft DefinitionQuality +} + +var DefinitionQualityValues = definitionQualityValuesType{ + Definition: "definition", + Draft: "draft", +} + +// Specifies the desired ordering of definitions. +type DefinitionQueryOrder string + +type definitionQueryOrderValuesType struct { + None DefinitionQueryOrder + LastModifiedAscending DefinitionQueryOrder + LastModifiedDescending DefinitionQueryOrder + DefinitionNameAscending DefinitionQueryOrder + DefinitionNameDescending DefinitionQueryOrder +} + +var DefinitionQueryOrderValues = definitionQueryOrderValuesType{ + // No order + None: "none", + // Order by created on/last modified time ascending. + LastModifiedAscending: "lastModifiedAscending", + // Order by created on/last modified time descending. + LastModifiedDescending: "lastModifiedDescending", + // Order by definition name ascending. + DefinitionNameAscending: "definitionNameAscending", + // Order by definition name descending. + DefinitionNameDescending: "definitionNameDescending", +} + +type DefinitionQueueStatus string + +type definitionQueueStatusValuesType struct { + Enabled DefinitionQueueStatus + Paused DefinitionQueueStatus + Disabled DefinitionQueueStatus +} + +var DefinitionQueueStatusValues = definitionQueueStatusValuesType{ + // When enabled the definition queue allows builds to be queued by users, the system will queue scheduled, gated and continuous integration builds, and the queued builds will be started by the system. + Enabled: "enabled", + // When paused the definition queue allows builds to be queued by users and the system will queue scheduled, gated and continuous integration builds. Builds in the queue will not be started by the system. + Paused: "paused", + // When disabled the definition queue will not allow builds to be queued by users and the system will not queue scheduled, gated or continuous integration builds. Builds already in the queue will not be started by the system. + Disabled: "disabled", +} + +// Represents a reference to a definition. +type DefinitionReference struct { + // The date this version of the definition was created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // The ID of the referenced definition. + Id *int `json:"id,omitempty"` + // The name of the referenced definition. + Name *string `json:"name,omitempty"` + // The folder path of the definition. + Path *string `json:"path,omitempty"` + // A reference to the project. + Project *core.TeamProjectReference `json:"project,omitempty"` + // A value that indicates whether builds can be queued against this definition. + QueueStatus *DefinitionQueueStatus `json:"queueStatus,omitempty"` + // The definition revision number. + Revision *int `json:"revision,omitempty"` + // The type of the definition. + Type *DefinitionType `json:"type,omitempty"` + // The definition's URI. + Uri *string `json:"uri,omitempty"` + // The REST URL of the definition. + Url *string `json:"url,omitempty"` +} + +type DefinitionResourceReference struct { + // Indicates whether the resource is authorized for use. + Authorized *bool `json:"authorized,omitempty"` + // The id of the resource. + Id *string `json:"id,omitempty"` + // A friendly name for the resource. + Name *string `json:"name,omitempty"` + // The type of the resource. + Type *string `json:"type,omitempty"` +} + +type DefinitionTriggerType string + +type definitionTriggerTypeValuesType struct { + None DefinitionTriggerType + ContinuousIntegration DefinitionTriggerType + BatchedContinuousIntegration DefinitionTriggerType + Schedule DefinitionTriggerType + GatedCheckIn DefinitionTriggerType + BatchedGatedCheckIn DefinitionTriggerType + PullRequest DefinitionTriggerType + BuildCompletion DefinitionTriggerType + All DefinitionTriggerType +} + +var DefinitionTriggerTypeValues = definitionTriggerTypeValuesType{ + // Manual builds only. + None: "none", + // A build should be started for each changeset. + ContinuousIntegration: "continuousIntegration", + // A build should be started for multiple changesets at a time at a specified interval. + BatchedContinuousIntegration: "batchedContinuousIntegration", + // A build should be started on a specified schedule whether or not changesets exist. + Schedule: "schedule", + // A validation build should be started for each check-in. + GatedCheckIn: "gatedCheckIn", + // A validation build should be started for each batch of check-ins. + BatchedGatedCheckIn: "batchedGatedCheckIn", + // A build should be triggered when a GitHub pull request is created or updated. Added in resource version 3 + PullRequest: "pullRequest", + // A build should be triggered when another build completes. + BuildCompletion: "buildCompletion", + // All types. + All: "all", +} + +type DefinitionType string + +type definitionTypeValuesType struct { + Xaml DefinitionType + Build DefinitionType +} + +var DefinitionTypeValues = definitionTypeValuesType{ + Xaml: "xaml", + Build: "build", +} + +type DeleteOptions string + +type deleteOptionsValuesType struct { + None DeleteOptions + DropLocation DeleteOptions + TestResults DeleteOptions + Label DeleteOptions + Details DeleteOptions + Symbols DeleteOptions + All DeleteOptions +} + +var DeleteOptionsValues = deleteOptionsValuesType{ + // No data should be deleted. This value should not be used. + None: "none", + // The drop location should be deleted. + DropLocation: "dropLocation", + // The test results should be deleted. + TestResults: "testResults", + // The version control label should be deleted. + Label: "label", + // The build should be deleted. + Details: "details", + // Published symbols should be deleted. + Symbols: "symbols", + // All data should be deleted. + All: "all", +} + +// Represents a demand used by a definition or build. +type Demand struct { + // The name of the capability referenced by the demand. + Name *string `json:"name,omitempty"` + // The demanded value. + Value *string `json:"value,omitempty"` +} + +// Represents a dependency. +type Dependency struct { + // The event. The dependency is satisfied when the referenced object emits this event. + Event *string `json:"event,omitempty"` + // The scope. This names the object referenced by the dependency. + Scope *string `json:"scope,omitempty"` +} + +// Represents the data from the build information nodes for type "DeploymentInformation" for xaml builds +type Deployment struct { + Type *string `json:"type,omitempty"` +} + +// Deployment information for type "Build" +type DeploymentBuild struct { + Type *string `json:"type,omitempty"` + BuildId *int `json:"buildId,omitempty"` +} + +// Deployment information for type "Deploy" +type DeploymentDeploy struct { + Type *string `json:"type,omitempty"` + Message *string `json:"message,omitempty"` +} + +// Deployment information for type "Test" +type DeploymentTest struct { + Type *string `json:"type,omitempty"` + RunId *int `json:"runId,omitempty"` +} + +// Represents a build process supported by the build definition designer. +type DesignerProcess struct { + // The type of the process. + Type *int `json:"type,omitempty"` + Phases *[]Phase `json:"phases,omitempty"` + // The target for the build process. + Target *DesignerProcessTarget `json:"target,omitempty"` +} + +// Represents the target for the build process. +type DesignerProcessTarget struct { + // Agent specification for the build process. + AgentSpecification *AgentSpecification `json:"agentSpecification,omitempty"` +} + +type DockerProcess struct { + // The type of the process. + Type *int `json:"type,omitempty"` + Target *DockerProcessTarget `json:"target,omitempty"` +} + +// Represents the target for the docker build process. +type DockerProcessTarget struct { + // Agent specification for the build process. + AgentSpecification *AgentSpecification `json:"agentSpecification,omitempty"` +} + +// Represents a folder that contains build definitions. +type Folder struct { + // The process or person who created the folder. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // The date the folder was created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // The description. + Description *string `json:"description,omitempty"` + // The process or person that last changed the folder. + LastChangedBy *webapi.IdentityRef `json:"lastChangedBy,omitempty"` + // The date the folder was last changed. + LastChangedDate *azuredevops.Time `json:"lastChangedDate,omitempty"` + // The full path. + Path *string `json:"path,omitempty"` + // The project. + Project *core.TeamProjectReference `json:"project,omitempty"` +} + +// Specifies the desired ordering of folders. +type FolderQueryOrder string + +type folderQueryOrderValuesType struct { + None FolderQueryOrder + FolderAscending FolderQueryOrder + FolderDescending FolderQueryOrder +} + +var FolderQueryOrderValues = folderQueryOrderValuesType{ + // No order + None: "none", + // Order by folder name and path ascending. + FolderAscending: "folderAscending", + // Order by folder name and path descending. + FolderDescending: "folderDescending", +} + +// Represents the ability to build forks of the selected repository. +type Forks struct { + // Indicates whether a build should use secrets when building forks of the selected repository. + AllowSecrets *bool `json:"allowSecrets,omitempty"` + // Indicates whether the trigger should queue builds for forks of the selected repository. + Enabled *bool `json:"enabled,omitempty"` +} + +// Represents a gated check-in trigger. +type GatedCheckInTrigger struct { + // The type of the trigger. + TriggerType *DefinitionTriggerType `json:"triggerType,omitempty"` + PathFilters *[]string `json:"pathFilters,omitempty"` + // Indicates whether CI triggers should run after the gated check-in succeeds. + RunContinuousIntegration *bool `json:"runContinuousIntegration,omitempty"` + // Indicates whether to take workspace mappings into account when determining whether a build should run. + UseWorkspaceMappings *bool `json:"useWorkspaceMappings,omitempty"` +} + +type GetOption string + +type getOptionValuesType struct { + LatestOnQueue GetOption + LatestOnBuild GetOption + Custom GetOption +} + +var GetOptionValues = getOptionValuesType{ + // Use the latest changeset at the time the build is queued. + LatestOnQueue: "latestOnQueue", + // Use the latest changeset at the time the build is started. + LatestOnBuild: "latestOnBuild", + // A user-specified version has been supplied. + Custom: "custom", +} + +// Data representation of an information node associated with a build +type InformationNode struct { + // Fields of the information node + Fields *map[string]string `json:"fields,omitempty"` + // Process or person that last modified this node + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // Date this node was last modified + LastModifiedDate *azuredevops.Time `json:"lastModifiedDate,omitempty"` + // Node Id of this information node + NodeId *int `json:"nodeId,omitempty"` + // Id of parent node (xml tree) + ParentId *int `json:"parentId,omitempty"` + // The type of the information node + Type *string `json:"type,omitempty"` +} + +// Represents an issue (error, warning) associated with a build. +type Issue struct { + // The category. + Category *string `json:"category,omitempty"` + Data *map[string]string `json:"data,omitempty"` + // A description of the issue. + Message *string `json:"message,omitempty"` + // The type (error, warning) of the issue. + Type *IssueType `json:"type,omitempty"` +} + +type IssueType string + +type issueTypeValuesType struct { + Error IssueType + Warning IssueType +} + +var IssueTypeValues = issueTypeValuesType{ + Error: "error", + Warning: "warning", +} + +type JustInTimeProcess struct { + // The type of the process. + Type *int `json:"type,omitempty"` +} + +// Represents an entry in a workspace mapping. +type MappingDetails struct { + // The local path. + LocalPath *string `json:"localPath,omitempty"` + // The mapping type. + MappingType *string `json:"mappingType,omitempty"` + // The server path. + ServerPath *string `json:"serverPath,omitempty"` +} + +// Represents options for running a phase against multiple agents. +type MultipleAgentExecutionOptions struct { + // Indicates the type of execution options. + Type *int `json:"type,omitempty"` + // Indicates whether failure on one agent should prevent the phase from running on other agents. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // The maximum number of agents to use simultaneously. + MaxConcurrency *int `json:"maxConcurrency,omitempty"` +} + +// Represents a phase of a build definition. +type Phase struct { + // The condition that must be true for this phase to execute. + Condition *string `json:"condition,omitempty"` + Dependencies *[]Dependency `json:"dependencies,omitempty"` + // The job authorization scope for builds queued against this definition. + JobAuthorizationScope *BuildAuthorizationScope `json:"jobAuthorizationScope,omitempty"` + // The cancellation timeout, in minutes, for builds queued against this definition. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // The job execution timeout, in minutes, for builds queued against this definition. + JobTimeoutInMinutes *int `json:"jobTimeoutInMinutes,omitempty"` + // The name of the phase. + Name *string `json:"name,omitempty"` + // The unique ref name of the phase. + RefName *string `json:"refName,omitempty"` + Steps *[]BuildDefinitionStep `json:"steps,omitempty"` + // The target (agent, server, etc.) for this phase. + Target *PhaseTarget `json:"target,omitempty"` + Variables *map[string]BuildDefinitionVariable `json:"variables,omitempty"` +} + +// Represents the target of a phase. +type PhaseTarget struct { + // The type of the target. + Type *int `json:"type,omitempty"` +} + +type ProcessTemplateType string + +type processTemplateTypeValuesType struct { + Custom ProcessTemplateType + Default ProcessTemplateType + Upgrade ProcessTemplateType +} + +var ProcessTemplateTypeValues = processTemplateTypeValuesType{ + // Indicates a custom template. + Custom: "custom", + // Indicates a default template. + Default: "default", + // Indicates an upgrade template. + Upgrade: "upgrade", +} + +// Represents a pull request object. These are retrieved from Source Providers. +type PullRequest struct { + // The links to other objects related to this object. + Links interface{} `json:"_links,omitempty"` + // Author of the pull request. + Author *webapi.IdentityRef `json:"author,omitempty"` + // Current state of the pull request, e.g. open, merged, closed, conflicts, etc. + CurrentState *string `json:"currentState,omitempty"` + // Description for the pull request. + Description *string `json:"description,omitempty"` + // Unique identifier for the pull request + Id *string `json:"id,omitempty"` + // The name of the provider this pull request is associated with. + ProviderName *string `json:"providerName,omitempty"` + // Source branch ref of this pull request + SourceBranchRef *string `json:"sourceBranchRef,omitempty"` + // Owner of the source repository of this pull request + SourceRepositoryOwner *string `json:"sourceRepositoryOwner,omitempty"` + // Target branch ref of this pull request + TargetBranchRef *string `json:"targetBranchRef,omitempty"` + // Owner of the target repository of this pull request + TargetRepositoryOwner *string `json:"targetRepositoryOwner,omitempty"` + // Title of the pull request. + Title *string `json:"title,omitempty"` +} + +// Represents a pull request trigger. +type PullRequestTrigger struct { + // The type of the trigger. + TriggerType *DefinitionTriggerType `json:"triggerType,omitempty"` + // Indicates if an update to a PR should delete current in-progress builds. + AutoCancel *bool `json:"autoCancel,omitempty"` + BranchFilters *[]string `json:"branchFilters,omitempty"` + Forks *Forks `json:"forks,omitempty"` + IsCommentRequiredForPullRequest *bool `json:"isCommentRequiredForPullRequest,omitempty"` + PathFilters *[]string `json:"pathFilters,omitempty"` + RequireCommentsForNonTeamMembersOnly *bool `json:"requireCommentsForNonTeamMembersOnly,omitempty"` + SettingsSourceType *int `json:"settingsSourceType,omitempty"` +} + +type QueryDeletedOption string + +type queryDeletedOptionValuesType struct { + ExcludeDeleted QueryDeletedOption + IncludeDeleted QueryDeletedOption + OnlyDeleted QueryDeletedOption +} + +var QueryDeletedOptionValues = queryDeletedOptionValuesType{ + // Include only non-deleted builds. + ExcludeDeleted: "excludeDeleted", + // Include deleted and non-deleted builds. + IncludeDeleted: "includeDeleted", + // Include only deleted builds. + OnlyDeleted: "onlyDeleted", +} + +// [Flags] +type QueueOptions string + +type queueOptionsValuesType struct { + None QueueOptions + DoNotRun QueueOptions +} + +var QueueOptionsValues = queueOptionsValuesType{ + // No queue options + None: "none", + // Create a plan Id for the build, do not run it + DoNotRun: "doNotRun", +} + +type QueuePriority string + +type queuePriorityValuesType struct { + Low QueuePriority + BelowNormal QueuePriority + Normal QueuePriority + AboveNormal QueuePriority + High QueuePriority +} + +var QueuePriorityValues = queuePriorityValuesType{ + // Low priority. + Low: "low", + // Below normal priority. + BelowNormal: "belowNormal", + // Normal priority. + Normal: "normal", + // Above normal priority. + AboveNormal: "aboveNormal", + // High priority. + High: "high", +} + +type RealtimeBuildEvent struct { + BuildId *int `json:"buildId,omitempty"` +} + +type RepositoryCleanOptions string + +type repositoryCleanOptionsValuesType struct { + Source RepositoryCleanOptions + SourceAndOutputDir RepositoryCleanOptions + SourceDir RepositoryCleanOptions + AllBuildDir RepositoryCleanOptions +} + +var RepositoryCleanOptionsValues = repositoryCleanOptionsValuesType{ + Source: "source", + SourceAndOutputDir: "sourceAndOutputDir", + // Re-create $(build.sourcesDirectory) + SourceDir: "sourceDir", + // Re-create $(agnet.buildDirectory) which contains $(build.sourcesDirectory), $(build.binariesDirectory) and any folders that left from previous build. + AllBuildDir: "allBuildDir", +} + +// Represents a repository's webhook returned from a source provider. +type RepositoryWebhook struct { + // The friendly name of the repository. + Name *string `json:"name,omitempty"` + Types *[]DefinitionTriggerType `json:"types,omitempty"` + // The URL of the repository. + Url *string `json:"url,omitempty"` +} + +// Represents a reference to a resource. +type ResourceReference struct { + // An alias to be used when referencing the resource. + Alias *string `json:"alias,omitempty"` +} + +type ResultSet string + +type resultSetValuesType struct { + All ResultSet + Top ResultSet +} + +var ResultSetValues = resultSetValuesType{ + // Include all repositories + All: "all", + // Include most relevant repositories for user + Top: "top", +} + +// Represents a retention policy for a build definition. +type RetentionPolicy struct { + Artifacts *[]string `json:"artifacts,omitempty"` + ArtifactTypesToDelete *[]string `json:"artifactTypesToDelete,omitempty"` + Branches *[]string `json:"branches,omitempty"` + // The number of days to keep builds. + DaysToKeep *int `json:"daysToKeep,omitempty"` + // Indicates whether the build record itself should be deleted. + DeleteBuildRecord *bool `json:"deleteBuildRecord,omitempty"` + // Indicates whether to delete test results associated with the build. + DeleteTestResults *bool `json:"deleteTestResults,omitempty"` + // The minimum number of builds to keep. + MinimumToKeep *int `json:"minimumToKeep,omitempty"` +} + +type Schedule struct { + BranchFilters *[]string `json:"branchFilters,omitempty"` + // Days for a build (flags enum for days of the week) + DaysToBuild *ScheduleDays `json:"daysToBuild,omitempty"` + // The Job Id of the Scheduled job that will queue the scheduled build. Since a single trigger can have multiple schedules and we want a single job to process a single schedule (since each schedule has a list of branches to build), the schedule itself needs to define the Job Id. This value will be filled in when a definition is added or updated. The UI does not provide it or use it. + ScheduleJobId *uuid.UUID `json:"scheduleJobId,omitempty"` + // Flag to determine if this schedule should only build if the associated source has been changed. + ScheduleOnlyWithChanges *bool `json:"scheduleOnlyWithChanges,omitempty"` + // Local timezone hour to start + StartHours *int `json:"startHours,omitempty"` + // Local timezone minute to start + StartMinutes *int `json:"startMinutes,omitempty"` + // Time zone of the build schedule (String representation of the time zone ID) + TimeZoneId *string `json:"timeZoneId,omitempty"` +} + +type ScheduleDays string + +type scheduleDaysValuesType struct { + None ScheduleDays + Monday ScheduleDays + Tuesday ScheduleDays + Wednesday ScheduleDays + Thursday ScheduleDays + Friday ScheduleDays + Saturday ScheduleDays + Sunday ScheduleDays + All ScheduleDays +} + +var ScheduleDaysValues = scheduleDaysValuesType{ + // Do not run. + None: "none", + // Run on Monday. + Monday: "monday", + // Run on Tuesday. + Tuesday: "tuesday", + // Run on Wednesday. + Wednesday: "wednesday", + // Run on Thursday. + Thursday: "thursday", + // Run on Friday. + Friday: "friday", + // Run on Saturday. + Saturday: "saturday", + // Run on Sunday. + Sunday: "sunday", + // Run on all days of the week. + All: "all", +} + +// Represents a schedule trigger. +type ScheduleTrigger struct { + // The type of the trigger. + TriggerType *DefinitionTriggerType `json:"triggerType,omitempty"` + Schedules *[]Schedule `json:"schedules,omitempty"` +} + +// Represents a reference to a secure file. +type SecureFileReference struct { + // An alias to be used when referencing the resource. + Alias *string `json:"alias,omitempty"` + // The ID of the secure file. + Id *uuid.UUID `json:"id,omitempty"` +} + +// Represents a phase target that runs on the server. +type ServerTarget struct { + // The type of the target. + Type *int `json:"type,omitempty"` + // The execution options. + ExecutionOptions *ServerTargetExecutionOptions `json:"executionOptions,omitempty"` +} + +// Represents options for running a phase on the server. +type ServerTargetExecutionOptions struct { + // The type. + Type *int `json:"type,omitempty"` +} + +// Represents a referenec to a service endpoint. +type ServiceEndpointReference struct { + // An alias to be used when referencing the resource. + Alias *string `json:"alias,omitempty"` + // The ID of the service endpoint. + Id *uuid.UUID `json:"id,omitempty"` +} + +type ServiceHostStatus string + +type serviceHostStatusValuesType struct { + Online ServiceHostStatus + Offline ServiceHostStatus +} + +var ServiceHostStatusValues = serviceHostStatusValuesType{ + // The service host is currently connected and accepting commands. + Online: "online", + // The service host is currently disconnected and not accepting commands. + Offline: "offline", +} + +type SourceProviderAttributes struct { + // The name of the source provider. + Name *string `json:"name,omitempty"` + // The capabilities supported by this source provider. + SupportedCapabilities *map[string]bool `json:"supportedCapabilities,omitempty"` + // The types of triggers supported by this source provider. + SupportedTriggers *[]SupportedTrigger `json:"supportedTriggers,omitempty"` +} + +type SourceProviderAvailability string + +type sourceProviderAvailabilityValuesType struct { + Hosted SourceProviderAvailability + OnPremises SourceProviderAvailability + All SourceProviderAvailability +} + +var SourceProviderAvailabilityValues = sourceProviderAvailabilityValuesType{ + // The source provider is available in the hosted environment. + Hosted: "hosted", + // The source provider is available in the on-premises environment. + OnPremises: "onPremises", + // The source provider is available in all environments. + All: "all", +} + +// Represents a work item related to some source item. These are retrieved from Source Providers. +type SourceRelatedWorkItem struct { + Links interface{} `json:"_links,omitempty"` + // Identity ref for the person that the work item is assigned to. + AssignedTo *webapi.IdentityRef `json:"assignedTo,omitempty"` + // Current state of the work item, e.g. Active, Resolved, Closed, etc. + CurrentState *string `json:"currentState,omitempty"` + // Long description for the work item. + Description *string `json:"description,omitempty"` + // Unique identifier for the work item + Id *string `json:"id,omitempty"` + // The name of the provider the work item is associated with. + ProviderName *string `json:"providerName,omitempty"` + // Short name for the work item. + Title *string `json:"title,omitempty"` + // Type of work item, e.g. Bug, Task, User Story, etc. + Type *string `json:"type,omitempty"` +} + +// A set of repositories returned from the source provider. +type SourceRepositories struct { + // A token used to continue this paged request; 'null' if the request is complete + ContinuationToken *string `json:"continuationToken,omitempty"` + // The number of repositories requested for each page + PageLength *int `json:"pageLength,omitempty"` + // A list of repositories + Repositories *[]SourceRepository `json:"repositories,omitempty"` + // The total number of pages, or '-1' if unknown + TotalPageCount *int `json:"totalPageCount,omitempty"` +} + +// Represents a repository returned from a source provider. +type SourceRepository struct { + // The name of the default branch. + DefaultBranch *string `json:"defaultBranch,omitempty"` + // The full name of the repository. + FullName *string `json:"fullName,omitempty"` + // The ID of the repository. + Id *string `json:"id,omitempty"` + // The friendly name of the repository. + Name *string `json:"name,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + // The name of the source provider the repository is from. + SourceProviderName *string `json:"sourceProviderName,omitempty"` + // The URL of the repository. + Url *string `json:"url,omitempty"` +} + +// Represents an item in a repository from a source provider. +type SourceRepositoryItem struct { + // Whether the item is able to have sub-items (e.g., is a folder). + IsContainer *bool `json:"isContainer,omitempty"` + // The full path of the item, relative to the root of the repository. + Path *string `json:"path,omitempty"` + // The type of the item (folder, file, etc). + Type *string `json:"type,omitempty"` + // The URL of the item. + Url *string `json:"url,omitempty"` +} + +type SupportedTrigger struct { + // The default interval to wait between polls (only relevant when NotificationType is Polling). + DefaultPollingInterval *int `json:"defaultPollingInterval,omitempty"` + // How the trigger is notified of changes. + NotificationType *string `json:"notificationType,omitempty"` + // The capabilities supported by this trigger. + SupportedCapabilities *map[string]SupportLevel `json:"supportedCapabilities,omitempty"` + // The type of trigger. + Type *DefinitionTriggerType `json:"type,omitempty"` +} + +type SupportLevel string + +type supportLevelValuesType struct { + Unsupported SupportLevel + Supported SupportLevel + Required SupportLevel +} + +var SupportLevelValues = supportLevelValuesType{ + // The functionality is not supported. + Unsupported: "unsupported", + // The functionality is supported. + Supported: "supported", + // The functionality is required. + Required: "required", +} + +// Represents a Subversion mapping entry. +type SvnMappingDetails struct { + // The depth. + Depth *int `json:"depth,omitempty"` + // Indicates whether to ignore externals. + IgnoreExternals *bool `json:"ignoreExternals,omitempty"` + // The local path. + LocalPath *string `json:"localPath,omitempty"` + // The revision. + Revision *string `json:"revision,omitempty"` + // The server path. + ServerPath *string `json:"serverPath,omitempty"` +} + +// Represents a subversion workspace. +type SvnWorkspace struct { + Mappings *[]SvnMappingDetails `json:"mappings,omitempty"` +} + +// Represents a reference to an agent pool. +type TaskAgentPoolReference struct { + // The pool ID. + Id *int `json:"id,omitempty"` + // A value indicating whether or not this pool is managed by the service. + IsHosted *bool `json:"isHosted,omitempty"` + // The pool name. + Name *string `json:"name,omitempty"` +} + +// A reference to a task definition. +type TaskDefinitionReference struct { + // The type of task (task or task group). + DefinitionType *string `json:"definitionType,omitempty"` + // The ID of the task. + Id *uuid.UUID `json:"id,omitempty"` + // The version of the task. + VersionSpec *string `json:"versionSpec,omitempty"` +} + +// Represents a reference to a plan group. +type TaskOrchestrationPlanGroupReference struct { + // The name of the plan group. + PlanGroup *string `json:"planGroup,omitempty"` + // The project ID. + ProjectId *uuid.UUID `json:"projectId,omitempty"` +} + +type TaskOrchestrationPlanGroupsStartedEvent struct { + PlanGroups *[]TaskOrchestrationPlanGroupReference `json:"planGroups,omitempty"` +} + +// Represents a reference to an orchestration plan. +type TaskOrchestrationPlanReference struct { + // The type of the plan. + OrchestrationType *int `json:"orchestrationType,omitempty"` + // The ID of the plan. + PlanId *uuid.UUID `json:"planId,omitempty"` +} + +// Represents a reference to a task. +type TaskReference struct { + // The ID of the task definition. + Id *uuid.UUID `json:"id,omitempty"` + // The name of the task definition. + Name *string `json:"name,omitempty"` + // The version of the task definition. + Version *string `json:"version,omitempty"` +} + +type TaskResult string + +type taskResultValuesType struct { + Succeeded TaskResult + SucceededWithIssues TaskResult + Failed TaskResult + Canceled TaskResult + Skipped TaskResult + Abandoned TaskResult +} + +var TaskResultValues = taskResultValuesType{ + Succeeded: "succeeded", + SucceededWithIssues: "succeededWithIssues", + Failed: "failed", + Canceled: "canceled", + Skipped: "skipped", + Abandoned: "abandoned", +} + +// Represents the timeline of a build. +type Timeline struct { + // The change ID. + ChangeId *int `json:"changeId,omitempty"` + // The ID of the timeline. + Id *uuid.UUID `json:"id,omitempty"` + // The REST URL of the timeline. + Url *string `json:"url,omitempty"` + // The process or person that last changed the timeline. + LastChangedBy *uuid.UUID `json:"lastChangedBy,omitempty"` + // The time the timeline was last changed. + LastChangedOn *azuredevops.Time `json:"lastChangedOn,omitempty"` + Records *[]TimelineRecord `json:"records,omitempty"` +} + +type TimelineAttempt struct { + // Gets or sets the attempt of the record. + Attempt *int `json:"attempt,omitempty"` + // Gets or sets the record identifier located within the specified timeline. + RecordId *uuid.UUID `json:"recordId,omitempty"` + // Gets or sets the timeline identifier which owns the record representing this attempt. + TimelineId *uuid.UUID `json:"timelineId,omitempty"` +} + +// Represents an entry in a build's timeline. +type TimelineRecord struct { + Links interface{} `json:"_links,omitempty"` + // Attempt number of record. + Attempt *int `json:"attempt,omitempty"` + // The change ID. + ChangeId *int `json:"changeId,omitempty"` + // A string that indicates the current operation. + CurrentOperation *string `json:"currentOperation,omitempty"` + // A reference to a sub-timeline. + Details *TimelineReference `json:"details,omitempty"` + // The number of errors produced by this operation. + ErrorCount *int `json:"errorCount,omitempty"` + // The finish time. + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + // The ID of the record. + Id *uuid.UUID `json:"id,omitempty"` + // String identifier that is consistent across attempts. + Identifier *string `json:"identifier,omitempty"` + Issues *[]Issue `json:"issues,omitempty"` + // The time the record was last modified. + LastModified *azuredevops.Time `json:"lastModified,omitempty"` + // A reference to the log produced by this operation. + Log *BuildLogReference `json:"log,omitempty"` + // The name. + Name *string `json:"name,omitempty"` + // An ordinal value relative to other records. + Order *int `json:"order,omitempty"` + // The ID of the record's parent. + ParentId *uuid.UUID `json:"parentId,omitempty"` + // The current completion percentage. + PercentComplete *int `json:"percentComplete,omitempty"` + PreviousAttempts *[]TimelineAttempt `json:"previousAttempts,omitempty"` + // The result. + Result *TaskResult `json:"result,omitempty"` + // The result code. + ResultCode *string `json:"resultCode,omitempty"` + // The start time. + StartTime *azuredevops.Time `json:"startTime,omitempty"` + // The state of the record. + State *TimelineRecordState `json:"state,omitempty"` + // A reference to the task represented by this timeline record. + Task *TaskReference `json:"task,omitempty"` + // The type of the record. + Type *string `json:"type,omitempty"` + // The REST URL of the timeline record. + Url *string `json:"url,omitempty"` + // The number of warnings produced by this operation. + WarningCount *int `json:"warningCount,omitempty"` + // The name of the agent running the operation. + WorkerName *string `json:"workerName,omitempty"` +} + +type TimelineRecordState string + +type timelineRecordStateValuesType struct { + Pending TimelineRecordState + InProgress TimelineRecordState + Completed TimelineRecordState +} + +var TimelineRecordStateValues = timelineRecordStateValuesType{ + Pending: "pending", + InProgress: "inProgress", + Completed: "completed", +} + +type TimelineRecordsUpdatedEvent struct { + BuildId *int `json:"buildId,omitempty"` + TimelineRecords *[]TimelineRecord `json:"timelineRecords,omitempty"` +} + +// Represents a reference to a timeline. +type TimelineReference struct { + // The change ID. + ChangeId *int `json:"changeId,omitempty"` + // The ID of the timeline. + Id *uuid.UUID `json:"id,omitempty"` + // The REST URL of the timeline. + Url *string `json:"url,omitempty"` +} + +type ValidationResult string + +type validationResultValuesType struct { + Ok ValidationResult + Warning ValidationResult + Error ValidationResult +} + +var ValidationResultValues = validationResultValuesType{ + Ok: "ok", + Warning: "warning", + Error: "error", +} + +// Represents a variable group. +type VariableGroup struct { + // The Name of the variable group. + Alias *string `json:"alias,omitempty"` + // The ID of the variable group. + Id *int `json:"id,omitempty"` + // The description. + Description *string `json:"description,omitempty"` + // The name of the variable group. + Name *string `json:"name,omitempty"` + // The type of the variable group. + Type *string `json:"type,omitempty"` + Variables *map[string]BuildDefinitionVariable `json:"variables,omitempty"` +} + +// Represents a reference to a variable group. +type VariableGroupReference struct { + // The Name of the variable group. + Alias *string `json:"alias,omitempty"` + // The ID of the variable group. + Id *int `json:"id,omitempty"` +} + +// Represents options for running a phase based on values specified by a list of variables. +type VariableMultipliersAgentExecutionOptions struct { + // Indicates the type of execution options. + Type *int `json:"type,omitempty"` + // Indicates whether failure on one agent should prevent the phase from running on other agents. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // The maximum number of agents to use in parallel. + MaxConcurrency *int `json:"maxConcurrency,omitempty"` + Multipliers *[]string `json:"multipliers,omitempty"` +} + +// Represents options for running a phase based on values specified by a list of variables. +type VariableMultipliersServerExecutionOptions struct { + // The type. + Type *int `json:"type,omitempty"` + // Indicates whether failure of one job should prevent the phase from running in other jobs. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // The maximum number of server jobs to run in parallel. + MaxConcurrency *int `json:"maxConcurrency,omitempty"` + Multipliers *[]string `json:"multipliers,omitempty"` +} + +// Mapping for a workspace +type WorkspaceMapping struct { + // Uri of the associated definition + DefinitionUri *string `json:"definitionUri,omitempty"` + // Depth of this mapping + Depth *int `json:"depth,omitempty"` + // local location of the definition + LocalItem *string `json:"localItem,omitempty"` + // type of workspace mapping + MappingType *WorkspaceMappingType `json:"mappingType,omitempty"` + // Server location of the definition + ServerItem *string `json:"serverItem,omitempty"` + // Id of the workspace + WorkspaceId *int `json:"workspaceId,omitempty"` +} + +type WorkspaceMappingType string + +type workspaceMappingTypeValuesType struct { + Map WorkspaceMappingType + Cloak WorkspaceMappingType +} + +var WorkspaceMappingTypeValues = workspaceMappingTypeValuesType{ + // The path is mapped in the workspace. + Map: "map", + // The path is cloaked in the workspace. + Cloak: "cloak", +} + +type WorkspaceTemplate struct { + // Uri of the associated definition + DefinitionUri *string `json:"definitionUri,omitempty"` + // The identity that last modified this template + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // The last time this template was modified + LastModifiedDate *azuredevops.Time `json:"lastModifiedDate,omitempty"` + // List of workspace mappings + Mappings *[]WorkspaceMapping `json:"mappings,omitempty"` + // Id of the workspace for this template + WorkspaceId *int `json:"workspaceId,omitempty"` +} + +type XamlBuildControllerReference struct { + // Id of the resource + Id *int `json:"id,omitempty"` + // Name of the linked resource (definition name, controller name, etc.) + Name *string `json:"name,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` +} + +type XamlBuildDefinition struct { + // The date this version of the definition was created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // The ID of the referenced definition. + Id *int `json:"id,omitempty"` + // The name of the referenced definition. + Name *string `json:"name,omitempty"` + // The folder path of the definition. + Path *string `json:"path,omitempty"` + // A reference to the project. + Project *core.TeamProjectReference `json:"project,omitempty"` + // A value that indicates whether builds can be queued against this definition. + QueueStatus *DefinitionQueueStatus `json:"queueStatus,omitempty"` + // The definition revision number. + Revision *int `json:"revision,omitempty"` + // The type of the definition. + Type *DefinitionType `json:"type,omitempty"` + // The definition's URI. + Uri *string `json:"uri,omitempty"` + // The REST URL of the definition. + Url *string `json:"url,omitempty"` + Links interface{} `json:"_links,omitempty"` + // Batch size of the definition + BatchSize *int `json:"batchSize,omitempty"` + BuildArgs *string `json:"buildArgs,omitempty"` + // The continuous integration quiet period + ContinuousIntegrationQuietPeriod *int `json:"continuousIntegrationQuietPeriod,omitempty"` + // The build controller + Controller *BuildController `json:"controller,omitempty"` + // The date this definition was created + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Default drop location for builds from this definition + DefaultDropLocation *string `json:"defaultDropLocation,omitempty"` + // Description of the definition + Description *string `json:"description,omitempty"` + // The last build on this definition + LastBuild *XamlBuildReference `json:"lastBuild,omitempty"` + // The repository + Repository *BuildRepository `json:"repository,omitempty"` + // The reasons supported by the template + SupportedReasons *BuildReason `json:"supportedReasons,omitempty"` + // How builds are triggered from this definition + TriggerType *DefinitionTriggerType `json:"triggerType,omitempty"` +} + +type XamlBuildReference struct { + // Id of the resource + Id *int `json:"id,omitempty"` + // Name of the linked resource (definition name, controller name, etc.) + Name *string `json:"name,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` +} + +type XamlBuildServerReference struct { + // Id of the resource + Id *int `json:"id,omitempty"` + // Name of the linked resource (definition name, controller name, etc.) + Name *string `json:"name,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` +} + +type XamlDefinitionReference struct { + // Id of the resource + Id *int `json:"id,omitempty"` + // Name of the linked resource (definition name, controller name, etc.) + Name *string `json:"name,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` +} + +// Represents a YAML process. +type YamlProcess struct { + // The type of the process. + Type *int `json:"type,omitempty"` + Errors *[]string `json:"errors,omitempty"` + // The resources used by the build definition. + Resources *BuildProcessResources `json:"resources,omitempty"` + // The YAML filename. + YamlFilename *string `json:"yamlFilename,omitempty"` +} diff --git a/azuredevops/cix/client.go b/azuredevops/cix/client.go new file mode 100644 index 00000000..704a775e --- /dev/null +++ b/azuredevops/cix/client.go @@ -0,0 +1,289 @@ +// -------------------------------------------------------------------------------------------- +// 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 cix + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" +) + +type Client interface { + // [Preview API] Creates a new Pipeline connection between the provider installation and the specified project. Returns the PipelineConnection object created. + CreateProjectConnection(context.Context, CreateProjectConnectionArgs) (*PipelineConnection, error) + // [Preview API] + CreateResources(context.Context, CreateResourcesArgs) (*CreatedResources, error) + // [Preview API] Gets a list of existing configuration files for the given repository. + GetConfigurations(context.Context, GetConfigurationsArgs) (*[]ConfigurationFile, error) + // [Preview API] Returns a list of build frameworks that best match the given repository based on its contents. + GetDetectedBuildFrameworks(context.Context, GetDetectedBuildFrameworksArgs) (*[]DetectedBuildFramework, error) + // [Preview API] Returns a list of all YAML templates with weighting based on which would best fit the given repository. + GetTemplateRecommendations(context.Context, GetTemplateRecommendationsArgs) (*[]Template, error) + // [Preview API] + RenderTemplate(context.Context, RenderTemplateArgs) (*Template, 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, + } +} + +// [Preview API] Creates a new Pipeline connection between the provider installation and the specified project. Returns the PipelineConnection object created. +func (client *ClientImpl) CreateProjectConnection(ctx context.Context, args CreateProjectConnectionArgs) (*PipelineConnection, error) { + if args.CreateConnectionInputs == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CreateConnectionInputs"} + } + queryParams := url.Values{} + if args.Project == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "project"} + } + queryParams.Add("project", *args.Project) + body, marshalErr := json.Marshal(*args.CreateConnectionInputs) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("00df4879-9216-45d5-b38d-4a487b626b2c") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PipelineConnection + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateProjectConnection function +type CreateProjectConnectionArgs struct { + // (required) + CreateConnectionInputs *CreatePipelineConnectionInputs + // (required) + Project *string +} + +// [Preview API] +func (client *ClientImpl) CreateResources(ctx context.Context, args CreateResourcesArgs) (*CreatedResources, error) { + if args.CreationParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CreationParameters"} + } + 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.CreationParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("43201899-7690-4870-9c79-ab69605f21ed") + 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 CreatedResources + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateResources function +type CreateResourcesArgs struct { + // (required) + CreationParameters *map[string]ResourceCreationParameter + // (required) Project ID or project name + Project *string +} + +// [Preview API] Gets a list of existing configuration files for the given repository. +func (client *ClientImpl) GetConfigurations(ctx context.Context, args GetConfigurationsArgs) (*[]ConfigurationFile, 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.RepositoryType != nil { + queryParams.Add("repositoryType", *args.RepositoryType) + } + if args.RepositoryId != nil { + queryParams.Add("repositoryId", *args.RepositoryId) + } + if args.Branch != nil { + queryParams.Add("branch", *args.Branch) + } + if args.ServiceConnectionId != nil { + queryParams.Add("serviceConnectionId", (*args.ServiceConnectionId).String()) + } + locationId, _ := uuid.Parse("8fc87684-9ebc-4c37-ab92-f4ac4a58cb3a") + 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 []ConfigurationFile + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetConfigurations function +type GetConfigurationsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) The type of the repository such as GitHub, TfsGit (i.e. Azure Repos), Bitbucket, etc. + RepositoryType *string + // (optional) The vendor-specific identifier or the name of the repository, e.g. Microsoft/vscode (GitHub) or e9d82045-ddba-4e01-a63d-2ab9f040af62 (Azure Repos) + RepositoryId *string + // (optional) The repository branch where to look for the configuration file. + Branch *string + // (optional) If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TfsGit (i.e. Azure Repos). + ServiceConnectionId *uuid.UUID +} + +// [Preview API] Returns a list of build frameworks that best match the given repository based on its contents. +func (client *ClientImpl) GetDetectedBuildFrameworks(ctx context.Context, args GetDetectedBuildFrameworksArgs) (*[]DetectedBuildFramework, 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.RepositoryType != nil { + queryParams.Add("repositoryType", *args.RepositoryType) + } + if args.RepositoryId != nil { + queryParams.Add("repositoryId", *args.RepositoryId) + } + if args.Branch != nil { + queryParams.Add("branch", *args.Branch) + } + if args.DetectionType != nil { + queryParams.Add("detectionType", string(*args.DetectionType)) + } + if args.ServiceConnectionId != nil { + queryParams.Add("serviceConnectionId", (*args.ServiceConnectionId).String()) + } + locationId, _ := uuid.Parse("29a30bab-9efb-4652-bf1b-9269baca0980") + 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 []DetectedBuildFramework + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDetectedBuildFrameworks function +type GetDetectedBuildFrameworksArgs struct { + // (required) Project ID or project name + Project *string + // (optional) The type of the repository such as GitHub, TfsGit (i.e. Azure Repos), Bitbucket, etc. + RepositoryType *string + // (optional) The vendor-specific identifier or the name of the repository, e.g. Microsoft/vscode (GitHub) or e9d82045-ddba-4e01-a63d-2ab9f040af62 (Azure Repos) + RepositoryId *string + // (optional) The repository branch to detect build frameworks for. + Branch *string + // (optional) + DetectionType *BuildFrameworkDetectionType + // (optional) If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TfsGit (i.e. Azure Repos). + ServiceConnectionId *uuid.UUID +} + +// [Preview API] Returns a list of all YAML templates with weighting based on which would best fit the given repository. +func (client *ClientImpl) GetTemplateRecommendations(ctx context.Context, args GetTemplateRecommendationsArgs) (*[]Template, 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.RepositoryType != nil { + queryParams.Add("repositoryType", *args.RepositoryType) + } + if args.RepositoryId != nil { + queryParams.Add("repositoryId", *args.RepositoryId) + } + if args.Branch != nil { + queryParams.Add("branch", *args.Branch) + } + if args.ServiceConnectionId != nil { + queryParams.Add("serviceConnectionId", (*args.ServiceConnectionId).String()) + } + locationId, _ := uuid.Parse("63ea8f13-b563-4be7-bc31-3a96eda27220") + 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 []Template + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTemplateRecommendations function +type GetTemplateRecommendationsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) The type of the repository such as GitHub, TfsGit (i.e. Azure Repos), Bitbucket, etc. + RepositoryType *string + // (optional) The vendor-specific identifier or the name of the repository, e.g. Microsoft/vscode (GitHub) or e9d82045-ddba-4e01-a63d-2ab9f040af62 (Azure Repos) + RepositoryId *string + // (optional) The repository branch which to find matching templates for. + Branch *string + // (optional) If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TfsGit (i.e. Azure Repos). + ServiceConnectionId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) RenderTemplate(ctx context.Context, args RenderTemplateArgs) (*Template, error) { + if args.TemplateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TemplateParameters"} + } + routeValues := make(map[string]string) + if args.TemplateId == nil || *args.TemplateId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TemplateId"} + } + routeValues["templateId"] = *args.TemplateId + + body, marshalErr := json.Marshal(*args.TemplateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("eb5d6d1d-98a2-4bbd-9028-f9a6b2d66515") + 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 Template + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the RenderTemplate function +type RenderTemplateArgs struct { + // (required) + TemplateParameters *TemplateParameters + // (required) + TemplateId *string +} diff --git a/azuredevops/cix/models.go b/azuredevops/cix/models.go new file mode 100644 index 00000000..65022f28 --- /dev/null +++ b/azuredevops/cix/models.go @@ -0,0 +1,129 @@ +// -------------------------------------------------------------------------------------------- +// 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 cix + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops/core" +) + +type BuildFrameworkDetectionType string + +type buildFrameworkDetectionTypeValuesType struct { + Shallow BuildFrameworkDetectionType + Full BuildFrameworkDetectionType +} + +var BuildFrameworkDetectionTypeValues = buildFrameworkDetectionTypeValuesType{ + Shallow: "shallow", + Full: "full", +} + +type ConfigurationFile struct { + // The content of the file. + Content *string `json:"content,omitempty"` + // Indicates if the content is base64 encoded. + IsBase64Encoded *bool `json:"isBase64Encoded,omitempty"` + // The full path of the file, relative to the root of the repository. + Path *string `json:"path,omitempty"` +} + +type CreatedResources struct { + Resources *map[string]interface{} `json:"resources,omitempty"` +} + +// This class is used to create a pipeline connection within the team project provided. If the team project does not exist, it will be created. +type CreatePipelineConnectionInputs struct { + // The team project settings for an existing team project or for a new team project. + Project *core.TeamProject `json:"project,omitempty"` + // This dictionary contains information that is specific to the provider. This data is opaque to the rest of the Pipelines infrastructure and does NOT contribute to the resources Token. The format of the string and its contents depend on the implementation of the provider. + ProviderData *map[string]string `json:"providerData,omitempty"` + // The external source provider id for which the connection is being made. + ProviderId *string `json:"providerId,omitempty"` + // If provided, this will be the URL returned with the PipelineConnection. This will override any other redirect URL that would have been generated for the connection. + RedirectUrl *string `json:"redirectUrl,omitempty"` + // Where the request to create the pipeline originated (such as 'GitHub Marketplace' or 'Azure DevOps') + RequestSource *string `json:"requestSource,omitempty"` +} + +type DetectedBuildFramework struct { + // List of build targets discovered for the framework to act upon. + BuildTargets *[]DetectedBuildTarget `json:"buildTargets,omitempty"` + // The unique identifier of the build framework. + Id *string `json:"id,omitempty"` + // Additional detected settings for the build framework. + Settings *map[string]string `json:"settings,omitempty"` + // The version of the framework if it can be determined from the sources. + Version *string `json:"version,omitempty"` +} + +type DetectedBuildTarget struct { + Path *string `json:"path,omitempty"` + Settings *map[string]string `json:"settings,omitempty"` + Type *string `json:"type,omitempty"` +} + +type PipelineConnection struct { + // The account id that contains the team project for the connection. + AccountId *uuid.UUID `json:"accountId,omitempty"` + // Deprecated: This property is no longer filled in and will be removed soon. + DefinitionId *int `json:"definitionId,omitempty"` + // This is the URL that the user should be taken to in order to continue setup. + RedirectUrl *string `json:"redirectUrl,omitempty"` + // The service endpoint that was created for the connection. + ServiceEndpointId *uuid.UUID `json:"serviceEndpointId,omitempty"` + // The team project that contains the definition for the connection. + TeamProjectId *uuid.UUID `json:"teamProjectId,omitempty"` +} + +type ResourceCreationParameter struct { + ResourceToCreate interface{} `json:"resourceToCreate,omitempty"` + Type *string `json:"type,omitempty"` +} + +type Template struct { + Assets *[]TemplateAsset `json:"assets,omitempty"` + Content *string `json:"content,omitempty"` + DataSourceBindings *[]TemplateDataSourceBinding `json:"dataSourceBindings,omitempty"` + Description *string `json:"description,omitempty"` + IconUrl *string `json:"iconUrl,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Parameters *[]TemplateParameterDefinition `json:"parameters,omitempty"` + RecommendedWeight *int `json:"recommendedWeight,omitempty"` +} + +type TemplateAsset struct { + Content *string `json:"content,omitempty"` + Description *string `json:"description,omitempty"` + DestinationPath *string `json:"destinationPath,omitempty"` + Path *string `json:"path,omitempty"` + Type *string `json:"type,omitempty"` +} + +type TemplateDataSourceBinding struct { + DataSourceName *string `json:"dataSourceName,omitempty"` + EndpointParameterName *string `json:"endpointParameterName,omitempty"` + Parameters *map[string]string `json:"parameters,omitempty"` + ResultTemplate *string `json:"resultTemplate,omitempty"` + Target *string `json:"target,omitempty"` +} + +type TemplateParameterDefinition struct { + DefaultValue *string `json:"defaultValue,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Name *string `json:"name,omitempty"` + PossibleValues *[]string `json:"possibleValues,omitempty"` + Required *bool `json:"required,omitempty"` + Type *string `json:"type,omitempty"` +} + +type TemplateParameters struct { + Tokens *map[string]interface{} `json:"tokens,omitempty"` +} diff --git a/azuredevops/client.go b/azuredevops/client.go new file mode 100644 index 00000000..8382ab08 --- /dev/null +++ b/azuredevops/client.go @@ -0,0 +1,434 @@ +// 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 = "5.1.0-b1" // 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 { + 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/azuredevops/clientTrace/client.go b/azuredevops/clientTrace/client.go new file mode 100644 index 00000000..ded75a0b --- /dev/null +++ b/azuredevops/clientTrace/client.go @@ -0,0 +1,58 @@ +// -------------------------------------------------------------------------------------------- +// 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 clienttrace + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" +) + +type Client interface { + // [Preview API] + PublishEvents(context.Context, PublishEventsArgs) 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, + } +} + +// [Preview API] +func (client *ClientImpl) PublishEvents(ctx context.Context, args PublishEventsArgs) error { + if args.Events == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Events"} + } + body, marshalErr := json.Marshal(*args.Events) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("06bcc74a-1491-4eb8-a0eb-704778f9d041") + _, 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 err + } + + return nil +} + +// Arguments for the PublishEvents function +type PublishEventsArgs struct { + // (required) + Events *[]ClientTraceEvent +} diff --git a/azuredevops/clientTrace/models.go b/azuredevops/clientTrace/models.go new file mode 100644 index 00000000..114ca718 --- /dev/null +++ b/azuredevops/clientTrace/models.go @@ -0,0 +1,38 @@ +// -------------------------------------------------------------------------------------------- +// 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 clienttrace + +type ClientTraceEvent struct { + Area *string `json:"area,omitempty"` + Component *string `json:"component,omitempty"` + ExceptionType *string `json:"exceptionType,omitempty"` + Feature *string `json:"feature,omitempty"` + Level *Level `json:"level,omitempty"` + Message *string `json:"message,omitempty"` + Method *string `json:"method,omitempty"` + Properties *map[string]interface{} `json:"properties,omitempty"` +} + +type Level string + +type levelValuesType struct { + Off Level + Error Level + Warning Level + Info Level + Verbose Level +} + +var LevelValues = levelValuesType{ + Off: "off", + Error: "error", + Warning: "warning", + Info: "info", + Verbose: "verbose", +} diff --git a/azuredevops/cloudloadtest/client.go b/azuredevops/cloudloadtest/client.go new file mode 100644 index 00000000..017c8e35 --- /dev/null +++ b/azuredevops/cloudloadtest/client.go @@ -0,0 +1,768 @@ +// -------------------------------------------------------------------------------------------- +// 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 cloudloadtest + +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/testservice" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("7ae6d0a6-cda5-44cf-a261-28c392bed25c") + +type Client interface { + CreateAgentGroup(context.Context, CreateAgentGroupArgs) (*testservice.AgentGroup, error) + CreateTestDefinition(context.Context, CreateTestDefinitionArgs) (*testservice.TestDefinition, error) + CreateTestDrop(context.Context, CreateTestDropArgs) (*testservice.TestDrop, error) + CreateTestRun(context.Context, CreateTestRunArgs) (*testservice.TestRun, error) + DeleteStaticAgent(context.Context, DeleteStaticAgentArgs) (*string, error) + GetAgentGroups(context.Context, GetAgentGroupsArgs) (interface{}, error) + GetApplication(context.Context, GetApplicationArgs) (*testservice.Application, error) + GetApplicationCounters(context.Context, GetApplicationCountersArgs) (*[]testservice.ApplicationCounters, error) + GetApplications(context.Context, GetApplicationsArgs) (*[]testservice.Application, error) + GetCounters(context.Context, GetCountersArgs) (*[]testservice.TestRunCounterInstance, error) + GetCounterSamples(context.Context, GetCounterSamplesArgs) (*testservice.CounterSamplesResult, error) + GetLoadTestResult(context.Context, GetLoadTestResultArgs) (*testservice.TestResults, error) + GetLoadTestRunErrors(context.Context, GetLoadTestRunErrorsArgs) (*testservice.LoadTestErrors, error) + GetPlugin(context.Context, GetPluginArgs) (*testservice.ApplicationType, error) + GetPlugins(context.Context, GetPluginsArgs) (*[]testservice.ApplicationType, error) + GetStaticAgents(context.Context, GetStaticAgentsArgs) (interface{}, error) + GetTestDefinition(context.Context, GetTestDefinitionArgs) (*testservice.TestDefinition, error) + GetTestDefinitions(context.Context, GetTestDefinitionsArgs) (*[]testservice.TestDefinitionBasic, error) + GetTestDrop(context.Context, GetTestDropArgs) (*testservice.TestDrop, error) + GetTestRun(context.Context, GetTestRunArgs) (*testservice.TestRun, error) + GetTestRunMessages(context.Context, GetTestRunMessagesArgs) (*[]testservice.TestRunMessage, error) + // Returns test runs based on the filter specified. Returns all runs of the tenant if there is no filter. + GetTestRuns(context.Context, GetTestRunsArgs) (interface{}, error) + UpdateTestDefinition(context.Context, UpdateTestDefinitionArgs) (*testservice.TestDefinition, error) + UpdateTestRun(context.Context, UpdateTestRunArgs) 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 +} + +func (client *ClientImpl) CreateAgentGroup(ctx context.Context, args CreateAgentGroupArgs) (*testservice.AgentGroup, error) { + if args.Group == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Group"} + } + body, marshalErr := json.Marshal(*args.Group) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ab8d91c1-12d9-4ec5-874d-1ddb23e17720") + 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 testservice.AgentGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateAgentGroup function +type CreateAgentGroupArgs struct { + // (required) Agent group to be created + Group *testservice.AgentGroup +} + +func (client *ClientImpl) CreateTestDefinition(ctx context.Context, args CreateTestDefinitionArgs) (*testservice.TestDefinition, error) { + if args.TestDefinition == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestDefinition"} + } + body, marshalErr := json.Marshal(*args.TestDefinition) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a8f9b135-f604-41ea-9d74-d9a5fd32fcd8") + 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 testservice.TestDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestDefinition function +type CreateTestDefinitionArgs struct { + // (required) Test definition to be created + TestDefinition *testservice.TestDefinition +} + +func (client *ClientImpl) CreateTestDrop(ctx context.Context, args CreateTestDropArgs) (*testservice.TestDrop, error) { + if args.WebTestDrop == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WebTestDrop"} + } + body, marshalErr := json.Marshal(*args.WebTestDrop) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d89d0e08-505c-4357-96f6-9729311ce8ad") + 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 testservice.TestDrop + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestDrop function +type CreateTestDropArgs struct { + // (required) Test drop to be created + WebTestDrop *testservice.TestDrop +} + +func (client *ClientImpl) CreateTestRun(ctx context.Context, args CreateTestRunArgs) (*testservice.TestRun, error) { + if args.WebTestRun == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WebTestRun"} + } + body, marshalErr := json.Marshal(*args.WebTestRun) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b41a84ff-ff03-4ac1-b76e-e7ea25c92aba") + 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 testservice.TestRun + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestRun function +type CreateTestRunArgs struct { + // (required) + WebTestRun *testservice.TestRun +} + +func (client *ClientImpl) DeleteStaticAgent(ctx context.Context, args DeleteStaticAgentArgs) (*string, error) { + routeValues := make(map[string]string) + if args.AgentGroupId == nil || *args.AgentGroupId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AgentGroupId"} + } + routeValues["agentGroupId"] = *args.AgentGroupId + + queryParams := url.Values{} + if args.AgentName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "agentName"} + } + queryParams.Add("agentName", *args.AgentName) + locationId, _ := uuid.Parse("87e4b63d-7142-4b50-801e-72ba9ff8ee9b") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.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 DeleteStaticAgent function +type DeleteStaticAgentArgs struct { + // (required) The agent group identifier + AgentGroupId *string + // (required) Name of the static agent + AgentName *string +} + +func (client *ClientImpl) GetAgentGroups(ctx context.Context, args GetAgentGroupsArgs) (interface{}, error) { + routeValues := make(map[string]string) + if args.AgentGroupId != nil && *args.AgentGroupId != "" { + routeValues["agentGroupId"] = *args.AgentGroupId + } + + queryParams := url.Values{} + if args.MachineSetupInput != nil { + queryParams.Add("machineSetupInput", strconv.FormatBool(*args.MachineSetupInput)) + } + if args.MachineAccessData != nil { + queryParams.Add("machineAccessData", strconv.FormatBool(*args.MachineAccessData)) + } + if args.OutgoingRequestUrls != nil { + queryParams.Add("outgoingRequestUrls", strconv.FormatBool(*args.OutgoingRequestUrls)) + } + if args.AgentGroupName != nil { + queryParams.Add("agentGroupName", *args.AgentGroupName) + } + locationId, _ := uuid.Parse("ab8d91c1-12d9-4ec5-874d-1ddb23e17720") + 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 interface{} + err = client.Client.UnmarshalBody(resp, responseValue) + return responseValue, err +} + +// Arguments for the GetAgentGroups function +type GetAgentGroupsArgs struct { + // (optional) The agent group identifier + AgentGroupId *string + // (optional) + MachineSetupInput *bool + // (optional) + MachineAccessData *bool + // (optional) + OutgoingRequestUrls *bool + // (optional) Name of the agent group + AgentGroupName *string +} + +func (client *ClientImpl) GetApplication(ctx context.Context, args GetApplicationArgs) (*testservice.Application, error) { + routeValues := make(map[string]string) + if args.ApplicationId == nil || *args.ApplicationId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ApplicationId"} + } + routeValues["applicationId"] = *args.ApplicationId + + locationId, _ := uuid.Parse("2c986dce-8e8d-4142-b541-d016d5aff764") + 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 testservice.Application + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetApplication function +type GetApplicationArgs struct { + // (required) Filter by APM application identifier. + ApplicationId *string +} + +func (client *ClientImpl) GetApplicationCounters(ctx context.Context, args GetApplicationCountersArgs) (*[]testservice.ApplicationCounters, error) { + queryParams := url.Values{} + if args.ApplicationId != nil { + queryParams.Add("applicationId", *args.ApplicationId) + } + if args.Plugintype != nil { + queryParams.Add("plugintype", *args.Plugintype) + } + locationId, _ := uuid.Parse("c1275ce9-6d26-4bc6-926b-b846502e812d") + 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 []testservice.ApplicationCounters + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetApplicationCounters function +type GetApplicationCountersArgs struct { + // (optional) Filter by APM application identifier. + ApplicationId *string + // (optional) Currently ApplicationInsights is the only available plugin type. + Plugintype *string +} + +func (client *ClientImpl) GetApplications(ctx context.Context, args GetApplicationsArgs) (*[]testservice.Application, error) { + queryParams := url.Values{} + if args.Type != nil { + queryParams.Add("type", *args.Type) + } + locationId, _ := uuid.Parse("2c986dce-8e8d-4142-b541-d016d5aff764") + 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 []testservice.Application + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetApplications function +type GetApplicationsArgs struct { + // (optional) Filters the results based on the plugin type. + Type *string +} + +func (client *ClientImpl) GetCounters(ctx context.Context, args GetCountersArgs) (*[]testservice.TestRunCounterInstance, error) { + routeValues := make(map[string]string) + if args.TestRunId == nil || *args.TestRunId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"} + } + routeValues["testRunId"] = *args.TestRunId + + queryParams := url.Values{} + if args.GroupNames == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "groupNames"} + } + queryParams.Add("groupNames", *args.GroupNames) + if args.IncludeSummary != nil { + queryParams.Add("includeSummary", strconv.FormatBool(*args.IncludeSummary)) + } + locationId, _ := uuid.Parse("29265ea4-b5a5-4b2e-b054-47f5f6f00183") + 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 []testservice.TestRunCounterInstance + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCounters function +type GetCountersArgs struct { + // (required) The test run identifier + TestRunId *string + // (required) Comma separated names of counter groups, such as 'Application', 'Performance' and 'Throughput' + GroupNames *string + // (optional) + IncludeSummary *bool +} + +func (client *ClientImpl) GetCounterSamples(ctx context.Context, args GetCounterSamplesArgs) (*testservice.CounterSamplesResult, error) { + if args.CounterSampleQueryDetails == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CounterSampleQueryDetails"} + } + routeValues := make(map[string]string) + if args.TestRunId == nil || *args.TestRunId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"} + } + routeValues["testRunId"] = *args.TestRunId + + body, marshalErr := json.Marshal(*args.CounterSampleQueryDetails) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bad18480-7193-4518-992a-37289c5bb92d") + 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 testservice.CounterSamplesResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCounterSamples function +type GetCounterSamplesArgs struct { + // (required) + CounterSampleQueryDetails *azuredevops.VssJsonCollectionWrapper + // (required) The test run identifier + TestRunId *string +} + +func (client *ClientImpl) GetLoadTestResult(ctx context.Context, args GetLoadTestResultArgs) (*testservice.TestResults, error) { + routeValues := make(map[string]string) + if args.TestRunId == nil || *args.TestRunId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"} + } + routeValues["testRunId"] = *args.TestRunId + + locationId, _ := uuid.Parse("5ed69bd8-4557-4cec-9b75-1ad67d0c257b") + 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 testservice.TestResults + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetLoadTestResult function +type GetLoadTestResultArgs struct { + // (required) The test run identifier + TestRunId *string +} + +func (client *ClientImpl) GetLoadTestRunErrors(ctx context.Context, args GetLoadTestRunErrorsArgs) (*testservice.LoadTestErrors, error) { + routeValues := make(map[string]string) + if args.TestRunId == nil || *args.TestRunId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"} + } + routeValues["testRunId"] = *args.TestRunId + + queryParams := url.Values{} + if args.Type != nil { + queryParams.Add("type", *args.Type) + } + if args.SubType != nil { + queryParams.Add("subType", *args.SubType) + } + if args.Detailed != nil { + queryParams.Add("detailed", strconv.FormatBool(*args.Detailed)) + } + locationId, _ := uuid.Parse("b52025a7-3fb4-4283-8825-7079e75bd402") + 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 testservice.LoadTestErrors + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetLoadTestRunErrors function +type GetLoadTestRunErrorsArgs struct { + // (required) The test run identifier + TestRunId *string + // (optional) Filter for the particular type of errors. + Type *string + // (optional) Filter for a particular subtype of errors. You should not provide error subtype without error type. + SubType *string + // (optional) To include the details of test errors such as messagetext, request, stacktrace, testcasename, scenarioname, and lasterrordate. + Detailed *bool +} + +func (client *ClientImpl) GetPlugin(ctx context.Context, args GetPluginArgs) (*testservice.ApplicationType, error) { + routeValues := make(map[string]string) + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + + locationId, _ := uuid.Parse("7dcb0bb2-42d5-4729-9958-c0401d5e7693") + 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 testservice.ApplicationType + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPlugin function +type GetPluginArgs struct { + // (required) Currently ApplicationInsights is the only available plugin type. + Type *string +} + +func (client *ClientImpl) GetPlugins(ctx context.Context, args GetPluginsArgs) (*[]testservice.ApplicationType, error) { + locationId, _ := uuid.Parse("7dcb0bb2-42d5-4729-9958-c0401d5e7693") + 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 []testservice.ApplicationType + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPlugins function +type GetPluginsArgs struct { +} + +func (client *ClientImpl) GetStaticAgents(ctx context.Context, args GetStaticAgentsArgs) (interface{}, error) { + routeValues := make(map[string]string) + if args.AgentGroupId == nil || *args.AgentGroupId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AgentGroupId"} + } + routeValues["agentGroupId"] = *args.AgentGroupId + + queryParams := url.Values{} + if args.AgentName != nil { + queryParams.Add("agentName", *args.AgentName) + } + locationId, _ := uuid.Parse("87e4b63d-7142-4b50-801e-72ba9ff8ee9b") + 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 interface{} + err = client.Client.UnmarshalBody(resp, responseValue) + return responseValue, err +} + +// Arguments for the GetStaticAgents function +type GetStaticAgentsArgs struct { + // (required) The agent group identifier + AgentGroupId *string + // (optional) Name of the static agent + AgentName *string +} + +func (client *ClientImpl) GetTestDefinition(ctx context.Context, args GetTestDefinitionArgs) (*testservice.TestDefinition, error) { + routeValues := make(map[string]string) + if args.TestDefinitionId == nil || *args.TestDefinitionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestDefinitionId"} + } + routeValues["testDefinitionId"] = *args.TestDefinitionId + + locationId, _ := uuid.Parse("a8f9b135-f604-41ea-9d74-d9a5fd32fcd8") + 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 testservice.TestDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestDefinition function +type GetTestDefinitionArgs struct { + // (required) The test definition identifier + TestDefinitionId *string +} + +func (client *ClientImpl) GetTestDefinitions(ctx context.Context, args GetTestDefinitionsArgs) (*[]testservice.TestDefinitionBasic, error) { + queryParams := url.Values{} + if args.FromDate != nil { + queryParams.Add("fromDate", *args.FromDate) + } + if args.ToDate != nil { + queryParams.Add("toDate", *args.ToDate) + } + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + locationId, _ := uuid.Parse("a8f9b135-f604-41ea-9d74-d9a5fd32fcd8") + 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 []testservice.TestDefinitionBasic + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestDefinitions function +type GetTestDefinitionsArgs struct { + // (optional) Date after which test definitions were created + FromDate *string + // (optional) Date before which test definitions were crated + ToDate *string + // (optional) + Top *int +} + +func (client *ClientImpl) GetTestDrop(ctx context.Context, args GetTestDropArgs) (*testservice.TestDrop, error) { + routeValues := make(map[string]string) + if args.TestDropId == nil || *args.TestDropId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestDropId"} + } + routeValues["testDropId"] = *args.TestDropId + + locationId, _ := uuid.Parse("d89d0e08-505c-4357-96f6-9729311ce8ad") + 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 testservice.TestDrop + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestDrop function +type GetTestDropArgs struct { + // (required) The test drop identifier + TestDropId *string +} + +func (client *ClientImpl) GetTestRun(ctx context.Context, args GetTestRunArgs) (*testservice.TestRun, error) { + routeValues := make(map[string]string) + if args.TestRunId == nil || *args.TestRunId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"} + } + routeValues["testRunId"] = *args.TestRunId + + locationId, _ := uuid.Parse("b41a84ff-ff03-4ac1-b76e-e7ea25c92aba") + 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 testservice.TestRun + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRun function +type GetTestRunArgs struct { + // (required) Unique ID of the test run + TestRunId *string +} + +func (client *ClientImpl) GetTestRunMessages(ctx context.Context, args GetTestRunMessagesArgs) (*[]testservice.TestRunMessage, error) { + routeValues := make(map[string]string) + if args.TestRunId == nil || *args.TestRunId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"} + } + routeValues["testRunId"] = *args.TestRunId + + locationId, _ := uuid.Parse("2e7ba122-f522-4205-845b-2d270e59850a") + 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 []testservice.TestRunMessage + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRunMessages function +type GetTestRunMessagesArgs struct { + // (required) Id of the test run + TestRunId *string +} + +// Returns test runs based on the filter specified. Returns all runs of the tenant if there is no filter. +func (client *ClientImpl) GetTestRuns(ctx context.Context, args GetTestRunsArgs) (interface{}, error) { + queryParams := url.Values{} + if args.Name != nil { + queryParams.Add("name", *args.Name) + } + if args.RequestedBy != nil { + queryParams.Add("requestedBy", *args.RequestedBy) + } + if args.Status != nil { + queryParams.Add("status", *args.Status) + } + if args.RunType != nil { + queryParams.Add("runType", *args.RunType) + } + if args.FromDate != nil { + queryParams.Add("fromDate", *args.FromDate) + } + if args.ToDate != nil { + queryParams.Add("toDate", *args.ToDate) + } + if args.Detailed != nil { + queryParams.Add("detailed", strconv.FormatBool(*args.Detailed)) + } + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + if args.Runsourceidentifier != nil { + queryParams.Add("runsourceidentifier", *args.Runsourceidentifier) + } + if args.RetentionState != nil { + queryParams.Add("retentionState", *args.RetentionState) + } + locationId, _ := uuid.Parse("b41a84ff-ff03-4ac1-b76e-e7ea25c92aba") + 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 interface{} + err = client.Client.UnmarshalBody(resp, responseValue) + return responseValue, err +} + +// Arguments for the GetTestRuns function +type GetTestRunsArgs struct { + // (optional) Name for the test run. Names are not unique. Test runs with same name are assigned sequential rolling numbers. + Name *string + // (optional) Filter by the user who requested the test run. Here requestedBy should be the display name of the user. + RequestedBy *string + // (optional) Filter by the test run status. + Status *string + // (optional) Valid values include: null, one of TestRunType, or "*" + RunType *string + // (optional) Filter by the test runs that have been modified after the fromDate timestamp. + FromDate *string + // (optional) Filter by the test runs that have been modified before the toDate timestamp. + ToDate *string + // (optional) Include the detailed test run attributes. + Detailed *bool + // (optional) The maximum number of test runs to return. + Top *int + // (optional) + Runsourceidentifier *string + // (optional) + RetentionState *string +} + +func (client *ClientImpl) UpdateTestDefinition(ctx context.Context, args UpdateTestDefinitionArgs) (*testservice.TestDefinition, error) { + if args.TestDefinition == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestDefinition"} + } + body, marshalErr := json.Marshal(*args.TestDefinition) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a8f9b135-f604-41ea-9d74-d9a5fd32fcd8") + 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 testservice.TestDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestDefinition function +type UpdateTestDefinitionArgs struct { + // (required) + TestDefinition *testservice.TestDefinition +} + +func (client *ClientImpl) UpdateTestRun(ctx context.Context, args UpdateTestRunArgs) error { + if args.WebTestRun == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.WebTestRun"} + } + routeValues := make(map[string]string) + if args.TestRunId == nil || *args.TestRunId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestRunId"} + } + routeValues["testRunId"] = *args.TestRunId + + body, marshalErr := json.Marshal(*args.WebTestRun) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("b41a84ff-ff03-4ac1-b76e-e7ea25c92aba") + _, 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 UpdateTestRun function +type UpdateTestRunArgs struct { + // (required) + WebTestRun *testservice.TestRun + // (required) + TestRunId *string +} diff --git a/azuredevops/commerce/models.go b/azuredevops/commerce/models.go new file mode 100644 index 00000000..7a8a6ba9 --- /dev/null +++ b/azuredevops/commerce/models.go @@ -0,0 +1,856 @@ +// -------------------------------------------------------------------------------------------- +// 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 commerce + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" +) + +// The subscription account namespace. Denotes the 'category' of the account. +type AccountProviderNamespace string + +type accountProviderNamespaceValuesType struct { + VisualStudioOnline AccountProviderNamespace + AppInsights AccountProviderNamespace + Marketplace AccountProviderNamespace + OnPremise AccountProviderNamespace +} + +var AccountProviderNamespaceValues = accountProviderNamespaceValuesType{ + VisualStudioOnline: "visualStudioOnline", + AppInsights: "appInsights", + Marketplace: "marketplace", + OnPremise: "onPremise", +} + +// Encapsulates Azure specific plan structure, using a publisher defined publisher name, offer name, and plan name. These are all specified by the publisher and can vary from other meta data we store about the extension internally therefore need to be tracked separately for purposes of interacting with Azure. +type AzureOfferPlanDefinition struct { + // Determines whether or not this plan is visible to all users + IsPublic *bool `json:"isPublic,omitempty"` + // The meter id which identifies the offer meter this plan is associated with + MeterId *int `json:"meterId,omitempty"` + // The offer / product name as defined by the publisher in Azure + OfferId *string `json:"offerId,omitempty"` + // The offer / product name as defined by the publisher in Azure + OfferName *string `json:"offerName,omitempty"` + // The id of the plan, which is usually in the format "{publisher}:{offer}:{plan}" + PlanId *string `json:"planId,omitempty"` + // The plan name as defined by the publisher in Azure + PlanName *string `json:"planName,omitempty"` + // The version string which optionally identifies the version of the plan + PlanVersion *string `json:"planVersion,omitempty"` + // The publisher of the plan as defined by the publisher in Azure + Publisher *string `json:"publisher,omitempty"` + // get/set publisher name + PublisherName *string `json:"publisherName,omitempty"` + // The number of users associated with the plan as defined in Azure + Quantity *int `json:"quantity,omitempty"` +} + +// These are known offer types to VSTS. +type AzureOfferType string + +type azureOfferTypeValuesType struct { + None AzureOfferType + Standard AzureOfferType + Ea AzureOfferType + Msdn AzureOfferType + Csp AzureOfferType + Unsupported AzureOfferType +} + +var AzureOfferTypeValues = azureOfferTypeValuesType{ + None: "none", + Standard: "standard", + Ea: "ea", + Msdn: "msdn", + Csp: "csp", + Unsupported: "unsupported", +} + +// Represents an azure region, used by ibiza for linking accounts +type AzureRegion struct { + // Display Name of the azure region. Ex: North Central US. + DisplayName *string `json:"displayName,omitempty"` + // Unique Identifier + Id *string `json:"id,omitempty"` + // Region code of the azure region. Ex: NCUS. + RegionCode *string `json:"regionCode,omitempty"` +} + +// The responsible entity/method for billing. +type BillingProvider string + +type billingProviderValuesType struct { + SelfManaged BillingProvider + AzureStoreManaged BillingProvider +} + +var BillingProviderValues = billingProviderValuesType{ + SelfManaged: "selfManaged", + AzureStoreManaged: "azureStoreManaged", +} + +type ConnectedServer struct { + // Hosted AccountId associated with the connected server NOTE: As of S112, this is now the CollectionId. Not changed as this is exposed to client code. + AccountId *uuid.UUID `json:"accountId,omitempty"` + // Hosted AccountName associated with the connected server NOTE: As of S112, this is now the collection name. Not changed as this is exposed to client code. + AccountName *string `json:"accountName,omitempty"` + // Object used to create credentials to call from OnPrem to hosted service. + Authorization *ConnectedServerAuthorization `json:"authorization,omitempty"` + // OnPrem server id associated with the connected server + ServerId *uuid.UUID `json:"serverId,omitempty"` + // OnPrem server associated with the connected server + ServerName *string `json:"serverName,omitempty"` + // SpsUrl of the hosted account that the onrepm server has been connected to. + SpsUrl *string `json:"spsUrl,omitempty"` + // The id of the subscription used for purchase + SubscriptionId *uuid.UUID `json:"subscriptionId,omitempty"` + // OnPrem target host associated with the connected server. Typically the collection host id + TargetId *uuid.UUID `json:"targetId,omitempty"` + // OnPrem target associated with the connected server. + TargetName *string `json:"targetName,omitempty"` +} + +// Provides data necessary for authorizing the connecter server using OAuth 2.0 authentication flows. +type ConnectedServerAuthorization 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 agent. + ClientId *uuid.UUID `json:"clientId,omitempty"` + // Gets or sets the public key used to verify the identity of this connected server. + PublicKey *string `json:"publicKey,omitempty"` +} + +type IAzureSubscription struct { + AnniversaryDay *int `json:"anniversaryDay,omitempty"` + Created *azuredevops.Time `json:"created,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + Namespace *AccountProviderNamespace `json:"namespace,omitempty"` + OfferType *AzureOfferType `json:"offerType,omitempty"` + Source *SubscriptionSource `json:"source,omitempty"` + Status *SubscriptionStatus `json:"status,omitempty"` +} + +type ICommerceEvent struct { + // Billed quantity (prorated) passed to Azure commerce + BilledQuantity *float64 `json:"billedQuantity,omitempty"` + CollectionId *uuid.UUID `json:"collectionId,omitempty"` + CollectionName *string `json:"collectionName,omitempty"` + // Quantity for current billing cycle + CommittedQuantity *int `json:"committedQuantity,omitempty"` + // Quantity for next billing cycle + CurrentQuantity *int `json:"currentQuantity,omitempty"` + EffectiveDate *azuredevops.Time `json:"effectiveDate,omitempty"` + // Onpremise or hosted + Environment *string `json:"environment,omitempty"` + EventId *string `json:"eventId,omitempty"` + EventName *string `json:"eventName,omitempty"` + EventSource *string `json:"eventSource,omitempty"` + EventTime *azuredevops.Time `json:"eventTime,omitempty"` + GalleryId *string `json:"galleryId,omitempty"` + IncludedQuantity *int `json:"includedQuantity,omitempty"` + MaxQuantity *int `json:"maxQuantity,omitempty"` + MeterName *string `json:"meterName,omitempty"` + OrganizationId *uuid.UUID `json:"organizationId,omitempty"` + OrganizationName *string `json:"organizationName,omitempty"` + PreviousIncludedQuantity *int `json:"previousIncludedQuantity,omitempty"` + PreviousMaxQuantity *int `json:"previousMaxQuantity,omitempty"` + // Previous quantity in case of upgrade/downgrade + PreviousQuantity *int `json:"previousQuantity,omitempty"` + RenewalGroup *string `json:"renewalGroup,omitempty"` + ServiceIdentity *uuid.UUID `json:"serviceIdentity,omitempty"` + SubscriptionId *uuid.UUID `json:"subscriptionId,omitempty"` + TrialEndDate *azuredevops.Time `json:"trialEndDate,omitempty"` + TrialStartDate *azuredevops.Time `json:"trialStartDate,omitempty"` + UserIdentity *uuid.UUID `json:"userIdentity,omitempty"` + Version *string `json:"version,omitempty"` +} + +// Encapsulates the state of offer meter definitions and purchases +type ICommercePackage struct { + Configuration *map[string]string `json:"configuration,omitempty"` + OfferMeters *[]OfferMeter `json:"offerMeters,omitempty"` + OfferSubscriptions *[]OfferSubscription `json:"offerSubscriptions,omitempty"` +} + +// Information about a resource associated with a subscription. +type IOfferSubscription struct { + // Indicates whether users get auto assigned this license type duing first access. + AutoAssignOnAccess *bool `json:"autoAssignOnAccess,omitempty"` + // The azure subscription id + AzureSubscriptionId *uuid.UUID `json:"azureSubscriptionId,omitempty"` + // The azure subscription name + AzureSubscriptionName *string `json:"azureSubscriptionName,omitempty"` + // The azure subscription state + AzureSubscriptionState *SubscriptionStatus `json:"azureSubscriptionState,omitempty"` + // Quantity committed by the user, when resources is commitment based. + CommittedQuantity *int `json:"committedQuantity,omitempty"` + // A enumeration value indicating why the resource was disabled. + DisabledReason *ResourceStatusReason `json:"disabledReason,omitempty"` + // Uri pointing to user action on a disabled resource. It is based on DisabledReason value. + DisabledResourceActionLink *string `json:"disabledResourceActionLink,omitempty"` + // Quantity included for free. + IncludedQuantity *int `json:"includedQuantity,omitempty"` + // Returns true if paid billing is enabled on the resource. Returns false for non-azure subscriptions, disabled azure subscriptions or explicitly disabled by user + IsPaidBillingEnabled *bool `json:"isPaidBillingEnabled,omitempty"` + // Gets or sets a value indicating whether this instance is in preview. + IsPreview *bool `json:"isPreview,omitempty"` + // Gets the value indicating whether the puchase is canceled. + IsPurchaseCanceled *bool `json:"isPurchaseCanceled,omitempty"` + // Gets the value indicating whether current meter was purchased while the meter is still in trial + IsPurchasedDuringTrial *bool `json:"isPurchasedDuringTrial,omitempty"` + // Gets or sets a value indicating whether this instance is trial or preview. + IsTrialOrPreview *bool `json:"isTrialOrPreview,omitempty"` + // Returns true if resource is can be used otherwise returns false. DisabledReason can be used to identify why resource is disabled. + IsUseable *bool `json:"isUseable,omitempty"` + // Returns an integer representing the maximum quantity that can be billed for this resource. Any usage submitted over this number is automatically excluded from being sent to azure. + MaximumQuantity *int `json:"maximumQuantity,omitempty"` + // Gets the name of this resource. + OfferMeter *OfferMeter `json:"offerMeter,omitempty"` + // Gets the renewal group. + RenewalGroup *ResourceRenewalGroup `json:"renewalGroup,omitempty"` + // Returns a Date of UTC kind indicating when the next reset of quantities is going to happen. On this day at UTC 2:00 AM is when the reset will occur. + ResetDate *azuredevops.Time `json:"resetDate,omitempty"` + // Gets or sets the start date for this resource. First install date in any state. + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // Gets or sets the trial expiry date. + TrialExpiryDate *azuredevops.Time `json:"trialExpiryDate,omitempty"` +} + +// The subscription account. Add Sub Type and Owner email later. +type ISubscriptionAccount struct { + // Gets or sets the account host type. + AccountHostType *int `json:"accountHostType,omitempty"` + // Gets or sets the account identifier. Usually a guid. + AccountId *uuid.UUID `json:"accountId,omitempty"` + // Gets or sets the name of the account. + AccountName *string `json:"accountName,omitempty"` + // Gets or sets the account tenantId. + AccountTenantId *uuid.UUID `json:"accountTenantId,omitempty"` + // get or set purchase Error Reason + FailedPurchaseReason *PurchaseErrorReason `json:"failedPurchaseReason,omitempty"` + // Gets or sets the geo location. + GeoLocation *string `json:"geoLocation,omitempty"` + // Gets or sets a value indicating whether the calling user identity owns or is a PCA of the account. + IsAccountOwner *bool `json:"isAccountOwner,omitempty"` + // Gets or set the flag to enable purchase via subscription. + IsEligibleForPurchase *bool `json:"isEligibleForPurchase,omitempty"` + // get or set IsPrepaidFundSubscription + IsPrepaidFundSubscription *bool `json:"isPrepaidFundSubscription,omitempty"` + // get or set IsPricingPricingAvailable + IsPricingAvailable *bool `json:"isPricingAvailable,omitempty"` + // Gets or sets the subscription locale + Locale *string `json:"locale,omitempty"` + // Gets or sets the Offer Type of this subscription. A value of null means, this value has not been evaluated. + OfferType *AzureOfferType `json:"offerType,omitempty"` + // Gets or sets the subscription address country display name + RegionDisplayName *string `json:"regionDisplayName,omitempty"` + // Gets or sets the resource group. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // Gets or sets the azure resource name. + ResourceName *string `json:"resourceName,omitempty"` + // A dictionary of service urls, mapping the service owner to the service owner url + ServiceUrls *map[uuid.UUID]string `json:"serviceUrls,omitempty"` + // Gets or sets the subscription identifier. + SubscriptionId *uuid.UUID `json:"subscriptionId,omitempty"` + // Gets or sets the azure subscription name + SubscriptionName *string `json:"subscriptionName,omitempty"` + // get or set object id of subscruption admin + SubscriptionObjectId *uuid.UUID `json:"subscriptionObjectId,omitempty"` + // get or set subscription offer code + SubscriptionOfferCode *string `json:"subscriptionOfferCode,omitempty"` + // Gets or sets the subscription status. + SubscriptionStatus *SubscriptionStatus `json:"subscriptionStatus,omitempty"` + // get or set tenant id of subscription + SubscriptionTenantId *uuid.UUID `json:"subscriptionTenantId,omitempty"` +} + +// Information about a resource associated with a subscription. +type ISubscriptionResource struct { + // Quantity committed by the user, when resources is commitment based. + CommittedQuantity *int `json:"committedQuantity,omitempty"` + // A enumeration value indicating why the resource was disabled. + DisabledReason *ResourceStatusReason `json:"disabledReason,omitempty"` + // Uri pointing to user action on a disabled resource. It is based on DisabledReason value. + DisabledResourceActionLink *string `json:"disabledResourceActionLink,omitempty"` + // Quantity included for free. + IncludedQuantity *int `json:"includedQuantity,omitempty"` + // Returns true if paid billing is enabled on the resource. Returns false for non-azure subscriptions, disabled azure subscriptions or explicitly disabled by user + IsPaidBillingEnabled *bool `json:"isPaidBillingEnabled,omitempty"` + // Returns true if resource is can be used otherwise returns false. DisabledReason can be used to identify why resource is disabled. + IsUseable *bool `json:"isUseable,omitempty"` + // Returns an integer representing the maximum quantity that can be billed for this resource. Any usage submitted over this number is automatically excluded from being sent to azure. + MaximumQuantity *int `json:"maximumQuantity,omitempty"` + // Gets the name of this resource. + Name *ResourceName `json:"name,omitempty"` + // Returns a Date of UTC kind indicating when the next reset of quantities is going to happen. On this day at UTC 2:00 AM is when the reset will occur. + ResetDate *azuredevops.Time `json:"resetDate,omitempty"` +} + +// Represents the aggregated usage of a resource over a time span +type IUsageEventAggregate struct { + // Gets or sets end time of the aggregated value, exclusive + EndTime *azuredevops.Time `json:"endTime,omitempty"` + // Gets or sets resource that the aggregated value represents + Resource *ResourceName `json:"resource,omitempty"` + // Gets or sets start time of the aggregated value, inclusive + StartTime *azuredevops.Time `json:"startTime,omitempty"` + // Gets or sets quantity of the resource used from start time to end time + Value *int `json:"value,omitempty"` +} + +// The meter billing state. +type MeterBillingState string + +type meterBillingStateValuesType struct { + Free MeterBillingState + Paid MeterBillingState +} + +var MeterBillingStateValues = meterBillingStateValuesType{ + Free: "free", + Paid: "paid", +} + +// Defines meter categories. +type MeterCategory string + +type meterCategoryValuesType struct { + Legacy MeterCategory + Bundle MeterCategory + Extension MeterCategory +} + +var MeterCategoryValues = meterCategoryValuesType{ + Legacy: "legacy", + Bundle: "bundle", + Extension: "extension", +} + +// Describes the Renewal frequncy of a Meter. +type MeterRenewalFrequecy string + +type meterRenewalFrequecyValuesType struct { + None MeterRenewalFrequecy + Monthly MeterRenewalFrequecy + Annually MeterRenewalFrequecy +} + +var MeterRenewalFrequecyValues = meterRenewalFrequecyValuesType{ + None: "none", + Monthly: "monthly", + Annually: "annually", +} + +// The meter state. +type MeterState string + +type meterStateValuesType struct { + Registered MeterState + Active MeterState + Retired MeterState + Deleted MeterState +} + +var MeterStateValues = meterStateValuesType{ + Registered: "registered", + Active: "active", + Retired: "retired", + Deleted: "deleted", +} + +type MinimumRequiredServiceLevel string + +type minimumRequiredServiceLevelValuesType struct { + None MinimumRequiredServiceLevel + Express MinimumRequiredServiceLevel + Advanced MinimumRequiredServiceLevel + AdvancedPlus MinimumRequiredServiceLevel + Stakeholder MinimumRequiredServiceLevel +} + +var MinimumRequiredServiceLevelValues = minimumRequiredServiceLevelValuesType{ + // No service rights. The user cannot access the account + None: "none", + // Default or minimum service level + Express: "express", + // Premium service level - either by purchasing on the Azure portal or by purchasing the appropriate MSDN subscription + Advanced: "advanced", + // Only available to a specific set of MSDN Subscribers + AdvancedPlus: "advancedPlus", + // Stakeholder service level + Stakeholder: "stakeholder", +} + +type OfferMeter struct { + // Gets or sets the value of absolute maximum quantity for the resource + AbsoluteMaximumQuantity *int `json:"absoluteMaximumQuantity,omitempty"` + // Gets or sets the user assignment model. + AssignmentModel *OfferMeterAssignmentModel `json:"assignmentModel,omitempty"` + // Indicates whether users get auto assigned this license type duing first access. + AutoAssignOnAccess *bool `json:"autoAssignOnAccess,omitempty"` + // Gets or sets the responsible entity/method for billing. Determines how this meter is handled in the backend. + BillingEntity *BillingProvider `json:"billingEntity,omitempty"` + // Gets or sets the billing mode of the resource + BillingMode *ResourceBillingMode `json:"billingMode,omitempty"` + // Gets or sets the billing start date. If TrialDays + PreviewGraceDays > then, on 'BillingStartDate' it starts the preview Grace and/or trial period. + BillingStartDate *azuredevops.Time `json:"billingStartDate,omitempty"` + // Gets or sets the state of the billing. + BillingState *MeterBillingState `json:"billingState,omitempty"` + // Category. + Category *MeterCategory `json:"category,omitempty"` + // Quantity committed by the user, when resources is commitment based. + CommittedQuantity *int `json:"committedQuantity,omitempty"` + // Quantity used by the user, when resources is pay as you go or commitment based. + CurrentQuantity *int `json:"currentQuantity,omitempty"` + // Gets or sets the map of named quantity varied plans, plans can be purchased that vary only in the number of users included. Null if this offer meter does not support named fixed quantity plans. + FixedQuantityPlans *[]AzureOfferPlanDefinition `json:"fixedQuantityPlans,omitempty"` + // Gets or sets Gallery Id. + GalleryId *string `json:"galleryId,omitempty"` + // Gets or sets the Min license level the offer is free for. + IncludedInLicenseLevel *MinimumRequiredServiceLevel `json:"includedInLicenseLevel,omitempty"` + // Quantity included for free. + IncludedQuantity *int `json:"includedQuantity,omitempty"` + // Flag to identify whether the meter is First Party or Third Party based on BillingEntity If the BillingEntity is SelfManaged, the Meter is First Party otherwise its a Third Party Meter + IsFirstParty *bool `json:"isFirstParty,omitempty"` + // Gets or sets the value of maximum quantity for the resource + MaximumQuantity *int `json:"maximumQuantity,omitempty"` + // Meter Id. + MeterId *int `json:"meterId,omitempty"` + // Gets or sets the minimum required access level for the meter. + MinimumRequiredAccessLevel *MinimumRequiredServiceLevel `json:"minimumRequiredAccessLevel,omitempty"` + // Name of the resource + Name *string `json:"name,omitempty"` + // Gets or sets the offer scope. + OfferScope *OfferScope `json:"offerScope,omitempty"` + // Gets or sets the identifier representing this meter in commerce platform + PlatformMeterId *uuid.UUID `json:"platformMeterId,omitempty"` + // Gets or sets the preview grace days. + PreviewGraceDays *byte `json:"previewGraceDays,omitempty"` + // Gets or sets the Renewak Frequency. + RenewalFrequency *MeterRenewalFrequecy `json:"renewalFrequency,omitempty"` + // Gets or sets the status. + Status *MeterState `json:"status,omitempty"` + // Gets or sets the trial cycles. + TrialCycles *int `json:"trialCycles,omitempty"` + // Gets or sets the trial days. + TrialDays *byte `json:"trialDays,omitempty"` + // Measuring unit for this meter. + Unit *string `json:"unit,omitempty"` +} + +// The offer meter assignment model. +type OfferMeterAssignmentModel string + +type offerMeterAssignmentModelValuesType struct { + Explicit OfferMeterAssignmentModel + Implicit OfferMeterAssignmentModel +} + +var OfferMeterAssignmentModelValues = offerMeterAssignmentModelValuesType{ + // Users need to be explicitly assigned. + Explicit: "explicit", + // Users will be added automatically. All-or-nothing model. + Implicit: "implicit", +} + +type OfferMeterPrice struct { + // Currency code + CurrencyCode *string `json:"currencyCode,omitempty"` + // The meter Name which identifies the offer meter this plan is associated with + MeterName *string `json:"meterName,omitempty"` + // The Name of the plan, which is usually in the format "{publisher}:{offer}:{plan}" + PlanName *string `json:"planName,omitempty"` + // Plan Price + Price *float64 `json:"price,omitempty"` + // Plan Quantity + Quantity *float64 `json:"quantity,omitempty"` + // Region price is for + Region *string `json:"region,omitempty"` +} + +// The offer scope. +type OfferScope string + +type offerScopeValuesType struct { + Account OfferScope + User OfferScope + UserAccount OfferScope +} + +var OfferScopeValues = offerScopeValuesType{ + Account: "account", + User: "user", + UserAccount: "userAccount", +} + +// Information about a resource associated with a subscription. +type OfferSubscription struct { + // Indicates whether users get auto assigned this license type duing first access. + AutoAssignOnAccess *bool `json:"autoAssignOnAccess,omitempty"` + // The azure subscription id + AzureSubscriptionId *uuid.UUID `json:"azureSubscriptionId,omitempty"` + // The azure subscription name + AzureSubscriptionName *string `json:"azureSubscriptionName,omitempty"` + // The azure subscription state + AzureSubscriptionState *SubscriptionStatus `json:"azureSubscriptionState,omitempty"` + // Quantity committed by the user, when resources is commitment based. + CommittedQuantity *int `json:"committedQuantity,omitempty"` + // A enumeration value indicating why the resource was disabled. + DisabledReason *ResourceStatusReason `json:"disabledReason,omitempty"` + // Uri pointing to user action on a disabled resource. It is based on DisabledReason value. + DisabledResourceActionLink *string `json:"disabledResourceActionLink,omitempty"` + // Quantity included for free. + IncludedQuantity *int `json:"includedQuantity,omitempty"` + // Returns true if paid billing is enabled on the resource. Returns false for non-azure subscriptions, disabled azure subscriptions or explicitly disabled by user + IsPaidBillingEnabled *bool `json:"isPaidBillingEnabled,omitempty"` + // Gets or sets a value indicating whether this instance is in preview. + IsPreview *bool `json:"isPreview,omitempty"` + // Gets the value indicating whether the puchase is canceled. + IsPurchaseCanceled *bool `json:"isPurchaseCanceled,omitempty"` + // Gets the value indicating whether current meter was purchased while the meter is still in trial + IsPurchasedDuringTrial *bool `json:"isPurchasedDuringTrial,omitempty"` + // Gets or sets a value indicating whether this instance is trial or preview. + IsTrialOrPreview *bool `json:"isTrialOrPreview,omitempty"` + // Returns true if resource is can be used otherwise returns false. DisabledReason can be used to identify why resource is disabled. + IsUseable *bool `json:"isUseable,omitempty"` + // Returns an integer representing the maximum quantity that can be billed for this resource. Any usage submitted over this number is automatically excluded from being sent to azure. + MaximumQuantity *int `json:"maximumQuantity,omitempty"` + // Gets or sets the name of this resource. + OfferMeter *OfferMeter `json:"offerMeter,omitempty"` + // The unique identifier of this offer subscription + OfferSubscriptionId *uuid.UUID `json:"offerSubscriptionId,omitempty"` + // Gets the renewal group. + RenewalGroup *ResourceRenewalGroup `json:"renewalGroup,omitempty"` + // Returns a Date of UTC kind indicating when the next reset of quantities is going to happen. On this day at UTC 2:00 AM is when the reset will occur. + ResetDate *azuredevops.Time `json:"resetDate,omitempty"` + // Gets or sets the start date for this resource. First install date in any state. + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // Gets or sets the trial expiry date. + TrialExpiryDate *azuredevops.Time `json:"trialExpiryDate,omitempty"` +} + +// The Purchasable offer meter. +type PurchasableOfferMeter struct { + // Currency code for meter pricing + CurrencyCode *string `json:"currencyCode,omitempty"` + // Gets or sets the estimated renewal date. + EstimatedRenewalDate *azuredevops.Time `json:"estimatedRenewalDate,omitempty"` + // Locale for azure subscription + LocaleCode *string `json:"localeCode,omitempty"` + // Gets or sets the meter pricing (GraduatedPrice) + MeterPricing *[]azuredevops.KeyValuePair `json:"meterPricing,omitempty"` + // Gets or sets the offer meter definition. + OfferMeterDefinition *OfferMeter `json:"offerMeterDefinition,omitempty"` +} + +type PurchaseErrorReason string + +type purchaseErrorReasonValuesType struct { + None PurchaseErrorReason + MonetaryLimitSet PurchaseErrorReason + InvalidOfferCode PurchaseErrorReason + NotAdminOrCoAdmin PurchaseErrorReason + InvalidRegionPurchase PurchaseErrorReason + PaymentInstrumentNotCreditCard PurchaseErrorReason + InvalidOfferRegion PurchaseErrorReason + UnsupportedSubscription PurchaseErrorReason + DisabledSubscription PurchaseErrorReason + InvalidUser PurchaseErrorReason + NotSubscriptionUser PurchaseErrorReason + UnsupportedSubscriptionCsp PurchaseErrorReason + TemporarySpendingLimit PurchaseErrorReason + AzureServiceError PurchaseErrorReason +} + +var PurchaseErrorReasonValues = purchaseErrorReasonValuesType{ + None: "none", + MonetaryLimitSet: "monetaryLimitSet", + InvalidOfferCode: "invalidOfferCode", + NotAdminOrCoAdmin: "notAdminOrCoAdmin", + InvalidRegionPurchase: "invalidRegionPurchase", + PaymentInstrumentNotCreditCard: "paymentInstrumentNotCreditCard", + InvalidOfferRegion: "invalidOfferRegion", + UnsupportedSubscription: "unsupportedSubscription", + DisabledSubscription: "disabledSubscription", + InvalidUser: "invalidUser", + NotSubscriptionUser: "notSubscriptionUser", + UnsupportedSubscriptionCsp: "unsupportedSubscriptionCsp", + TemporarySpendingLimit: "temporarySpendingLimit", + AzureServiceError: "azureServiceError", +} + +// Represents a purchase request for requesting purchase by a user who does not have authorization to purchase. +type PurchaseRequest struct { + // Name of the offer meter + OfferMeterName *string `json:"offerMeterName,omitempty"` + // Quantity for purchase + Quantity *int `json:"quantity,omitempty"` + // Reason for the purchase request + Reason *string `json:"reason,omitempty"` + // Response for this purchase request by the approver + Response *PurchaseRequestResponse `json:"response,omitempty"` +} + +// Type of purchase request response +type PurchaseRequestResponse string + +type purchaseRequestResponseValuesType struct { + None PurchaseRequestResponse + Approved PurchaseRequestResponse + Denied PurchaseRequestResponse +} + +var PurchaseRequestResponseValues = purchaseRequestResponseValuesType{ + None: "none", + Approved: "approved", + Denied: "denied", +} + +// The resource billing mode. +type ResourceBillingMode string + +type resourceBillingModeValuesType struct { + Committment ResourceBillingMode + PayAsYouGo ResourceBillingMode +} + +var ResourceBillingModeValues = resourceBillingModeValuesType{ + Committment: "committment", + PayAsYouGo: "payAsYouGo", +} + +// Various metered resources in VSTS +type ResourceName string + +type resourceNameValuesType struct { + StandardLicense ResourceName + AdvancedLicense ResourceName + ProfessionalLicense ResourceName + Build ResourceName + LoadTest ResourceName + PremiumBuildAgent ResourceName + PrivateOtherBuildAgent ResourceName + PrivateAzureBuildAgent ResourceName + Artifacts ResourceName + MsHostedCICDforMacOS ResourceName + MsHostedCICDforWindowsLinux ResourceName +} + +var ResourceNameValues = resourceNameValuesType{ + StandardLicense: "standardLicense", + AdvancedLicense: "advancedLicense", + ProfessionalLicense: "professionalLicense", + Build: "build", + LoadTest: "loadTest", + PremiumBuildAgent: "premiumBuildAgent", + PrivateOtherBuildAgent: "privateOtherBuildAgent", + PrivateAzureBuildAgent: "privateAzureBuildAgent", + Artifacts: "artifacts", + MsHostedCICDforMacOS: "msHostedCICDforMacOS", + MsHostedCICDforWindowsLinux: "msHostedCICDforWindowsLinux", +} + +// The resource renewal group. +type ResourceRenewalGroup string + +type resourceRenewalGroupValuesType struct { + Monthly ResourceRenewalGroup + Jan ResourceRenewalGroup + Feb ResourceRenewalGroup + Mar ResourceRenewalGroup + Apr ResourceRenewalGroup + May ResourceRenewalGroup + Jun ResourceRenewalGroup + Jul ResourceRenewalGroup + Aug ResourceRenewalGroup + Sep ResourceRenewalGroup + Oct ResourceRenewalGroup + Nov ResourceRenewalGroup + Dec ResourceRenewalGroup +} + +var ResourceRenewalGroupValues = resourceRenewalGroupValuesType{ + Monthly: "monthly", + Jan: "jan", + Feb: "feb", + Mar: "mar", + Apr: "apr", + May: "may", + Jun: "jun", + Jul: "jul", + Aug: "aug", + Sep: "sep", + Oct: "oct", + Nov: "nov", + Dec: "dec", +} + +// [Flags] Reason for disabled resource. +type ResourceStatusReason string + +type resourceStatusReasonValuesType struct { + None ResourceStatusReason + NoAzureSubscription ResourceStatusReason + NoIncludedQuantityLeft ResourceStatusReason + SubscriptionDisabled ResourceStatusReason + PaidBillingDisabled ResourceStatusReason + MaximumQuantityReached ResourceStatusReason +} + +var ResourceStatusReasonValues = resourceStatusReasonValuesType{ + None: "none", + NoAzureSubscription: "noAzureSubscription", + NoIncludedQuantityLeft: "noIncludedQuantityLeft", + SubscriptionDisabled: "subscriptionDisabled", + PaidBillingDisabled: "paidBillingDisabled", + MaximumQuantityReached: "maximumQuantityReached", +} + +// The subscription account. Add Sub Type and Owner email later. +type SubscriptionAccount struct { + // Gets or sets the account host type. + AccountHostType *int `json:"accountHostType,omitempty"` + // Gets or sets the account identifier. Usually a guid. + AccountId *uuid.UUID `json:"accountId,omitempty"` + // Gets or sets the name of the account. + AccountName *string `json:"accountName,omitempty"` + // Gets or sets the account tenantId. + AccountTenantId *uuid.UUID `json:"accountTenantId,omitempty"` + // Purchase Error Reason + FailedPurchaseReason *PurchaseErrorReason `json:"failedPurchaseReason,omitempty"` + // Gets or sets the geo location. + GeoLocation *string `json:"geoLocation,omitempty"` + // Gets or sets a value indicating whether the calling user identity owns or is a PCA of the account. + IsAccountOwner *bool `json:"isAccountOwner,omitempty"` + // Gets or set the flag to enable purchase via subscription. + IsEligibleForPurchase *bool `json:"isEligibleForPurchase,omitempty"` + // get or set IsPrepaidFundSubscription + IsPrepaidFundSubscription *bool `json:"isPrepaidFundSubscription,omitempty"` + // get or set IsPricingPricingAvailable + IsPricingAvailable *bool `json:"isPricingAvailable,omitempty"` + // Gets or sets the subscription address country code + Locale *string `json:"locale,omitempty"` + // Gets or sets the Offer Type of this subscription. + OfferType *AzureOfferType `json:"offerType,omitempty"` + // Gets or sets the subscription address country display name + RegionDisplayName *string `json:"regionDisplayName,omitempty"` + // Gets or sets the resource group. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // Gets or sets the azure resource name. + ResourceName *string `json:"resourceName,omitempty"` + // A dictionary of service urls, mapping the service owner to the service owner url + ServiceUrls *map[uuid.UUID]string `json:"serviceUrls,omitempty"` + // Gets or sets the subscription identifier. + SubscriptionId *uuid.UUID `json:"subscriptionId,omitempty"` + // Gets or sets the azure subscription name + SubscriptionName *string `json:"subscriptionName,omitempty"` + // object id of subscription admin + SubscriptionObjectId *uuid.UUID `json:"subscriptionObjectId,omitempty"` + // get or set subscription offer code + SubscriptionOfferCode *string `json:"subscriptionOfferCode,omitempty"` + // Gets or sets the subscription status. + SubscriptionStatus *SubscriptionStatus `json:"subscriptionStatus,omitempty"` + // tenant id of subscription + SubscriptionTenantId *uuid.UUID `json:"subscriptionTenantId,omitempty"` +} + +// Information about a resource associated with a subscription. +type SubscriptionResource struct { + // Quantity committed by the user, when resources is commitment based. + CommittedQuantity *int `json:"committedQuantity,omitempty"` + // A enumeration value indicating why the resource was disabled. + DisabledReason *ResourceStatusReason `json:"disabledReason,omitempty"` + // Uri pointing to user action on a disabled resource. It is based on DisabledReason value. + DisabledResourceActionLink *string `json:"disabledResourceActionLink,omitempty"` + // Quantity included for free. + IncludedQuantity *int `json:"includedQuantity,omitempty"` + // Returns true if paid billing is enabled on the resource. Returns false for non-azure subscriptions, disabled azure subscriptions or explicitly disabled by user + IsPaidBillingEnabled *bool `json:"isPaidBillingEnabled,omitempty"` + // Returns true if resource is can be used otherwise returns false. DisabledReason can be used to identify why resource is disabled. + IsUseable *bool `json:"isUseable,omitempty"` + // Returns an integer representing the maximum quantity that can be billed for this resource. Any usage submitted over this number is automatically excluded from being sent to azure. + MaximumQuantity *int `json:"maximumQuantity,omitempty"` + // Gets or sets the name of this resource. + Name *ResourceName `json:"name,omitempty"` + // Returns a Date of UTC kind indicating when the next reset of quantities is going to happen. On this day at UTC 2:00 AM is when the reset will occur. + ResetDate *azuredevops.Time `json:"resetDate,omitempty"` +} + +type SubscriptionSource string + +type subscriptionSourceValuesType struct { + Normal SubscriptionSource + EnterpriseAgreement SubscriptionSource + Internal SubscriptionSource + Unknown SubscriptionSource + FreeTier SubscriptionSource +} + +var SubscriptionSourceValues = subscriptionSourceValuesType{ + Normal: "normal", + EnterpriseAgreement: "enterpriseAgreement", + Internal: "internal", + Unknown: "unknown", + FreeTier: "freeTier", +} + +// Azure subscription status +type SubscriptionStatus string + +type subscriptionStatusValuesType struct { + Unknown SubscriptionStatus + Active SubscriptionStatus + Disabled SubscriptionStatus + Deleted SubscriptionStatus + Unregistered SubscriptionStatus +} + +var SubscriptionStatusValues = subscriptionStatusValuesType{ + Unknown: "unknown", + Active: "active", + Disabled: "disabled", + Deleted: "deleted", + Unregistered: "unregistered", +} + +// Class that represents common set of properties for a raw usage event reported by TFS services. +type UsageEvent struct { + // Gets or sets account id of the event. Note: This is for backward compat with BI. + AccountId *uuid.UUID `json:"accountId,omitempty"` + // Account name associated with the usage event + AccountName *string `json:"accountName,omitempty"` + // User GUID associated with the usage event + AssociatedUser *uuid.UUID `json:"associatedUser,omitempty"` + // Timestamp when this billing event is billable + BillableDate *azuredevops.Time `json:"billableDate,omitempty"` + // Unique event identifier + EventId *string `json:"eventId,omitempty"` + // Receiving Timestamp of the billing event by metering service + EventTimestamp *azuredevops.Time `json:"eventTimestamp,omitempty"` + // Gets or sets the event unique identifier. + EventUniqueId *uuid.UUID `json:"eventUniqueId,omitempty"` + // Meter Id. + MeterName *string `json:"meterName,omitempty"` + // Partition id of the account + PartitionId *int `json:"partitionId,omitempty"` + // Quantity of the usage event + Quantity *int `json:"quantity,omitempty"` + // Gets or sets the billing mode for the resource involved in the usage + ResourceBillingMode *ResourceBillingMode `json:"resourceBillingMode,omitempty"` + // Service context GUID associated with the usage event + ServiceIdentity *uuid.UUID `json:"serviceIdentity,omitempty"` + // Gets or sets subscription anniversary day of the subscription + SubscriptionAnniversaryDay *int `json:"subscriptionAnniversaryDay,omitempty"` + // Gets or sets subscription guid of the associated account of the event + SubscriptionId *uuid.UUID `json:"subscriptionId,omitempty"` +} diff --git a/azuredevops/connection.go b/azuredevops/connection.go new file mode 100644 index 00000000..8b90ee40 --- /dev/null +++ b/azuredevops/connection.go @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azuredevops + +import ( + "context" + "encoding/base64" + "github.com/google/uuid" + "strings" + "sync" + "time" +) + +// 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 + 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/azuredevops/contributions/client.go b/azuredevops/contributions/client.go new file mode 100644 index 00000000..0f7df624 --- /dev/null +++ b/azuredevops/contributions/client.go @@ -0,0 +1,185 @@ +// -------------------------------------------------------------------------------------------- +// 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 contributions + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("8477aec9-a4c7-4bd4-a456-ba4c53c989cb") + +type Client interface { + // [Preview API] + GetInstalledExtensionByName(context.Context, GetInstalledExtensionByNameArgs) (*InstalledExtension, error) + // [Preview API] + GetInstalledExtensions(context.Context, GetInstalledExtensionsArgs) (*[]InstalledExtension, error) + // [Preview API] Query for contribution nodes and provider details according the parameters in the passed in query object. + QueryContributionNodes(context.Context, QueryContributionNodesArgs) (*ContributionNodeQueryResult, error) + // [Preview API] + QueryDataProviders(context.Context, QueryDataProvidersArgs) (*DataProviderResult, 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) GetInstalledExtensionByName(ctx context.Context, args GetInstalledExtensionByNameArgs) (*InstalledExtension, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.AssetTypes != nil { + listAsString := strings.Join((*args.AssetTypes)[:], ":") + queryParams.Add("assetTypes", listAsString) + } + locationId, _ := uuid.Parse("3e2f6668-0798-4dcb-b592-bfe2fa57fde2") + 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 InstalledExtension + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetInstalledExtensionByName function +type GetInstalledExtensionByNameArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (optional) + AssetTypes *[]string +} + +// [Preview API] +func (client *ClientImpl) GetInstalledExtensions(ctx context.Context, args GetInstalledExtensionsArgs) (*[]InstalledExtension, error) { + queryParams := url.Values{} + if args.ContributionIds != nil { + listAsString := strings.Join((*args.ContributionIds)[:], ";") + queryParams.Add("contributionIds", listAsString) + } + if args.IncludeDisabledApps != nil { + queryParams.Add("includeDisabledApps", strconv.FormatBool(*args.IncludeDisabledApps)) + } + if args.AssetTypes != nil { + listAsString := strings.Join((*args.AssetTypes)[:], ":") + queryParams.Add("assetTypes", listAsString) + } + locationId, _ := uuid.Parse("2648442b-fd63-4b9a-902f-0c913510f139") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []InstalledExtension + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetInstalledExtensions function +type GetInstalledExtensionsArgs struct { + // (optional) + ContributionIds *[]string + // (optional) + IncludeDisabledApps *bool + // (optional) + AssetTypes *[]string +} + +// [Preview API] Query for contribution nodes and provider details according the parameters in the passed in query object. +func (client *ClientImpl) QueryContributionNodes(ctx context.Context, args QueryContributionNodesArgs) (*ContributionNodeQueryResult, error) { + if args.Query == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"} + } + body, marshalErr := json.Marshal(*args.Query) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("db7f2146-2309-4cee-b39c-c767777a1c55") + 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 ContributionNodeQueryResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryContributionNodes function +type QueryContributionNodesArgs struct { + // (required) + Query *ContributionNodeQuery +} + +// [Preview API] +func (client *ClientImpl) QueryDataProviders(ctx context.Context, args QueryDataProvidersArgs) (*DataProviderResult, error) { + if args.Query == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"} + } + routeValues := make(map[string]string) + if args.ScopeName != nil && *args.ScopeName != "" { + routeValues["scopeName"] = *args.ScopeName + } + if args.ScopeValue != nil && *args.ScopeValue != "" { + routeValues["scopeValue"] = *args.ScopeValue + } + + body, marshalErr := json.Marshal(*args.Query) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("738368db-35ee-4b85-9f94-77ed34af2b0d") + 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 DataProviderResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryDataProviders function +type QueryDataProvidersArgs struct { + // (required) + Query *DataProviderQuery + // (optional) + ScopeName *string + // (optional) + ScopeValue *string +} diff --git a/azuredevops/contributions/models.go b/azuredevops/contributions/models.go new file mode 100644 index 00000000..9ed23127 --- /dev/null +++ b/azuredevops/contributions/models.go @@ -0,0 +1,503 @@ +// -------------------------------------------------------------------------------------------- +// 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 contributions + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/gallery" +) + +// Representation of a ContributionNode that can be used for serialized to clients. +type ClientContribution struct { + // Description of the contribution/type + Description *string `json:"description,omitempty"` + // Fully qualified identifier of the contribution/type + Id *string `json:"id,omitempty"` + // Includes is a set of contributions that should have this contribution included in their targets list. + Includes *[]string `json:"includes,omitempty"` + // Properties/attributes of this contribution + Properties interface{} `json:"properties,omitempty"` + // The ids of the contribution(s) that this contribution targets. (parent contributions) + Targets *[]string `json:"targets,omitempty"` + // Id of the Contribution Type + Type *string `json:"type,omitempty"` +} + +// Representation of a ContributionNode that can be used for serialized to clients. +type ClientContributionNode struct { + // List of ids for contributions which are children to the current contribution. + Children *[]string `json:"children,omitempty"` + // Contribution associated with this node. + Contribution *ClientContribution `json:"contribution,omitempty"` + // List of ids for contributions which are parents to the current contribution. + Parents *[]string `json:"parents,omitempty"` +} + +type ClientContributionProviderDetails struct { + // Friendly name for the provider. + DisplayName *string `json:"displayName,omitempty"` + // Unique identifier for this provider. The provider name can be used to cache the contribution data and refer back to it when looking for changes + Name *string `json:"name,omitempty"` + // Properties associated with the provider + Properties *map[string]string `json:"properties,omitempty"` + // Version of contributions associated with this contribution provider. + Version *string `json:"version,omitempty"` +} + +// A client data provider are the details needed to make the data provider request from the client. +type ClientDataProviderQuery struct { + // Contextual information to pass to the data providers + Context *DataProviderContext `json:"context,omitempty"` + // The contribution ids of the data providers to resolve + ContributionIds *[]string `json:"contributionIds,omitempty"` + // The Id of the service instance type that should be communicated with in order to resolve the data providers from the client given the query values. + QueryServiceInstanceType *uuid.UUID `json:"queryServiceInstanceType,omitempty"` +} + +// An individual contribution made by an extension +type Contribution struct { + // Description of the contribution/type + Description *string `json:"description,omitempty"` + // Fully qualified identifier of the contribution/type + Id *string `json:"id,omitempty"` + // VisibleTo can be used to restrict whom can reference a given contribution/type. This value should be a list of publishers or extensions access is restricted too. Examples: "ms" - Means only the "ms" publisher can reference this. "ms.vss-web" - Means only the "vss-web" extension from the "ms" publisher can reference this. + VisibleTo *[]string `json:"visibleTo,omitempty"` + // List of constraints (filters) that should be applied to the availability of this contribution + Constraints *[]ContributionConstraint `json:"constraints,omitempty"` + // Includes is a set of contributions that should have this contribution included in their targets list. + Includes *[]string `json:"includes,omitempty"` + // Properties/attributes of this contribution + Properties interface{} `json:"properties,omitempty"` + // List of demanded claims in order for the user to see this contribution (like anonymous, public, member...). + RestrictedTo *[]string `json:"restrictedTo,omitempty"` + // The ids of the contribution(s) that this contribution targets. (parent contributions) + Targets *[]string `json:"targets,omitempty"` + // Id of the Contribution Type + Type *string `json:"type,omitempty"` +} + +// Base class shared by contributions and contribution types +type ContributionBase struct { + // Description of the contribution/type + Description *string `json:"description,omitempty"` + // Fully qualified identifier of the contribution/type + Id *string `json:"id,omitempty"` + // VisibleTo can be used to restrict whom can reference a given contribution/type. This value should be a list of publishers or extensions access is restricted too. Examples: "ms" - Means only the "ms" publisher can reference this. "ms.vss-web" - Means only the "vss-web" extension from the "ms" publisher can reference this. + VisibleTo *[]string `json:"visibleTo,omitempty"` +} + +// Specifies a constraint that can be used to dynamically include/exclude a given contribution +type ContributionConstraint struct { + // An optional property that can be specified to group constraints together. All constraints within a group are AND'd together (all must be evaluate to True in order for the contribution to be included). Different groups of constraints are OR'd (only one group needs to evaluate to True for the contribution to be included). + Group *int `json:"group,omitempty"` + // Fully qualified identifier of a shared constraint + Id *string `json:"id,omitempty"` + // If true, negate the result of the filter (include the contribution if the applied filter returns false instead of true) + Inverse *bool `json:"inverse,omitempty"` + // Name of the IContributionFilter plugin + Name *string `json:"name,omitempty"` + // Properties that are fed to the contribution filter class + Properties interface{} `json:"properties,omitempty"` + // Constraints can be optionally be applied to one or more of the relationships defined in the contribution. If no relationships are defined then all relationships are associated with the constraint. This means the default behaviour will eliminate the contribution from the tree completely if the constraint is applied. + Relationships *[]string `json:"relationships,omitempty"` +} + +// Represents different ways of including contributions based on licensing +type ContributionLicensingBehaviorType string + +type contributionLicensingBehaviorTypeValuesType struct { + OnlyIfLicensed ContributionLicensingBehaviorType + OnlyIfUnlicensed ContributionLicensingBehaviorType + AlwaysInclude ContributionLicensingBehaviorType +} + +var ContributionLicensingBehaviorTypeValues = contributionLicensingBehaviorTypeValuesType{ + // Default value - only include the contribution if the user is licensed for the extension + OnlyIfLicensed: "onlyIfLicensed", + // Only include the contribution if the user is NOT licensed for the extension + OnlyIfUnlicensed: "onlyIfUnlicensed", + // Always include the contribution regardless of whether or not the user is licensed for the extension + AlwaysInclude: "alwaysInclude", +} + +// A query that can be issued for contribution nodes +type ContributionNodeQuery struct { + // The contribution ids of the nodes to find. + ContributionIds *[]string `json:"contributionIds,omitempty"` + // Contextual information that can be leveraged by contribution constraints + DataProviderContext *DataProviderContext `json:"dataProviderContext,omitempty"` + // Indicator if contribution provider details should be included in the result. + IncludeProviderDetails *bool `json:"includeProviderDetails,omitempty"` + // Query options tpo be used when fetching ContributionNodes + QueryOptions *ContributionQueryOptions `json:"queryOptions,omitempty"` +} + +// Result of a contribution node query. Wraps the resulting contribution nodes and provider details. +type ContributionNodeQueryResult struct { + // Map of contribution ids to corresponding node. + Nodes *map[string]ClientContributionNode `json:"nodes,omitempty"` + // Map of provider ids to the corresponding provider details object. + ProviderDetails *map[string]ClientContributionProviderDetails `json:"providerDetails,omitempty"` +} + +// Description about a property of a contribution type +type ContributionPropertyDescription struct { + // Description of the property + Description *string `json:"description,omitempty"` + // Name of the property + Name *string `json:"name,omitempty"` + // True if this property is required + Required *bool `json:"required,omitempty"` + // The type of value used for this property + Type *ContributionPropertyType `json:"type,omitempty"` +} + +// [Flags] The type of value used for a property +type ContributionPropertyType string + +type contributionPropertyTypeValuesType struct { + Unknown ContributionPropertyType + String ContributionPropertyType + Uri ContributionPropertyType + Guid ContributionPropertyType + Boolean ContributionPropertyType + Integer ContributionPropertyType + Double ContributionPropertyType + DateTime ContributionPropertyType + Dictionary ContributionPropertyType + Array ContributionPropertyType + Object ContributionPropertyType +} + +var ContributionPropertyTypeValues = contributionPropertyTypeValuesType{ + // Contribution type is unknown (value may be anything) + Unknown: "unknown", + // Value is a string + String: "string", + // Value is a Uri + Uri: "uri", + // Value is a GUID + Guid: "guid", + // Value is True or False + Boolean: "boolean", + // Value is an integer + Integer: "integer", + // Value is a double + Double: "double", + // Value is a DateTime object + DateTime: "dateTime", + // Value is a generic Dictionary/JObject/property bag + Dictionary: "dictionary", + // Value is an array + Array: "array", + // Value is an arbitrary/custom object + Object: "object", +} + +// [Flags] Options that control the contributions to include in a query +type ContributionQueryOptions string + +type contributionQueryOptionsValuesType struct { + None ContributionQueryOptions + IncludeSelf ContributionQueryOptions + IncludeChildren ContributionQueryOptions + IncludeSubTree ContributionQueryOptions + IncludeAll ContributionQueryOptions + IgnoreConstraints ContributionQueryOptions +} + +var ContributionQueryOptionsValues = contributionQueryOptionsValuesType{ + None: "none", + // Include the direct contributions that have the ids queried. + IncludeSelf: "includeSelf", + // Include the contributions that directly target the contributions queried. + IncludeChildren: "includeChildren", + // Include the contributions from the entire sub-tree targeting the contributions queried. + IncludeSubTree: "includeSubTree", + // Include the contribution being queried as well as all contributions that target them recursively. + IncludeAll: "includeAll", + // Some callers may want the entire tree back without constraint evaluation being performed. + IgnoreConstraints: "ignoreConstraints", +} + +// A contribution type, given by a json schema +type ContributionType struct { + // Description of the contribution/type + Description *string `json:"description,omitempty"` + // Fully qualified identifier of the contribution/type + Id *string `json:"id,omitempty"` + // VisibleTo can be used to restrict whom can reference a given contribution/type. This value should be a list of publishers or extensions access is restricted too. Examples: "ms" - Means only the "ms" publisher can reference this. "ms.vss-web" - Means only the "vss-web" extension from the "ms" publisher can reference this. + VisibleTo *[]string `json:"visibleTo,omitempty"` + // Controls whether or not contributions of this type have the type indexed for queries. This allows clients to find all extensions that have a contribution of this type. NOTE: Only TrustedPartners are allowed to specify indexed contribution types. + Indexed *bool `json:"indexed,omitempty"` + // Friendly name of the contribution/type + Name *string `json:"name,omitempty"` + // Describes the allowed properties for this contribution type + Properties *map[string]ContributionPropertyDescription `json:"properties,omitempty"` +} + +// Contextual information that data providers can examine when populating their data +type DataProviderContext struct { + // Generic property bag that contains context-specific properties that data providers can use when populating their data dictionary + Properties *map[string]interface{} `json:"properties,omitempty"` +} + +type DataProviderExceptionDetails struct { + // The type of the exception that was thrown. + ExceptionType *string `json:"exceptionType,omitempty"` + // Message that is associated with the exception. + Message *string `json:"message,omitempty"` + // The StackTrace from the exception turned into a string. + StackTrace *string `json:"stackTrace,omitempty"` +} + +// A query that can be issued for data provider data +type DataProviderQuery struct { + // Contextual information to pass to the data providers + Context *DataProviderContext `json:"context,omitempty"` + // The contribution ids of the data providers to resolve + ContributionIds *[]string `json:"contributionIds,omitempty"` +} + +// Result structure from calls to GetDataProviderData +type DataProviderResult struct { + // This is the set of data providers that were requested, but either they were defined as client providers, or as remote providers that failed and may be retried by the client. + ClientProviders *map[string]ClientDataProviderQuery `json:"clientProviders,omitempty"` + // Property bag of data keyed off of the data provider contribution id + Data *map[string]interface{} `json:"data,omitempty"` + // Set of exceptions that occurred resolving the data providers. + Exceptions *map[string]DataProviderExceptionDetails `json:"exceptions,omitempty"` + // List of data providers resolved in the data-provider query + ResolvedProviders *[]ResolvedDataProvider `json:"resolvedProviders,omitempty"` + // Scope name applied to this data provider result. + ScopeName *string `json:"scopeName,omitempty"` + // Scope value applied to this data provider result. + ScopeValue *string `json:"scopeValue,omitempty"` + // Property bag of shared data that was contributed to by any of the individual data providers + SharedData *map[string]interface{} `json:"sharedData,omitempty"` +} + +// Base class for an event callback for an extension +type ExtensionEventCallback struct { + // The uri of the endpoint that is hit when an event occurs + Uri *string `json:"uri,omitempty"` +} + +// Collection of event callbacks - endpoints called when particular extension events occur. +type ExtensionEventCallbackCollection struct { + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension disable has occurred. + PostDisable *ExtensionEventCallback `json:"postDisable,omitempty"` + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension enable has occurred. + PostEnable *ExtensionEventCallback `json:"postEnable,omitempty"` + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension install has completed. + PostInstall *ExtensionEventCallback `json:"postInstall,omitempty"` + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension uninstall has occurred. + PostUninstall *ExtensionEventCallback `json:"postUninstall,omitempty"` + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension update has occurred. + PostUpdate *ExtensionEventCallback `json:"postUpdate,omitempty"` + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension install is about to occur. Response indicates whether to proceed or abort. + PreInstall *ExtensionEventCallback `json:"preInstall,omitempty"` + // For multi-version extensions, defines an endpoint that gets called via an OPTIONS request to determine the particular version of the extension to be used + VersionCheck *ExtensionEventCallback `json:"versionCheck,omitempty"` +} + +// [Flags] Set of flags applied to extensions that are relevant to contribution consumers +type ExtensionFlags string + +type extensionFlagsValuesType struct { + BuiltIn ExtensionFlags + Trusted ExtensionFlags +} + +var ExtensionFlagsValues = extensionFlagsValuesType{ + // A built-in extension is installed for all VSTS accounts by default + BuiltIn: "builtIn", + // The extension comes from a fully-trusted publisher + Trusted: "trusted", +} + +// How an extension should handle including contributions based on licensing +type ExtensionLicensing struct { + // A list of contributions which deviate from the default licensing behavior + Overrides *[]LicensingOverride `json:"overrides,omitempty"` +} + +// Base class for extension properties which are shared by the extension manifest and the extension model +type ExtensionManifest struct { + // Uri used as base for other relative uri's defined in extension + BaseUri *string `json:"baseUri,omitempty"` + // List of shared constraints defined by this extension + Constraints *[]ContributionConstraint `json:"constraints,omitempty"` + // List of contributions made by this extension + Contributions *[]Contribution `json:"contributions,omitempty"` + // List of contribution types defined by this extension + ContributionTypes *[]ContributionType `json:"contributionTypes,omitempty"` + // List of explicit demands required by this extension + Demands *[]string `json:"demands,omitempty"` + // Collection of endpoints that get called when particular extension events occur + EventCallbacks *ExtensionEventCallbackCollection `json:"eventCallbacks,omitempty"` + // Secondary location that can be used as base for other relative uri's defined in extension + FallbackBaseUri *string `json:"fallbackBaseUri,omitempty"` + // Language Culture Name set by the Gallery + Language *string `json:"language,omitempty"` + // How this extension behaves with respect to licensing + Licensing *ExtensionLicensing `json:"licensing,omitempty"` + // Version of the extension manifest format/content + ManifestVersion *float64 `json:"manifestVersion,omitempty"` + // Default user claims applied to all contributions (except the ones which have been specified restrictedTo explicitly) to control the visibility of a contribution. + RestrictedTo *[]string `json:"restrictedTo,omitempty"` + // List of all oauth scopes required by this extension + Scopes *[]string `json:"scopes,omitempty"` + // The ServiceInstanceType(Guid) of the VSTS service that must be available to an account in order for the extension to be installed + ServiceInstanceType *uuid.UUID `json:"serviceInstanceType,omitempty"` +} + +// [Flags] States of an extension Note: If you add value to this enum, you need to do 2 other things. First add the back compat enum in value src\Vssf\Sdk\Server\Contributions\InstalledExtensionMessage.cs. Second, you can not send the new value on the message bus. You need to remove it from the message bus event prior to being sent. +type ExtensionStateFlags string + +type extensionStateFlagsValuesType struct { + None ExtensionStateFlags + Disabled ExtensionStateFlags + BuiltIn ExtensionStateFlags + MultiVersion ExtensionStateFlags + UnInstalled ExtensionStateFlags + VersionCheckError ExtensionStateFlags + Trusted ExtensionStateFlags + Error ExtensionStateFlags + NeedsReauthorization ExtensionStateFlags + AutoUpgradeError ExtensionStateFlags + Warning ExtensionStateFlags +} + +var ExtensionStateFlagsValues = extensionStateFlagsValuesType{ + // No flags set + None: "none", + // Extension is disabled + Disabled: "disabled", + // Extension is a built in + BuiltIn: "builtIn", + // Extension has multiple versions + MultiVersion: "multiVersion", + // Extension is not installed. This is for builtin extensions only and can not otherwise be set. + UnInstalled: "unInstalled", + // Error performing version check + VersionCheckError: "versionCheckError", + // Trusted extensions are ones that are given special capabilities. These tend to come from Microsoft and can't be published by the general public. Note: BuiltIn extensions are always trusted. + Trusted: "trusted", + // Extension is currently in an error state + Error: "error", + // Extension scopes have changed and the extension requires re-authorization + NeedsReauthorization: "needsReauthorization", + // Error performing auto-upgrade. For example, if the new version has demands not supported the extension cannot be auto-upgraded. + AutoUpgradeError: "autoUpgradeError", + // Extension is currently in a warning state, that can cause a degraded experience. The degraded experience can be caused for example by some installation issues detected such as implicit demands not supported. + Warning: "warning", +} + +// Represents a VSTS extension along with its installation state +type InstalledExtension struct { + // Uri used as base for other relative uri's defined in extension + BaseUri *string `json:"baseUri,omitempty"` + // List of shared constraints defined by this extension + Constraints *[]ContributionConstraint `json:"constraints,omitempty"` + // List of contributions made by this extension + Contributions *[]Contribution `json:"contributions,omitempty"` + // List of contribution types defined by this extension + ContributionTypes *[]ContributionType `json:"contributionTypes,omitempty"` + // List of explicit demands required by this extension + Demands *[]string `json:"demands,omitempty"` + // Collection of endpoints that get called when particular extension events occur + EventCallbacks *ExtensionEventCallbackCollection `json:"eventCallbacks,omitempty"` + // Secondary location that can be used as base for other relative uri's defined in extension + FallbackBaseUri *string `json:"fallbackBaseUri,omitempty"` + // Language Culture Name set by the Gallery + Language *string `json:"language,omitempty"` + // How this extension behaves with respect to licensing + Licensing *ExtensionLicensing `json:"licensing,omitempty"` + // Version of the extension manifest format/content + ManifestVersion *float64 `json:"manifestVersion,omitempty"` + // Default user claims applied to all contributions (except the ones which have been specified restrictedTo explicitly) to control the visibility of a contribution. + RestrictedTo *[]string `json:"restrictedTo,omitempty"` + // List of all oauth scopes required by this extension + Scopes *[]string `json:"scopes,omitempty"` + // The ServiceInstanceType(Guid) of the VSTS service that must be available to an account in order for the extension to be installed + ServiceInstanceType *uuid.UUID `json:"serviceInstanceType,omitempty"` + // The friendly extension id for this extension - unique for a given publisher. + ExtensionId *string `json:"extensionId,omitempty"` + // The display name of the extension. + ExtensionName *string `json:"extensionName,omitempty"` + // This is the set of files available from the extension. + Files *[]gallery.ExtensionFile `json:"files,omitempty"` + // Extension flags relevant to contribution consumers + Flags *ExtensionFlags `json:"flags,omitempty"` + // Information about this particular installation of the extension + InstallState *InstalledExtensionState `json:"installState,omitempty"` + // This represents the date/time the extensions was last updated in the gallery. This doesnt mean this version was updated the value represents changes to any and all versions of the extension. + LastPublished *azuredevops.Time `json:"lastPublished,omitempty"` + // Unique id of the publisher of this extension + PublisherId *string `json:"publisherId,omitempty"` + // The display name of the publisher + PublisherName *string `json:"publisherName,omitempty"` + // Unique id for this extension (the same id is used for all versions of a single extension) + RegistrationId *uuid.UUID `json:"registrationId,omitempty"` + // Version of this extension + Version *string `json:"version,omitempty"` +} + +// The state of an installed extension +type InstalledExtensionState struct { + // States of an installed extension + Flags *ExtensionStateFlags `json:"flags,omitempty"` + // List of installation issues + InstallationIssues *[]InstalledExtensionStateIssue `json:"installationIssues,omitempty"` + // The time at which this installation was last updated + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` +} + +// Represents an installation issue +type InstalledExtensionStateIssue struct { + // The error message + Message *string `json:"message,omitempty"` + // Source of the installation issue, for example "Demands" + Source *string `json:"source,omitempty"` + // Installation issue type (Warning, Error) + Type *InstalledExtensionStateIssueType `json:"type,omitempty"` +} + +// Installation issue type (Warning, Error) +type InstalledExtensionStateIssueType string + +type installedExtensionStateIssueTypeValuesType struct { + Warning InstalledExtensionStateIssueType + Error InstalledExtensionStateIssueType +} + +var InstalledExtensionStateIssueTypeValues = installedExtensionStateIssueTypeValuesType{ + // Represents an installation warning, for example an implicit demand not supported + Warning: "warning", + // Represents an installation error, for example an explicit demand not supported + Error: "error", +} + +// Maps a contribution to a licensing behavior +type LicensingOverride struct { + // How the inclusion of this contribution should change based on licensing + Behavior *ContributionLicensingBehaviorType `json:"behavior,omitempty"` + // Fully qualified contribution id which we want to define licensing behavior for + Id *string `json:"id,omitempty"` +} + +// Entry for a specific data provider's resulting data +type ResolvedDataProvider struct { + // The total time the data provider took to resolve its data (in milliseconds) + Duration *float32 `json:"duration,omitempty"` + Error *string `json:"error,omitempty"` + Id *string `json:"id,omitempty"` +} diff --git a/azuredevops/core/client.go b/azuredevops/core/client.go new file mode 100644 index 00000000..edddd3a7 --- /dev/null +++ b/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/azuredevops/core/models.go b/azuredevops/core/models.go new file mode 100644 index 00000000..e7564104 --- /dev/null +++ b/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/azuredevops/customerintelligence/client.go b/azuredevops/customerintelligence/client.go new file mode 100644 index 00000000..9a78394c --- /dev/null +++ b/azuredevops/customerintelligence/client.go @@ -0,0 +1,58 @@ +// -------------------------------------------------------------------------------------------- +// 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 customerintelligence + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" +) + +type Client interface { + // [Preview API] + PublishEvents(context.Context, PublishEventsArgs) 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, + } +} + +// [Preview API] +func (client *ClientImpl) PublishEvents(ctx context.Context, args PublishEventsArgs) error { + if args.Events == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Events"} + } + body, marshalErr := json.Marshal(*args.Events) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("b5cc35c2-ff2b-491d-a085-24b6e9f396fd") + _, 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 err + } + + return nil +} + +// Arguments for the PublishEvents function +type PublishEventsArgs struct { + // (required) + Events *[]CustomerIntelligenceEvent +} diff --git a/azuredevops/customerintelligence/models.go b/azuredevops/customerintelligence/models.go new file mode 100644 index 00000000..1fc91197 --- /dev/null +++ b/azuredevops/customerintelligence/models.go @@ -0,0 +1,15 @@ +// -------------------------------------------------------------------------------------------- +// 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 customerintelligence + +type CustomerIntelligenceEvent struct { + Area *string `json:"area,omitempty"` + Feature *string `json:"feature,omitempty"` + Properties *map[string]interface{} `json:"properties,omitempty"` +} diff --git a/azuredevops/dashboard/client.go b/azuredevops/dashboard/client.go new file mode 100644 index 00000000..6fbead37 --- /dev/null +++ b/azuredevops/dashboard/client.go @@ -0,0 +1,756 @@ +// -------------------------------------------------------------------------------------------- +// 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 dashboard + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" +) + +var ResourceAreaId, _ = uuid.Parse("31c84e0a-3ece-48fd-a29d-100849af99ba") + +type Client interface { + // [Preview API] Create the supplied dashboard. + CreateDashboard(context.Context, CreateDashboardArgs) (*Dashboard, error) + // [Preview API] Create a widget on the specified dashboard. + CreateWidget(context.Context, CreateWidgetArgs) (*Widget, error) + // [Preview API] Delete a dashboard given its ID. This also deletes the widgets associated with this dashboard. + DeleteDashboard(context.Context, DeleteDashboardArgs) error + // [Preview API] Delete the specified widget. + DeleteWidget(context.Context, DeleteWidgetArgs) (*Dashboard, error) + // [Preview API] Get a dashboard by its ID. + GetDashboard(context.Context, GetDashboardArgs) (*Dashboard, error) + // [Preview API] Get a list of dashboards. + GetDashboards(context.Context, GetDashboardsArgs) (*DashboardGroup, error) + // [Preview API] Get the current state of the specified widget. + GetWidget(context.Context, GetWidgetArgs) (*Widget, error) + // [Preview API] Get the widget metadata satisfying the specified contribution ID. + GetWidgetMetadata(context.Context, GetWidgetMetadataArgs) (*WidgetMetadataResponse, error) + // [Preview API] Get widgets contained on the specified dashboard. + GetWidgets(context.Context, GetWidgetsArgs) (*WidgetsVersionedList, error) + // [Preview API] Get all available widget metadata in alphabetical order. + GetWidgetTypes(context.Context, GetWidgetTypesArgs) (*WidgetTypesResponse, error) + // [Preview API] Replace configuration for the specified dashboard. Replaces Widget list on Dashboard, only if property is supplied. + ReplaceDashboard(context.Context, ReplaceDashboardArgs) (*Dashboard, error) + // [Preview API] Update the name and position of dashboards in the supplied group, and remove omitted dashboards. Does not modify dashboard content. + ReplaceDashboards(context.Context, ReplaceDashboardsArgs) (*DashboardGroup, error) + // [Preview API] Override the state of the specified widget. + ReplaceWidget(context.Context, ReplaceWidgetArgs) (*Widget, error) + // [Preview API] Replace the widgets on specified dashboard with the supplied widgets. + ReplaceWidgets(context.Context, ReplaceWidgetsArgs) (*WidgetsVersionedList, error) + // [Preview API] Perform a partial update of the specified widget. + UpdateWidget(context.Context, UpdateWidgetArgs) (*Widget, error) + // [Preview API] Update the supplied widgets on the dashboard using supplied state. State of existing Widgets not passed in the widget list is preserved. + UpdateWidgets(context.Context, UpdateWidgetsArgs) (*WidgetsVersionedList, 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 the supplied dashboard. +func (client *ClientImpl) CreateDashboard(ctx context.Context, args CreateDashboardArgs) (*Dashboard, error) { + if args.Dashboard == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Dashboard"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + body, marshalErr := json.Marshal(*args.Dashboard) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("454b3e51-2e6e-48d4-ad81-978154089351") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Dashboard + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateDashboard function +type CreateDashboardArgs struct { + // (required) The initial state of the dashboard + Dashboard *Dashboard + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Create a widget on the specified dashboard. +func (client *ClientImpl) CreateWidget(ctx context.Context, args CreateWidgetArgs) (*Widget, error) { + if args.Widget == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Widget"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.DashboardId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DashboardId"} + } + routeValues["dashboardId"] = (*args.DashboardId).String() + + body, marshalErr := json.Marshal(*args.Widget) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bdcff53a-8355-4172-a00a-40497ea23afc") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Widget + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateWidget function +type CreateWidgetArgs struct { + // (required) State of the widget to add + Widget *Widget + // (required) Project ID or project name + Project *string + // (required) ID of dashboard the widget will be added to. + DashboardId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Delete a dashboard given its ID. This also deletes the widgets associated with this dashboard. +func (client *ClientImpl) DeleteDashboard(ctx context.Context, args DeleteDashboardArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.DashboardId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.DashboardId"} + } + routeValues["dashboardId"] = (*args.DashboardId).String() + + locationId, _ := uuid.Parse("454b3e51-2e6e-48d4-ad81-978154089351") + _, 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 DeleteDashboard function +type DeleteDashboardArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the dashboard to delete. + DashboardId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Delete the specified widget. +func (client *ClientImpl) DeleteWidget(ctx context.Context, args DeleteWidgetArgs) (*Dashboard, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.DashboardId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DashboardId"} + } + routeValues["dashboardId"] = (*args.DashboardId).String() + if args.WidgetId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WidgetId"} + } + routeValues["widgetId"] = (*args.WidgetId).String() + + locationId, _ := uuid.Parse("bdcff53a-8355-4172-a00a-40497ea23afc") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Dashboard + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the DeleteWidget function +type DeleteWidgetArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the dashboard containing the widget. + DashboardId *uuid.UUID + // (required) ID of the widget to update. + WidgetId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Get a dashboard by its ID. +func (client *ClientImpl) GetDashboard(ctx context.Context, args GetDashboardArgs) (*Dashboard, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.DashboardId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DashboardId"} + } + routeValues["dashboardId"] = (*args.DashboardId).String() + + locationId, _ := uuid.Parse("454b3e51-2e6e-48d4-ad81-978154089351") + 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 Dashboard + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDashboard function +type GetDashboardArgs struct { + // (required) Project ID or project name + Project *string + // (required) + DashboardId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Get a list of dashboards. +func (client *ClientImpl) GetDashboards(ctx context.Context, args GetDashboardsArgs) (*DashboardGroup, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + locationId, _ := uuid.Parse("454b3e51-2e6e-48d4-ad81-978154089351") + 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 DashboardGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDashboards function +type GetDashboardsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Get the current state of the specified widget. +func (client *ClientImpl) GetWidget(ctx context.Context, args GetWidgetArgs) (*Widget, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.DashboardId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DashboardId"} + } + routeValues["dashboardId"] = (*args.DashboardId).String() + if args.WidgetId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WidgetId"} + } + routeValues["widgetId"] = (*args.WidgetId).String() + + locationId, _ := uuid.Parse("bdcff53a-8355-4172-a00a-40497ea23afc") + 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 Widget + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWidget function +type GetWidgetArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the dashboard containing the widget. + DashboardId *uuid.UUID + // (required) ID of the widget to read. + WidgetId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Get the widget metadata satisfying the specified contribution ID. +func (client *ClientImpl) GetWidgetMetadata(ctx context.Context, args GetWidgetMetadataArgs) (*WidgetMetadataResponse, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.ContributionId == nil || *args.ContributionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ContributionId"} + } + routeValues["contributionId"] = *args.ContributionId + + locationId, _ := uuid.Parse("6b3628d3-e96f-4fc7-b176-50240b03b515") + 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 WidgetMetadataResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWidgetMetadata function +type GetWidgetMetadataArgs struct { + // (required) The ID of Contribution for the Widget + ContributionId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get widgets contained on the specified dashboard. +func (client *ClientImpl) GetWidgets(ctx context.Context, args GetWidgetsArgs) (*WidgetsVersionedList, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.DashboardId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DashboardId"} + } + routeValues["dashboardId"] = (*args.DashboardId).String() + + additionalHeaders := make(map[string]string) + if args.ETag != nil { + additionalHeaders["ETag"] = *args.ETag + } + locationId, _ := uuid.Parse("bdcff53a-8355-4172-a00a-40497ea23afc") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseBodyValue []Widget + err = client.Client.UnmarshalCollectionBody(resp, &responseBodyValue) + + var responseValue *WidgetsVersionedList + if err == nil { + responseValue = &WidgetsVersionedList{ + Widgets: &responseBodyValue, + ETag: &[]string{resp.Header.Get("ETag")}, + } + } + + return responseValue, err +} + +// Arguments for the GetWidgets function +type GetWidgetsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the dashboard to read. + DashboardId *uuid.UUID + // (optional) Team ID or team name + Team *string + // (optional) Dashboard Widgets Version + ETag *string +} + +// [Preview API] Get all available widget metadata in alphabetical order. +func (client *ClientImpl) GetWidgetTypes(ctx context.Context, args GetWidgetTypesArgs) (*WidgetTypesResponse, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.Scope == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "scope"} + } + queryParams.Add("$scope", string(*args.Scope)) + locationId, _ := uuid.Parse("6b3628d3-e96f-4fc7-b176-50240b03b515") + 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 WidgetTypesResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWidgetTypes function +type GetWidgetTypesArgs struct { + // (required) + Scope *WidgetScope + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Replace configuration for the specified dashboard. Replaces Widget list on Dashboard, only if property is supplied. +func (client *ClientImpl) ReplaceDashboard(ctx context.Context, args ReplaceDashboardArgs) (*Dashboard, error) { + if args.Dashboard == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Dashboard"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.DashboardId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DashboardId"} + } + routeValues["dashboardId"] = (*args.DashboardId).String() + + body, marshalErr := json.Marshal(*args.Dashboard) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("454b3e51-2e6e-48d4-ad81-978154089351") + 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 Dashboard + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReplaceDashboard function +type ReplaceDashboardArgs struct { + // (required) The Configuration of the dashboard to replace. + Dashboard *Dashboard + // (required) Project ID or project name + Project *string + // (required) ID of the dashboard to replace. + DashboardId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Update the name and position of dashboards in the supplied group, and remove omitted dashboards. Does not modify dashboard content. +func (client *ClientImpl) ReplaceDashboards(ctx context.Context, args ReplaceDashboardsArgs) (*DashboardGroup, error) { + if args.Group == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Group"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + body, marshalErr := json.Marshal(*args.Group) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("454b3e51-2e6e-48d4-ad81-978154089351") + 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 DashboardGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReplaceDashboards function +type ReplaceDashboardsArgs struct { + // (required) + Group *DashboardGroup + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Override the state of the specified widget. +func (client *ClientImpl) ReplaceWidget(ctx context.Context, args ReplaceWidgetArgs) (*Widget, error) { + if args.Widget == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Widget"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.DashboardId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DashboardId"} + } + routeValues["dashboardId"] = (*args.DashboardId).String() + if args.WidgetId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WidgetId"} + } + routeValues["widgetId"] = (*args.WidgetId).String() + + body, marshalErr := json.Marshal(*args.Widget) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bdcff53a-8355-4172-a00a-40497ea23afc") + 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 Widget + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReplaceWidget function +type ReplaceWidgetArgs struct { + // (required) State to be written for the widget. + Widget *Widget + // (required) Project ID or project name + Project *string + // (required) ID of the dashboard containing the widget. + DashboardId *uuid.UUID + // (required) ID of the widget to update. + WidgetId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Replace the widgets on specified dashboard with the supplied widgets. +func (client *ClientImpl) ReplaceWidgets(ctx context.Context, args ReplaceWidgetsArgs) (*WidgetsVersionedList, error) { + if args.Widgets == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Widgets"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.DashboardId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DashboardId"} + } + routeValues["dashboardId"] = (*args.DashboardId).String() + + additionalHeaders := make(map[string]string) + if args.ETag != nil { + additionalHeaders["ETag"] = *args.ETag + } + body, marshalErr := json.Marshal(*args.Widgets) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bdcff53a-8355-4172-a00a-40497ea23afc") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseBodyValue []Widget + err = client.Client.UnmarshalCollectionBody(resp, &responseBodyValue) + + var responseValue *WidgetsVersionedList + if err == nil { + responseValue = &WidgetsVersionedList{ + Widgets: &responseBodyValue, + ETag: &[]string{resp.Header.Get("ETag")}, + } + } + + return responseValue, err +} + +// Arguments for the ReplaceWidgets function +type ReplaceWidgetsArgs struct { + // (required) Revised state of widgets to store for the dashboard. + Widgets *[]Widget + // (required) Project ID or project name + Project *string + // (required) ID of the Dashboard to modify. + DashboardId *uuid.UUID + // (optional) Team ID or team name + Team *string + // (optional) Dashboard Widgets Version + ETag *string +} + +// [Preview API] Perform a partial update of the specified widget. +func (client *ClientImpl) UpdateWidget(ctx context.Context, args UpdateWidgetArgs) (*Widget, error) { + if args.Widget == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Widget"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.DashboardId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DashboardId"} + } + routeValues["dashboardId"] = (*args.DashboardId).String() + if args.WidgetId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WidgetId"} + } + routeValues["widgetId"] = (*args.WidgetId).String() + + body, marshalErr := json.Marshal(*args.Widget) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bdcff53a-8355-4172-a00a-40497ea23afc") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Widget + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateWidget function +type UpdateWidgetArgs struct { + // (required) Description of the widget changes to apply. All non-null fields will be replaced. + Widget *Widget + // (required) Project ID or project name + Project *string + // (required) ID of the dashboard containing the widget. + DashboardId *uuid.UUID + // (required) ID of the widget to update. + WidgetId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Update the supplied widgets on the dashboard using supplied state. State of existing Widgets not passed in the widget list is preserved. +func (client *ClientImpl) UpdateWidgets(ctx context.Context, args UpdateWidgetsArgs) (*WidgetsVersionedList, error) { + if args.Widgets == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Widgets"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.DashboardId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DashboardId"} + } + routeValues["dashboardId"] = (*args.DashboardId).String() + + additionalHeaders := make(map[string]string) + if args.ETag != nil { + additionalHeaders["ETag"] = *args.ETag + } + body, marshalErr := json.Marshal(*args.Widgets) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bdcff53a-8355-4172-a00a-40497ea23afc") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseBodyValue []Widget + err = client.Client.UnmarshalCollectionBody(resp, &responseBodyValue) + + var responseValue *WidgetsVersionedList + if err == nil { + responseValue = &WidgetsVersionedList{ + Widgets: &responseBodyValue, + ETag: &[]string{resp.Header.Get("ETag")}, + } + } + + return responseValue, err +} + +// Arguments for the UpdateWidgets function +type UpdateWidgetsArgs struct { + // (required) The set of widget states to update on the dashboard. + Widgets *[]Widget + // (required) Project ID or project name + Project *string + // (required) ID of the Dashboard to modify. + DashboardId *uuid.UUID + // (optional) Team ID or team name + Team *string + // (optional) Dashboard Widgets Version + ETag *string +} diff --git a/azuredevops/dashboard/models.go b/azuredevops/dashboard/models.go new file mode 100644 index 00000000..54735787 --- /dev/null +++ b/azuredevops/dashboard/models.go @@ -0,0 +1,332 @@ +// -------------------------------------------------------------------------------------------- +// 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 dashboard + +import ( + "github.com/google/uuid" +) + +// Model of a Dashboard. +type Dashboard struct { + Links interface{} `json:"_links,omitempty"` + // Description of the dashboard. + Description *string `json:"description,omitempty"` + // Server defined version tracking value, used for edit collision detection. + ETag *string `json:"eTag,omitempty"` + // ID of the Dashboard. Provided by service at creation time. + Id *uuid.UUID `json:"id,omitempty"` + // Name of the Dashboard. + Name *string `json:"name,omitempty"` + // ID of the Owner for a dashboard. For any legacy dashboards, this would be the unique identifier for the team associated with the dashboard. + OwnerId *uuid.UUID `json:"ownerId,omitempty"` + // Position of the dashboard, within a dashboard group. If unset at creation time, position is decided by the service. + Position *int `json:"position,omitempty"` + // Interval for client to automatically refresh the dashboard. Expressed in minutes. + RefreshInterval *int `json:"refreshInterval,omitempty"` + Url *string `json:"url,omitempty"` + // The set of Widgets on the dashboard. + Widgets *[]Widget `json:"widgets,omitempty"` +} + +// Describes a list of dashboards associated to an owner. Currently, teams own dashboard groups. +type DashboardGroup struct { + Links interface{} `json:"_links,omitempty"` + // A list of Dashboards held by the Dashboard Group + DashboardEntries *[]DashboardGroupEntry `json:"dashboardEntries,omitempty"` + // Deprecated: The old permission model describing the level of permissions for the current team. Pre-M125. + Permission *GroupMemberPermission `json:"permission,omitempty"` + // A permissions bit mask describing the security permissions of the current team for dashboards. When this permission is the value None, use GroupMemberPermission. Permissions are evaluated based on the presence of a value other than None, else the GroupMemberPermission will be saved. + TeamDashboardPermission *TeamDashboardPermission `json:"teamDashboardPermission,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Dashboard group entry, wrapping around Dashboard (needed?) +type DashboardGroupEntry struct { + Links interface{} `json:"_links,omitempty"` + // Description of the dashboard. + Description *string `json:"description,omitempty"` + // Server defined version tracking value, used for edit collision detection. + ETag *string `json:"eTag,omitempty"` + // ID of the Dashboard. Provided by service at creation time. + Id *uuid.UUID `json:"id,omitempty"` + // Name of the Dashboard. + Name *string `json:"name,omitempty"` + // ID of the Owner for a dashboard. For any legacy dashboards, this would be the unique identifier for the team associated with the dashboard. + OwnerId *uuid.UUID `json:"ownerId,omitempty"` + // Position of the dashboard, within a dashboard group. If unset at creation time, position is decided by the service. + Position *int `json:"position,omitempty"` + // Interval for client to automatically refresh the dashboard. Expressed in minutes. + RefreshInterval *int `json:"refreshInterval,omitempty"` + Url *string `json:"url,omitempty"` + // The set of Widgets on the dashboard. + Widgets *[]Widget `json:"widgets,omitempty"` +} + +// Response from RestAPI when saving and editing DashboardGroupEntry +type DashboardGroupEntryResponse struct { + Links interface{} `json:"_links,omitempty"` + // Description of the dashboard. + Description *string `json:"description,omitempty"` + // Server defined version tracking value, used for edit collision detection. + ETag *string `json:"eTag,omitempty"` + // ID of the Dashboard. Provided by service at creation time. + Id *uuid.UUID `json:"id,omitempty"` + // Name of the Dashboard. + Name *string `json:"name,omitempty"` + // ID of the Owner for a dashboard. For any legacy dashboards, this would be the unique identifier for the team associated with the dashboard. + OwnerId *uuid.UUID `json:"ownerId,omitempty"` + // Position of the dashboard, within a dashboard group. If unset at creation time, position is decided by the service. + Position *int `json:"position,omitempty"` + // Interval for client to automatically refresh the dashboard. Expressed in minutes. + RefreshInterval *int `json:"refreshInterval,omitempty"` + Url *string `json:"url,omitempty"` + // The set of Widgets on the dashboard. + Widgets *[]Widget `json:"widgets,omitempty"` +} + +type DashboardResponse struct { + Links interface{} `json:"_links,omitempty"` + // Description of the dashboard. + Description *string `json:"description,omitempty"` + // Server defined version tracking value, used for edit collision detection. + ETag *string `json:"eTag,omitempty"` + // ID of the Dashboard. Provided by service at creation time. + Id *uuid.UUID `json:"id,omitempty"` + // Name of the Dashboard. + Name *string `json:"name,omitempty"` + // ID of the Owner for a dashboard. For any legacy dashboards, this would be the unique identifier for the team associated with the dashboard. + OwnerId *uuid.UUID `json:"ownerId,omitempty"` + // Position of the dashboard, within a dashboard group. If unset at creation time, position is decided by the service. + Position *int `json:"position,omitempty"` + // Interval for client to automatically refresh the dashboard. Expressed in minutes. + RefreshInterval *int `json:"refreshInterval,omitempty"` + Url *string `json:"url,omitempty"` + // The set of Widgets on the dashboard. + Widgets *[]Widget `json:"widgets,omitempty"` +} + +// identifies the scope of dashboard storage and permissions. +type DashboardScope string + +type dashboardScopeValuesType struct { + Collection_User DashboardScope + Project_Team DashboardScope +} + +var DashboardScopeValues = dashboardScopeValuesType{ + Collection_User: "collection_User", + Project_Team: "project_Team", +} + +type GroupMemberPermission string + +type groupMemberPermissionValuesType struct { + None GroupMemberPermission + Edit GroupMemberPermission + Manage GroupMemberPermission + ManagePermissions GroupMemberPermission +} + +var GroupMemberPermissionValues = groupMemberPermissionValuesType{ + None: "none", + Edit: "edit", + Manage: "manage", + ManagePermissions: "managePermissions", +} + +// Lightbox configuration +type LightboxOptions struct { + // Height of desired lightbox, in pixels + Height *int `json:"height,omitempty"` + // True to allow lightbox resizing, false to disallow lightbox resizing, defaults to false. + Resizable *bool `json:"resizable,omitempty"` + // Width of desired lightbox, in pixels + Width *int `json:"width,omitempty"` +} + +// versioning for an artifact as described at: http://semver.org/, of the form major.minor.patch. +type SemanticVersion struct { + // Major version when you make incompatible API changes + Major *int `json:"major,omitempty"` + // Minor version when you add functionality in a backwards-compatible manner + Minor *int `json:"minor,omitempty"` + // Patch version when you make backwards-compatible bug fixes + Patch *int `json:"patch,omitempty"` +} + +// [Flags] +type TeamDashboardPermission string + +type teamDashboardPermissionValuesType struct { + None TeamDashboardPermission + Read TeamDashboardPermission + Create TeamDashboardPermission + Edit TeamDashboardPermission + Delete TeamDashboardPermission + ManagePermissions TeamDashboardPermission +} + +var TeamDashboardPermissionValues = teamDashboardPermissionValuesType{ + None: "none", + Read: "read", + Create: "create", + Edit: "edit", + Delete: "delete", + ManagePermissions: "managePermissions", +} + +// Widget data +type Widget struct { + Links interface{} `json:"_links,omitempty"` + // Refers to the allowed sizes for the widget. This gets populated when user wants to configure the widget + AllowedSizes *[]WidgetSize `json:"allowedSizes,omitempty"` + // Read-Only Property from Dashboard Service. Indicates if settings are blocked for the current user. + AreSettingsBlockedForUser *bool `json:"areSettingsBlockedForUser,omitempty"` + // Refers to unique identifier of a feature artifact. Used for pinning+unpinning a specific artifact. + ArtifactId *string `json:"artifactId,omitempty"` + ConfigurationContributionId *string `json:"configurationContributionId,omitempty"` + ConfigurationContributionRelativeId *string `json:"configurationContributionRelativeId,omitempty"` + ContentUri *string `json:"contentUri,omitempty"` + // The id of the underlying contribution defining the supplied Widget Configuration. + ContributionId *string `json:"contributionId,omitempty"` + // Optional partial dashboard content, to support exchanging dashboard-level version ETag for widget-level APIs + Dashboard *Dashboard `json:"dashboard,omitempty"` + ETag *string `json:"eTag,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + IsNameConfigurable *bool `json:"isNameConfigurable,omitempty"` + LightboxOptions *LightboxOptions `json:"lightboxOptions,omitempty"` + LoadingImageUrl *string `json:"loadingImageUrl,omitempty"` + Name *string `json:"name,omitempty"` + Position *WidgetPosition `json:"position,omitempty"` + Settings *string `json:"settings,omitempty"` + SettingsVersion *SemanticVersion `json:"settingsVersion,omitempty"` + Size *WidgetSize `json:"size,omitempty"` + TypeId *string `json:"typeId,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Contribution based information describing Dashboard Widgets. +type WidgetMetadata struct { + // Sizes supported by the Widget. + AllowedSizes *[]WidgetSize `json:"allowedSizes,omitempty"` + // Opt-in boolean that indicates if the widget requires the Analytics Service to function. Widgets requiring the analytics service are hidden from the catalog if the Analytics Service is not available. + AnalyticsServiceRequired *bool `json:"analyticsServiceRequired,omitempty"` + // Resource for an icon in the widget catalog. + CatalogIconUrl *string `json:"catalogIconUrl,omitempty"` + // Opt-in URL string pointing at widget information. Defaults to extension marketplace URL if omitted + CatalogInfoUrl *string `json:"catalogInfoUrl,omitempty"` + // The id of the underlying contribution defining the supplied Widget custom configuration UI. Null if custom configuration UI is not available. + ConfigurationContributionId *string `json:"configurationContributionId,omitempty"` + // The relative id of the underlying contribution defining the supplied Widget custom configuration UI. Null if custom configuration UI is not available. + ConfigurationContributionRelativeId *string `json:"configurationContributionRelativeId,omitempty"` + // Indicates if the widget requires configuration before being added to dashboard. + ConfigurationRequired *bool `json:"configurationRequired,omitempty"` + // Uri for the widget content to be loaded from . + ContentUri *string `json:"contentUri,omitempty"` + // The id of the underlying contribution defining the supplied Widget. + ContributionId *string `json:"contributionId,omitempty"` + // Optional default settings to be copied into widget settings. + DefaultSettings *string `json:"defaultSettings,omitempty"` + // Summary information describing the widget. + Description *string `json:"description,omitempty"` + // Widgets can be disabled by the app store. We'll need to gracefully handle for: - persistence (Allow) - Requests (Tag as disabled, and provide context) + IsEnabled *bool `json:"isEnabled,omitempty"` + // Opt-out boolean that indicates if the widget supports widget name/title configuration. Widgets ignoring the name should set it to false in the manifest. + IsNameConfigurable *bool `json:"isNameConfigurable,omitempty"` + // Opt-out boolean indicating if the widget is hidden from the catalog. Commonly, this is used to allow developers to disable creation of a deprecated widget. A widget must have a functional default state, or have a configuration experience, in order to be visible from the catalog. + IsVisibleFromCatalog *bool `json:"isVisibleFromCatalog,omitempty"` + // Opt-in properties for customizing widget presentation in a "lightbox" dialog. + LightboxOptions *LightboxOptions `json:"lightboxOptions,omitempty"` + // Resource for a loading placeholder image on dashboard + LoadingImageUrl *string `json:"loadingImageUrl,omitempty"` + // User facing name of the widget type. Each widget must use a unique value here. + Name *string `json:"name,omitempty"` + // Publisher Name of this kind of widget. + PublisherName *string `json:"publisherName,omitempty"` + // Data contract required for the widget to function and to work in its container. + SupportedScopes *[]WidgetScope `json:"supportedScopes,omitempty"` + // Contribution target IDs + Targets *[]string `json:"targets,omitempty"` + // Deprecated: locally unique developer-facing id of this kind of widget. ContributionId provides a globally unique identifier for widget types. + TypeId *string `json:"typeId,omitempty"` +} + +type WidgetMetadataResponse struct { + Uri *string `json:"uri,omitempty"` + WidgetMetadata *WidgetMetadata `json:"widgetMetadata,omitempty"` +} + +type WidgetPosition struct { + Column *int `json:"column,omitempty"` + Row *int `json:"row,omitempty"` +} + +// Response from RestAPI when saving and editing Widget +type WidgetResponse struct { + Links interface{} `json:"_links,omitempty"` + // Refers to the allowed sizes for the widget. This gets populated when user wants to configure the widget + AllowedSizes *[]WidgetSize `json:"allowedSizes,omitempty"` + // Read-Only Property from Dashboard Service. Indicates if settings are blocked for the current user. + AreSettingsBlockedForUser *bool `json:"areSettingsBlockedForUser,omitempty"` + // Refers to unique identifier of a feature artifact. Used for pinning+unpinning a specific artifact. + ArtifactId *string `json:"artifactId,omitempty"` + ConfigurationContributionId *string `json:"configurationContributionId,omitempty"` + ConfigurationContributionRelativeId *string `json:"configurationContributionRelativeId,omitempty"` + ContentUri *string `json:"contentUri,omitempty"` + // The id of the underlying contribution defining the supplied Widget Configuration. + ContributionId *string `json:"contributionId,omitempty"` + // Optional partial dashboard content, to support exchanging dashboard-level version ETag for widget-level APIs + Dashboard *Dashboard `json:"dashboard,omitempty"` + ETag *string `json:"eTag,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + IsNameConfigurable *bool `json:"isNameConfigurable,omitempty"` + LightboxOptions *LightboxOptions `json:"lightboxOptions,omitempty"` + LoadingImageUrl *string `json:"loadingImageUrl,omitempty"` + Name *string `json:"name,omitempty"` + Position *WidgetPosition `json:"position,omitempty"` + Settings *string `json:"settings,omitempty"` + SettingsVersion *SemanticVersion `json:"settingsVersion,omitempty"` + Size *WidgetSize `json:"size,omitempty"` + TypeId *string `json:"typeId,omitempty"` + Url *string `json:"url,omitempty"` +} + +// data contract required for the widget to function in a webaccess area or page. +type WidgetScope string + +type widgetScopeValuesType struct { + Collection_User WidgetScope + Project_Team WidgetScope +} + +var WidgetScopeValues = widgetScopeValuesType{ + Collection_User: "collection_User", + Project_Team: "project_Team", +} + +type WidgetSize struct { + // The Width of the widget, expressed in dashboard grid columns. + ColumnSpan *int `json:"columnSpan,omitempty"` + // The height of the widget, expressed in dashboard grid rows. + RowSpan *int `json:"rowSpan,omitempty"` +} + +// Wrapper class to support HTTP header generation using CreateResponse, ClientHeaderParameter and ClientResponseType in WidgetV2Controller +type WidgetsVersionedList struct { + ETag *[]string `json:"eTag,omitempty"` + Widgets *[]Widget `json:"widgets,omitempty"` +} + +type WidgetTypesResponse struct { + Links interface{} `json:"_links,omitempty"` + Uri *string `json:"uri,omitempty"` + WidgetTypes *[]WidgetMetadata `json:"widgetTypes,omitempty"` +} diff --git a/azuredevops/delegatedauthorization/models.go b/azuredevops/delegatedauthorization/models.go new file mode 100644 index 00000000..e26fb557 --- /dev/null +++ b/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/azuredevops/distributedtaskcommon/models.go b/azuredevops/distributedtaskcommon/models.go new file mode 100644 index 00000000..bde84d22 --- /dev/null +++ b/azuredevops/distributedtaskcommon/models.go @@ -0,0 +1,80 @@ +// -------------------------------------------------------------------------------------------- +// 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 distributedtaskcommon + +type AuthorizationHeader struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +// Represents binding of data source for the service endpoint request. +type DataSourceBindingBase struct { + // Pagination format supported by this data source(ContinuationToken/SkipTop). + CallbackContextTemplate *string `json:"callbackContextTemplate,omitempty"` + // Subsequent calls needed? + CallbackRequiredTemplate *string `json:"callbackRequiredTemplate,omitempty"` + // Gets or sets the name of the data source. + DataSourceName *string `json:"dataSourceName,omitempty"` + // Gets or sets the endpoint Id. + EndpointId *string `json:"endpointId,omitempty"` + // Gets or sets the url of the service endpoint. + EndpointUrl *string `json:"endpointUrl,omitempty"` + // Gets or sets the authorization headers. + Headers *[]AuthorizationHeader `json:"headers,omitempty"` + // Defines the initial value of the query params + InitialContextTemplate *string `json:"initialContextTemplate,omitempty"` + // Gets or sets the parameters for the data source. + Parameters *map[string]string `json:"parameters,omitempty"` + // Gets or sets http request body + RequestContent *string `json:"requestContent,omitempty"` + // Gets or sets http request verb + RequestVerb *string `json:"requestVerb,omitempty"` + // Gets or sets the result selector. + ResultSelector *string `json:"resultSelector,omitempty"` + // Gets or sets the result template. + ResultTemplate *string `json:"resultTemplate,omitempty"` + // Gets or sets the target of the data source. + Target *string `json:"target,omitempty"` +} + +type ProcessParameters struct { + DataSourceBindings *[]DataSourceBindingBase `json:"dataSourceBindings,omitempty"` + Inputs *[]TaskInputDefinitionBase `json:"inputs,omitempty"` + SourceDefinitions *[]TaskSourceDefinitionBase `json:"sourceDefinitions,omitempty"` +} + +type TaskInputDefinitionBase struct { + Aliases *[]string `json:"aliases,omitempty"` + DefaultValue *string `json:"defaultValue,omitempty"` + GroupName *string `json:"groupName,omitempty"` + HelpMarkDown *string `json:"helpMarkDown,omitempty"` + Label *string `json:"label,omitempty"` + Name *string `json:"name,omitempty"` + Options *map[string]string `json:"options,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Required *bool `json:"required,omitempty"` + Type *string `json:"type,omitempty"` + Validation *TaskInputValidation `json:"validation,omitempty"` + VisibleRule *string `json:"visibleRule,omitempty"` +} + +type TaskInputValidation struct { + // Conditional expression + Expression *string `json:"expression,omitempty"` + // Message explaining how user can correct if validation fails + Message *string `json:"message,omitempty"` +} + +type TaskSourceDefinitionBase struct { + AuthKey *string `json:"authKey,omitempty"` + Endpoint *string `json:"endpoint,omitempty"` + KeySelector *string `json:"keySelector,omitempty"` + Selector *string `json:"selector,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/azuredevops/errors.go b/azuredevops/errors.go new file mode 100644 index 00000000..e7cf6a37 --- /dev/null +++ b/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/azuredevops/extensionmanagement/client.go b/azuredevops/extensionmanagement/client.go new file mode 100644 index 00000000..2d53ff8f --- /dev/null +++ b/azuredevops/extensionmanagement/client.go @@ -0,0 +1,229 @@ +// -------------------------------------------------------------------------------------------- +// 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 extensionmanagement + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("6c2b0933-3600-42ae-bf8b-93d4f7e83594") + +type Client interface { + // [Preview API] Get an installed extension by its publisher and extension name. + GetInstalledExtensionByName(context.Context, GetInstalledExtensionByNameArgs) (*InstalledExtension, error) + // [Preview API] List the installed extensions in the account / project collection. + GetInstalledExtensions(context.Context, GetInstalledExtensionsArgs) (*[]InstalledExtension, error) + // [Preview API] Install the specified extension into the account / project collection. + InstallExtensionByName(context.Context, InstallExtensionByNameArgs) (*InstalledExtension, error) + // [Preview API] Uninstall the specified extension from the account / project collection. + UninstallExtensionByName(context.Context, UninstallExtensionByNameArgs) error + // [Preview API] Update an installed extension. Typically this API is used to enable or disable an extension. + UpdateInstalledExtension(context.Context, UpdateInstalledExtensionArgs) (*InstalledExtension, 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] Get an installed extension by its publisher and extension name. +func (client *ClientImpl) GetInstalledExtensionByName(ctx context.Context, args GetInstalledExtensionByNameArgs) (*InstalledExtension, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.AssetTypes != nil { + listAsString := strings.Join((*args.AssetTypes)[:], ":") + queryParams.Add("assetTypes", listAsString) + } + locationId, _ := uuid.Parse("fb0da285-f23e-4b56-8b53-3ef5f9f6de66") + 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 InstalledExtension + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetInstalledExtensionByName function +type GetInstalledExtensionByNameArgs struct { + // (required) Name of the publisher. Example: "fabrikam". + PublisherName *string + // (required) Name of the extension. Example: "ops-tools". + ExtensionName *string + // (optional) + AssetTypes *[]string +} + +// [Preview API] List the installed extensions in the account / project collection. +func (client *ClientImpl) GetInstalledExtensions(ctx context.Context, args GetInstalledExtensionsArgs) (*[]InstalledExtension, error) { + queryParams := url.Values{} + if args.IncludeDisabledExtensions != nil { + queryParams.Add("includeDisabledExtensions", strconv.FormatBool(*args.IncludeDisabledExtensions)) + } + if args.IncludeErrors != nil { + queryParams.Add("includeErrors", strconv.FormatBool(*args.IncludeErrors)) + } + if args.AssetTypes != nil { + listAsString := strings.Join((*args.AssetTypes)[:], ":") + queryParams.Add("assetTypes", listAsString) + } + if args.IncludeInstallationIssues != nil { + queryParams.Add("includeInstallationIssues", strconv.FormatBool(*args.IncludeInstallationIssues)) + } + locationId, _ := uuid.Parse("275424d0-c844-4fe2-bda6-04933a1357d8") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []InstalledExtension + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetInstalledExtensions function +type GetInstalledExtensionsArgs struct { + // (optional) If true (the default), include disabled extensions in the results. + IncludeDisabledExtensions *bool + // (optional) If true, include installed extensions with errors. + IncludeErrors *bool + // (optional) + AssetTypes *[]string + // (optional) + IncludeInstallationIssues *bool +} + +// [Preview API] Install the specified extension into the account / project collection. +func (client *ClientImpl) InstallExtensionByName(ctx context.Context, args InstallExtensionByNameArgs) (*InstalledExtension, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.Version != nil && *args.Version != "" { + routeValues["version"] = *args.Version + } + + locationId, _ := uuid.Parse("fb0da285-f23e-4b56-8b53-3ef5f9f6de66") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue InstalledExtension + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the InstallExtensionByName function +type InstallExtensionByNameArgs struct { + // (required) Name of the publisher. Example: "fabrikam". + PublisherName *string + // (required) Name of the extension. Example: "ops-tools". + ExtensionName *string + // (optional) + Version *string +} + +// [Preview API] Uninstall the specified extension from the account / project collection. +func (client *ClientImpl) UninstallExtensionByName(ctx context.Context, args UninstallExtensionByNameArgs) error { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.Reason != nil { + queryParams.Add("reason", *args.Reason) + } + if args.ReasonCode != nil { + queryParams.Add("reasonCode", *args.ReasonCode) + } + locationId, _ := uuid.Parse("fb0da285-f23e-4b56-8b53-3ef5f9f6de66") + _, 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 UninstallExtensionByName function +type UninstallExtensionByNameArgs struct { + // (required) Name of the publisher. Example: "fabrikam". + PublisherName *string + // (required) Name of the extension. Example: "ops-tools". + ExtensionName *string + // (optional) + Reason *string + // (optional) + ReasonCode *string +} + +// [Preview API] Update an installed extension. Typically this API is used to enable or disable an extension. +func (client *ClientImpl) UpdateInstalledExtension(ctx context.Context, args UpdateInstalledExtensionArgs) (*InstalledExtension, error) { + if args.Extension == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Extension"} + } + body, marshalErr := json.Marshal(*args.Extension) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("275424d0-c844-4fe2-bda6-04933a1357d8") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue InstalledExtension + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateInstalledExtension function +type UpdateInstalledExtensionArgs struct { + // (required) + Extension *InstalledExtension +} diff --git a/azuredevops/extensionmanagement/models.go b/azuredevops/extensionmanagement/models.go new file mode 100644 index 00000000..a6dc1685 --- /dev/null +++ b/azuredevops/extensionmanagement/models.go @@ -0,0 +1,873 @@ +// -------------------------------------------------------------------------------------------- +// 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 extensionmanagement + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/gallery" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +// How the acquisition is assigned +type AcquisitionAssignmentType string + +type acquisitionAssignmentTypeValuesType struct { + None AcquisitionAssignmentType + Me AcquisitionAssignmentType + All AcquisitionAssignmentType +} + +var AcquisitionAssignmentTypeValues = acquisitionAssignmentTypeValuesType{ + None: "none", + // Just assign for me + Me: "me", + // Assign for all users in the account + All: "all", +} + +type AcquisitionOperation struct { + // State of the the AcquisitionOperation for the current user + OperationState *AcquisitionOperationState `json:"operationState,omitempty"` + // AcquisitionOperationType: install, request, buy, etc... + OperationType *AcquisitionOperationType `json:"operationType,omitempty"` + // Optional reason to justify current state. Typically used with Disallow state. + Reason *string `json:"reason,omitempty"` + // List of reasons indicating why the operation is not allowed. + Reasons *[]AcquisitionOperationDisallowReason `json:"reasons,omitempty"` +} + +type AcquisitionOperationDisallowReason struct { + // User-friendly message clarifying the reason for disallowance + Message *string `json:"message,omitempty"` + // Type of reason for disallowance - AlreadyInstalled, UnresolvedDemand, etc. + Type *string `json:"type,omitempty"` +} + +type AcquisitionOperationState string + +type acquisitionOperationStateValuesType struct { + Disallow AcquisitionOperationState + Allow AcquisitionOperationState + Completed AcquisitionOperationState +} + +var AcquisitionOperationStateValues = acquisitionOperationStateValuesType{ + // Not allowed to use this AcquisitionOperation + Disallow: "disallow", + // Allowed to use this AcquisitionOperation + Allow: "allow", + // Operation has already been completed and is no longer available + Completed: "completed", +} + +// Set of different types of operations that can be requested. +type AcquisitionOperationType string + +type acquisitionOperationTypeValuesType struct { + Get AcquisitionOperationType + Install AcquisitionOperationType + Buy AcquisitionOperationType + Try AcquisitionOperationType + Request AcquisitionOperationType + None AcquisitionOperationType + PurchaseRequest AcquisitionOperationType +} + +var AcquisitionOperationTypeValues = acquisitionOperationTypeValuesType{ + // Not yet used + Get: "get", + // Install this extension into the host provided + Install: "install", + // Buy licenses for this extension and install into the host provided + Buy: "buy", + // Try this extension + Try: "try", + // Request this extension for installation + Request: "request", + // No action found + None: "none", + // Request admins for purchasing extension + PurchaseRequest: "purchaseRequest", +} + +// Market item acquisition options (install, buy, etc) for an installation target. +type AcquisitionOptions struct { + // Default Operation for the ItemId in this target + DefaultOperation *AcquisitionOperation `json:"defaultOperation,omitempty"` + // The item id that this options refer to + ItemId *string `json:"itemId,omitempty"` + // Operations allowed for the ItemId in this target + Operations *[]AcquisitionOperation `json:"operations,omitempty"` + // Additional properties which can be added to the request. + Properties interface{} `json:"properties,omitempty"` + // The target that this options refer to + Target *string `json:"target,omitempty"` +} + +// Representation of a ContributionNode that can be used for serialized to clients. +type ClientContribution struct { + // Description of the contribution/type + Description *string `json:"description,omitempty"` + // Fully qualified identifier of the contribution/type + Id *string `json:"id,omitempty"` + // Includes is a set of contributions that should have this contribution included in their targets list. + Includes *[]string `json:"includes,omitempty"` + // Properties/attributes of this contribution + Properties interface{} `json:"properties,omitempty"` + // The ids of the contribution(s) that this contribution targets. (parent contributions) + Targets *[]string `json:"targets,omitempty"` + // Id of the Contribution Type + Type *string `json:"type,omitempty"` +} + +// Representation of a ContributionNode that can be used for serialized to clients. +type ClientContributionNode struct { + // List of ids for contributions which are children to the current contribution. + Children *[]string `json:"children,omitempty"` + // Contribution associated with this node. + Contribution *ClientContribution `json:"contribution,omitempty"` + // List of ids for contributions which are parents to the current contribution. + Parents *[]string `json:"parents,omitempty"` +} + +type ClientContributionProviderDetails struct { + // Friendly name for the provider. + DisplayName *string `json:"displayName,omitempty"` + // Unique identifier for this provider. The provider name can be used to cache the contribution data and refer back to it when looking for changes + Name *string `json:"name,omitempty"` + // Properties associated with the provider + Properties *map[string]string `json:"properties,omitempty"` + // Version of contributions associated with this contribution provider. + Version *string `json:"version,omitempty"` +} + +// A client data provider are the details needed to make the data provider request from the client. +type ClientDataProviderQuery struct { + // Contextual information to pass to the data providers + Context *DataProviderContext `json:"context,omitempty"` + // The contribution ids of the data providers to resolve + ContributionIds *[]string `json:"contributionIds,omitempty"` + // The Id of the service instance type that should be communicated with in order to resolve the data providers from the client given the query values. + QueryServiceInstanceType *uuid.UUID `json:"queryServiceInstanceType,omitempty"` +} + +// An individual contribution made by an extension +type Contribution struct { + // Description of the contribution/type + Description *string `json:"description,omitempty"` + // Fully qualified identifier of the contribution/type + Id *string `json:"id,omitempty"` + // VisibleTo can be used to restrict whom can reference a given contribution/type. This value should be a list of publishers or extensions access is restricted too. Examples: "ms" - Means only the "ms" publisher can reference this. "ms.vss-web" - Means only the "vss-web" extension from the "ms" publisher can reference this. + VisibleTo *[]string `json:"visibleTo,omitempty"` + // List of constraints (filters) that should be applied to the availability of this contribution + Constraints *[]ContributionConstraint `json:"constraints,omitempty"` + // Includes is a set of contributions that should have this contribution included in their targets list. + Includes *[]string `json:"includes,omitempty"` + // Properties/attributes of this contribution + Properties interface{} `json:"properties,omitempty"` + // List of demanded claims in order for the user to see this contribution (like anonymous, public, member...). + RestrictedTo *[]string `json:"restrictedTo,omitempty"` + // The ids of the contribution(s) that this contribution targets. (parent contributions) + Targets *[]string `json:"targets,omitempty"` + // Id of the Contribution Type + Type *string `json:"type,omitempty"` +} + +// Base class shared by contributions and contribution types +type ContributionBase struct { + // Description of the contribution/type + Description *string `json:"description,omitempty"` + // Fully qualified identifier of the contribution/type + Id *string `json:"id,omitempty"` + // VisibleTo can be used to restrict whom can reference a given contribution/type. This value should be a list of publishers or extensions access is restricted too. Examples: "ms" - Means only the "ms" publisher can reference this. "ms.vss-web" - Means only the "vss-web" extension from the "ms" publisher can reference this. + VisibleTo *[]string `json:"visibleTo,omitempty"` +} + +// Specifies a constraint that can be used to dynamically include/exclude a given contribution +type ContributionConstraint struct { + // An optional property that can be specified to group constraints together. All constraints within a group are AND'd together (all must be evaluate to True in order for the contribution to be included). Different groups of constraints are OR'd (only one group needs to evaluate to True for the contribution to be included). + Group *int `json:"group,omitempty"` + // Fully qualified identifier of a shared constraint + Id *string `json:"id,omitempty"` + // If true, negate the result of the filter (include the contribution if the applied filter returns false instead of true) + Inverse *bool `json:"inverse,omitempty"` + // Name of the IContributionFilter plugin + Name *string `json:"name,omitempty"` + // Properties that are fed to the contribution filter class + Properties interface{} `json:"properties,omitempty"` + // Constraints can be optionally be applied to one or more of the relationships defined in the contribution. If no relationships are defined then all relationships are associated with the constraint. This means the default behaviour will eliminate the contribution from the tree completely if the constraint is applied. + Relationships *[]string `json:"relationships,omitempty"` +} + +// Represents different ways of including contributions based on licensing +type ContributionLicensingBehaviorType string + +type contributionLicensingBehaviorTypeValuesType struct { + OnlyIfLicensed ContributionLicensingBehaviorType + OnlyIfUnlicensed ContributionLicensingBehaviorType + AlwaysInclude ContributionLicensingBehaviorType +} + +var ContributionLicensingBehaviorTypeValues = contributionLicensingBehaviorTypeValuesType{ + // Default value - only include the contribution if the user is licensed for the extension + OnlyIfLicensed: "onlyIfLicensed", + // Only include the contribution if the user is NOT licensed for the extension + OnlyIfUnlicensed: "onlyIfUnlicensed", + // Always include the contribution regardless of whether or not the user is licensed for the extension + AlwaysInclude: "alwaysInclude", +} + +// A query that can be issued for contribution nodes +type ContributionNodeQuery struct { + // The contribution ids of the nodes to find. + ContributionIds *[]string `json:"contributionIds,omitempty"` + // Contextual information that can be leveraged by contribution constraints + DataProviderContext *DataProviderContext `json:"dataProviderContext,omitempty"` + // Indicator if contribution provider details should be included in the result. + IncludeProviderDetails *bool `json:"includeProviderDetails,omitempty"` + // Query options tpo be used when fetching ContributionNodes + QueryOptions *ContributionQueryOptions `json:"queryOptions,omitempty"` +} + +// Result of a contribution node query. Wraps the resulting contribution nodes and provider details. +type ContributionNodeQueryResult struct { + // Map of contribution ids to corresponding node. + Nodes *map[string]ClientContributionNode `json:"nodes,omitempty"` + // Map of provider ids to the corresponding provider details object. + ProviderDetails *map[string]ClientContributionProviderDetails `json:"providerDetails,omitempty"` +} + +// Description about a property of a contribution type +type ContributionPropertyDescription struct { + // Description of the property + Description *string `json:"description,omitempty"` + // Name of the property + Name *string `json:"name,omitempty"` + // True if this property is required + Required *bool `json:"required,omitempty"` + // The type of value used for this property + Type *ContributionPropertyType `json:"type,omitempty"` +} + +// [Flags] The type of value used for a property +type ContributionPropertyType string + +type contributionPropertyTypeValuesType struct { + Unknown ContributionPropertyType + String ContributionPropertyType + Uri ContributionPropertyType + Guid ContributionPropertyType + Boolean ContributionPropertyType + Integer ContributionPropertyType + Double ContributionPropertyType + DateTime ContributionPropertyType + Dictionary ContributionPropertyType + Array ContributionPropertyType + Object ContributionPropertyType +} + +var ContributionPropertyTypeValues = contributionPropertyTypeValuesType{ + // Contribution type is unknown (value may be anything) + Unknown: "unknown", + // Value is a string + String: "string", + // Value is a Uri + Uri: "uri", + // Value is a GUID + Guid: "guid", + // Value is True or False + Boolean: "boolean", + // Value is an integer + Integer: "integer", + // Value is a double + Double: "double", + // Value is a DateTime object + DateTime: "dateTime", + // Value is a generic Dictionary/JObject/property bag + Dictionary: "dictionary", + // Value is an array + Array: "array", + // Value is an arbitrary/custom object + Object: "object", +} + +type ContributionProviderDetails struct { + // Friendly name for the provider. + DisplayName *string `json:"displayName,omitempty"` + // Unique identifier for this provider. The provider name can be used to cache the contribution data and refer back to it when looking for changes + Name *string `json:"name,omitempty"` + // Properties associated with the provider + Properties *map[string]string `json:"properties,omitempty"` + // Version of contributions associated with this contribution provider. + Version *string `json:"version,omitempty"` +} + +// [Flags] Options that control the contributions to include in a query +type ContributionQueryOptions string + +type contributionQueryOptionsValuesType struct { + None ContributionQueryOptions + IncludeSelf ContributionQueryOptions + IncludeChildren ContributionQueryOptions + IncludeSubTree ContributionQueryOptions + IncludeAll ContributionQueryOptions + IgnoreConstraints ContributionQueryOptions +} + +var ContributionQueryOptionsValues = contributionQueryOptionsValuesType{ + None: "none", + // Include the direct contributions that have the ids queried. + IncludeSelf: "includeSelf", + // Include the contributions that directly target the contributions queried. + IncludeChildren: "includeChildren", + // Include the contributions from the entire sub-tree targeting the contributions queried. + IncludeSubTree: "includeSubTree", + // Include the contribution being queried as well as all contributions that target them recursively. + IncludeAll: "includeAll", + // Some callers may want the entire tree back without constraint evaluation being performed. + IgnoreConstraints: "ignoreConstraints", +} + +// A contribution type, given by a json schema +type ContributionType struct { + // Description of the contribution/type + Description *string `json:"description,omitempty"` + // Fully qualified identifier of the contribution/type + Id *string `json:"id,omitempty"` + // VisibleTo can be used to restrict whom can reference a given contribution/type. This value should be a list of publishers or extensions access is restricted too. Examples: "ms" - Means only the "ms" publisher can reference this. "ms.vss-web" - Means only the "vss-web" extension from the "ms" publisher can reference this. + VisibleTo *[]string `json:"visibleTo,omitempty"` + // Controls whether or not contributions of this type have the type indexed for queries. This allows clients to find all extensions that have a contribution of this type. NOTE: Only TrustedPartners are allowed to specify indexed contribution types. + Indexed *bool `json:"indexed,omitempty"` + // Friendly name of the contribution/type + Name *string `json:"name,omitempty"` + // Describes the allowed properties for this contribution type + Properties *map[string]ContributionPropertyDescription `json:"properties,omitempty"` +} + +// Contextual information that data providers can examine when populating their data +type DataProviderContext struct { + // Generic property bag that contains context-specific properties that data providers can use when populating their data dictionary + Properties *map[string]interface{} `json:"properties,omitempty"` +} + +type DataProviderExceptionDetails struct { + // The type of the exception that was thrown. + ExceptionType *string `json:"exceptionType,omitempty"` + // Message that is associated with the exception. + Message *string `json:"message,omitempty"` + // The StackTrace from the exception turned into a string. + StackTrace *string `json:"stackTrace,omitempty"` +} + +// A query that can be issued for data provider data +type DataProviderQuery struct { + // Contextual information to pass to the data providers + Context *DataProviderContext `json:"context,omitempty"` + // The contribution ids of the data providers to resolve + ContributionIds *[]string `json:"contributionIds,omitempty"` +} + +// Result structure from calls to GetDataProviderData +type DataProviderResult struct { + // This is the set of data providers that were requested, but either they were defined as client providers, or as remote providers that failed and may be retried by the client. + ClientProviders *map[string]ClientDataProviderQuery `json:"clientProviders,omitempty"` + // Property bag of data keyed off of the data provider contribution id + Data *map[string]interface{} `json:"data,omitempty"` + // Set of exceptions that occurred resolving the data providers. + Exceptions *map[string]DataProviderExceptionDetails `json:"exceptions,omitempty"` + // List of data providers resolved in the data-provider query + ResolvedProviders *[]ResolvedDataProvider `json:"resolvedProviders,omitempty"` + // Scope name applied to this data provider result. + ScopeName *string `json:"scopeName,omitempty"` + // Scope value applied to this data provider result. + ScopeValue *string `json:"scopeValue,omitempty"` + // Property bag of shared data that was contributed to by any of the individual data providers + SharedData *map[string]interface{} `json:"sharedData,omitempty"` +} + +// Data bag that any data provider can contribute to. This shared dictionary is returned in the data provider result. +type DataProviderSharedData struct { +} + +// Contract for handling the extension acquisition process +type ExtensionAcquisitionRequest struct { + // How the item is being assigned + AssignmentType *AcquisitionAssignmentType `json:"assignmentType,omitempty"` + // The id of the subscription used for purchase + BillingId *string `json:"billingId,omitempty"` + // The marketplace id (publisherName.extensionName) for the item + ItemId *string `json:"itemId,omitempty"` + // The type of operation, such as install, request, purchase + OperationType *AcquisitionOperationType `json:"operationType,omitempty"` + // Additional properties which can be added to the request. + Properties interface{} `json:"properties,omitempty"` + // How many licenses should be purchased + Quantity *int `json:"quantity,omitempty"` +} + +// Audit log for an extension +type ExtensionAuditLog struct { + // Collection of audit log entries + Entries *[]ExtensionAuditLogEntry `json:"entries,omitempty"` + // Extension that the change was made for + ExtensionName *string `json:"extensionName,omitempty"` + // Publisher that the extension is part of + PublisherName *string `json:"publisherName,omitempty"` +} + +// An audit log entry for an extension +type ExtensionAuditLogEntry struct { + // Change that was made to extension + AuditAction *string `json:"auditAction,omitempty"` + // Date at which the change was made + AuditDate *azuredevops.Time `json:"auditDate,omitempty"` + // Extra information about the change + Comment *string `json:"comment,omitempty"` + // Represents the user who made the change + UpdatedBy *webapi.IdentityRef `json:"updatedBy,omitempty"` +} + +type ExtensionAuthorization struct { + Id *uuid.UUID `json:"id,omitempty"` + Scopes *[]string `json:"scopes,omitempty"` +} + +// Represents a single collection for extension data documents +type ExtensionDataCollection struct { + // The name of the collection + CollectionName *string `json:"collectionName,omitempty"` + // A list of documents belonging to the collection + Documents *[]interface{} `json:"documents,omitempty"` + // The type of the collection's scope, such as Default or User + ScopeType *string `json:"scopeType,omitempty"` + // The value of the collection's scope, such as Current or Me + ScopeValue *string `json:"scopeValue,omitempty"` +} + +// Represents a query to receive a set of extension data collections +type ExtensionDataCollectionQuery struct { + // A list of collections to query + Collections *[]ExtensionDataCollection `json:"collections,omitempty"` +} + +type ExtensionEvent struct { + // The extension which has been updated + Extension *gallery.PublishedExtension `json:"extension,omitempty"` + // The current version of the extension that was updated + ExtensionVersion *string `json:"extensionVersion,omitempty"` + // Name of the collection for which the extension was requested + Host *ExtensionHost `json:"host,omitempty"` + // Gallery host url + Links *ExtensionEventUrls `json:"links,omitempty"` + // Represents the user who initiated the update + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // The type of update that was made + UpdateType *ExtensionUpdateType `json:"updateType,omitempty"` +} + +// Base class for an event callback for an extension +type ExtensionEventCallback struct { + // The uri of the endpoint that is hit when an event occurs + Uri *string `json:"uri,omitempty"` +} + +// Collection of event callbacks - endpoints called when particular extension events occur. +type ExtensionEventCallbackCollection struct { + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension disable has occurred. + PostDisable *ExtensionEventCallback `json:"postDisable,omitempty"` + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension enable has occurred. + PostEnable *ExtensionEventCallback `json:"postEnable,omitempty"` + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension install has completed. + PostInstall *ExtensionEventCallback `json:"postInstall,omitempty"` + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension uninstall has occurred. + PostUninstall *ExtensionEventCallback `json:"postUninstall,omitempty"` + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension update has occurred. + PostUpdate *ExtensionEventCallback `json:"postUpdate,omitempty"` + // Optional. Defines an endpoint that gets called via a POST request to notify that an extension install is about to occur. Response indicates whether to proceed or abort. + PreInstall *ExtensionEventCallback `json:"preInstall,omitempty"` + // For multi-version extensions, defines an endpoint that gets called via an OPTIONS request to determine the particular version of the extension to be used + VersionCheck *ExtensionEventCallback `json:"versionCheck,omitempty"` +} + +type ExtensionEventUrls struct { + // Url of the extension icon + ExtensionIcon *string `json:"extensionIcon,omitempty"` + // Link to view the extension details page + ExtensionPage *string `json:"extensionPage,omitempty"` + // Url of the extension management page + ManageExtensionsPage *string `json:"manageExtensionsPage,omitempty"` +} + +// [Flags] Set of flags applied to extensions that are relevant to contribution consumers +type ExtensionFlags string + +type extensionFlagsValuesType struct { + BuiltIn ExtensionFlags + Trusted ExtensionFlags +} + +var ExtensionFlagsValues = extensionFlagsValuesType{ + // A built-in extension is installed for all VSTS accounts by default + BuiltIn: "builtIn", + // The extension comes from a fully-trusted publisher + Trusted: "trusted", +} + +type ExtensionHost struct { + Id *uuid.UUID `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +// How an extension should handle including contributions based on licensing +type ExtensionLicensing struct { + // A list of contributions which deviate from the default licensing behavior + Overrides *[]LicensingOverride `json:"overrides,omitempty"` +} + +// Base class for extension properties which are shared by the extension manifest and the extension model +type ExtensionManifest struct { + // Uri used as base for other relative uri's defined in extension + BaseUri *string `json:"baseUri,omitempty"` + // List of shared constraints defined by this extension + Constraints *[]ContributionConstraint `json:"constraints,omitempty"` + // List of contributions made by this extension + Contributions *[]Contribution `json:"contributions,omitempty"` + // List of contribution types defined by this extension + ContributionTypes *[]ContributionType `json:"contributionTypes,omitempty"` + // List of explicit demands required by this extension + Demands *[]string `json:"demands,omitempty"` + // Collection of endpoints that get called when particular extension events occur + EventCallbacks *ExtensionEventCallbackCollection `json:"eventCallbacks,omitempty"` + // Secondary location that can be used as base for other relative uri's defined in extension + FallbackBaseUri *string `json:"fallbackBaseUri,omitempty"` + // Language Culture Name set by the Gallery + Language *string `json:"language,omitempty"` + // How this extension behaves with respect to licensing + Licensing *ExtensionLicensing `json:"licensing,omitempty"` + // Version of the extension manifest format/content + ManifestVersion *float64 `json:"manifestVersion,omitempty"` + // Default user claims applied to all contributions (except the ones which have been specified restrictedTo explicitly) to control the visibility of a contribution. + RestrictedTo *[]string `json:"restrictedTo,omitempty"` + // List of all oauth scopes required by this extension + Scopes *[]string `json:"scopes,omitempty"` + // The ServiceInstanceType(Guid) of the VSTS service that must be available to an account in order for the extension to be installed + ServiceInstanceType *uuid.UUID `json:"serviceInstanceType,omitempty"` +} + +// A request for an extension (to be installed or have a license assigned) +type ExtensionRequest struct { + // Required message supplied if the request is rejected + RejectMessage *string `json:"rejectMessage,omitempty"` + // Date at which the request was made + RequestDate *azuredevops.Time `json:"requestDate,omitempty"` + // Represents the user who made the request + RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` + // Optional message supplied by the requester justifying the request + RequestMessage *string `json:"requestMessage,omitempty"` + // Represents the state of the request + RequestState *ExtensionRequestState `json:"requestState,omitempty"` + // Date at which the request was resolved + ResolveDate *azuredevops.Time `json:"resolveDate,omitempty"` + // Represents the user who resolved the request + ResolvedBy *webapi.IdentityRef `json:"resolvedBy,omitempty"` +} + +type ExtensionRequestEvent struct { + // The extension which has been requested + Extension *gallery.PublishedExtension `json:"extension,omitempty"` + // Information about the host for which this extension is requested + Host *ExtensionHost `json:"host,omitempty"` + // Name of the collection for which the extension was requested + HostName *string `json:"hostName,omitempty"` + // Gallery host url + Links *ExtensionRequestUrls `json:"links,omitempty"` + // The extension request object + Request *ExtensionRequest `json:"request,omitempty"` + // The type of update that was made + UpdateType *ExtensionRequestUpdateType `json:"updateType,omitempty"` +} + +type ExtensionRequestsEvent struct { + // The extension which has been requested + Extension *gallery.PublishedExtension `json:"extension,omitempty"` + // Information about the host for which this extension is requested + Host *ExtensionHost `json:"host,omitempty"` + // Gallery host url + Links *ExtensionRequestUrls `json:"links,omitempty"` + // The extension request object + Requests *[]ExtensionRequest `json:"requests,omitempty"` + // The type of update that was made + UpdateType *ExtensionRequestUpdateType `json:"updateType,omitempty"` +} + +// Represents the state of an extension request +type ExtensionRequestState string + +type extensionRequestStateValuesType struct { + Open ExtensionRequestState + Accepted ExtensionRequestState + Rejected ExtensionRequestState +} + +var ExtensionRequestStateValues = extensionRequestStateValuesType{ + // The request has been opened, but not yet responded to + Open: "open", + // The request was accepted (extension installed or license assigned) + Accepted: "accepted", + // The request was rejected (extension not installed or license not assigned) + Rejected: "rejected", +} + +type ExtensionRequestUpdateType string + +type extensionRequestUpdateTypeValuesType struct { + Created ExtensionRequestUpdateType + Approved ExtensionRequestUpdateType + Rejected ExtensionRequestUpdateType + Deleted ExtensionRequestUpdateType +} + +var ExtensionRequestUpdateTypeValues = extensionRequestUpdateTypeValuesType{ + Created: "created", + Approved: "approved", + Rejected: "rejected", + Deleted: "deleted", +} + +type ExtensionRequestUrls struct { + // Url of the extension icon + ExtensionIcon *string `json:"extensionIcon,omitempty"` + // Link to view the extension details page + ExtensionPage *string `json:"extensionPage,omitempty"` + // Link to view the extension request + RequestPage *string `json:"requestPage,omitempty"` +} + +// The state of an extension +type ExtensionState struct { + // States of an installed extension + Flags *ExtensionStateFlags `json:"flags,omitempty"` + // List of installation issues + InstallationIssues *[]InstalledExtensionStateIssue `json:"installationIssues,omitempty"` + // The time at which this installation was last updated + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + ExtensionName *string `json:"extensionName,omitempty"` + // The time at which the version was last checked + LastVersionCheck *azuredevops.Time `json:"lastVersionCheck,omitempty"` + PublisherName *string `json:"publisherName,omitempty"` + Version *string `json:"version,omitempty"` +} + +// [Flags] States of an extension Note: If you add value to this enum, you need to do 2 other things. First add the back compat enum in value src\Vssf\Sdk\Server\Contributions\InstalledExtensionMessage.cs. Second, you can not send the new value on the message bus. You need to remove it from the message bus event prior to being sent. +type ExtensionStateFlags string + +type extensionStateFlagsValuesType struct { + None ExtensionStateFlags + Disabled ExtensionStateFlags + BuiltIn ExtensionStateFlags + MultiVersion ExtensionStateFlags + UnInstalled ExtensionStateFlags + VersionCheckError ExtensionStateFlags + Trusted ExtensionStateFlags + Error ExtensionStateFlags + NeedsReauthorization ExtensionStateFlags + AutoUpgradeError ExtensionStateFlags + Warning ExtensionStateFlags +} + +var ExtensionStateFlagsValues = extensionStateFlagsValuesType{ + // No flags set + None: "none", + // Extension is disabled + Disabled: "disabled", + // Extension is a built in + BuiltIn: "builtIn", + // Extension has multiple versions + MultiVersion: "multiVersion", + // Extension is not installed. This is for builtin extensions only and can not otherwise be set. + UnInstalled: "unInstalled", + // Error performing version check + VersionCheckError: "versionCheckError", + // Trusted extensions are ones that are given special capabilities. These tend to come from Microsoft and can't be published by the general public. Note: BuiltIn extensions are always trusted. + Trusted: "trusted", + // Extension is currently in an error state + Error: "error", + // Extension scopes have changed and the extension requires re-authorization + NeedsReauthorization: "needsReauthorization", + // Error performing auto-upgrade. For example, if the new version has demands not supported the extension cannot be auto-upgraded. + AutoUpgradeError: "autoUpgradeError", + // Extension is currently in a warning state, that can cause a degraded experience. The degraded experience can be caused for example by some installation issues detected such as implicit demands not supported. + Warning: "warning", +} + +type ExtensionUpdateType string + +type extensionUpdateTypeValuesType struct { + Installed ExtensionUpdateType + Uninstalled ExtensionUpdateType + Enabled ExtensionUpdateType + Disabled ExtensionUpdateType + VersionUpdated ExtensionUpdateType + ActionRequired ExtensionUpdateType + ActionResolved ExtensionUpdateType +} + +var ExtensionUpdateTypeValues = extensionUpdateTypeValuesType{ + Installed: "installed", + Uninstalled: "uninstalled", + Enabled: "enabled", + Disabled: "disabled", + VersionUpdated: "versionUpdated", + ActionRequired: "actionRequired", + ActionResolved: "actionResolved", +} + +type ExtensionUrls struct { + // Url of the extension icon + ExtensionIcon *string `json:"extensionIcon,omitempty"` + // Link to view the extension details page + ExtensionPage *string `json:"extensionPage,omitempty"` +} + +// Represents a VSTS extension along with its installation state +type InstalledExtension struct { + // Uri used as base for other relative uri's defined in extension + BaseUri *string `json:"baseUri,omitempty"` + // List of shared constraints defined by this extension + Constraints *[]ContributionConstraint `json:"constraints,omitempty"` + // List of contributions made by this extension + Contributions *[]Contribution `json:"contributions,omitempty"` + // List of contribution types defined by this extension + ContributionTypes *[]ContributionType `json:"contributionTypes,omitempty"` + // List of explicit demands required by this extension + Demands *[]string `json:"demands,omitempty"` + // Collection of endpoints that get called when particular extension events occur + EventCallbacks *ExtensionEventCallbackCollection `json:"eventCallbacks,omitempty"` + // Secondary location that can be used as base for other relative uri's defined in extension + FallbackBaseUri *string `json:"fallbackBaseUri,omitempty"` + // Language Culture Name set by the Gallery + Language *string `json:"language,omitempty"` + // How this extension behaves with respect to licensing + Licensing *ExtensionLicensing `json:"licensing,omitempty"` + // Version of the extension manifest format/content + ManifestVersion *float64 `json:"manifestVersion,omitempty"` + // Default user claims applied to all contributions (except the ones which have been specified restrictedTo explicitly) to control the visibility of a contribution. + RestrictedTo *[]string `json:"restrictedTo,omitempty"` + // List of all oauth scopes required by this extension + Scopes *[]string `json:"scopes,omitempty"` + // The ServiceInstanceType(Guid) of the VSTS service that must be available to an account in order for the extension to be installed + ServiceInstanceType *uuid.UUID `json:"serviceInstanceType,omitempty"` + // The friendly extension id for this extension - unique for a given publisher. + ExtensionId *string `json:"extensionId,omitempty"` + // The display name of the extension. + ExtensionName *string `json:"extensionName,omitempty"` + // This is the set of files available from the extension. + Files *[]gallery.ExtensionFile `json:"files,omitempty"` + // Extension flags relevant to contribution consumers + Flags *ExtensionFlags `json:"flags,omitempty"` + // Information about this particular installation of the extension + InstallState *InstalledExtensionState `json:"installState,omitempty"` + // This represents the date/time the extensions was last updated in the gallery. This doesnt mean this version was updated the value represents changes to any and all versions of the extension. + LastPublished *azuredevops.Time `json:"lastPublished,omitempty"` + // Unique id of the publisher of this extension + PublisherId *string `json:"publisherId,omitempty"` + // The display name of the publisher + PublisherName *string `json:"publisherName,omitempty"` + // Unique id for this extension (the same id is used for all versions of a single extension) + RegistrationId *uuid.UUID `json:"registrationId,omitempty"` + // Version of this extension + Version *string `json:"version,omitempty"` +} + +type InstalledExtensionQuery struct { + AssetTypes *[]string `json:"assetTypes,omitempty"` + Monikers *[]gallery.ExtensionIdentifier `json:"monikers,omitempty"` +} + +// The state of an installed extension +type InstalledExtensionState struct { + // States of an installed extension + Flags *ExtensionStateFlags `json:"flags,omitempty"` + // List of installation issues + InstallationIssues *[]InstalledExtensionStateIssue `json:"installationIssues,omitempty"` + // The time at which this installation was last updated + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` +} + +// Represents an installation issue +type InstalledExtensionStateIssue struct { + // The error message + Message *string `json:"message,omitempty"` + // Source of the installation issue, for example "Demands" + Source *string `json:"source,omitempty"` + // Installation issue type (Warning, Error) + Type *InstalledExtensionStateIssueType `json:"type,omitempty"` +} + +// Installation issue type (Warning, Error) +type InstalledExtensionStateIssueType string + +type installedExtensionStateIssueTypeValuesType struct { + Warning InstalledExtensionStateIssueType + Error InstalledExtensionStateIssueType +} + +var InstalledExtensionStateIssueTypeValues = installedExtensionStateIssueTypeValuesType{ + // Represents an installation warning, for example an implicit demand not supported + Warning: "warning", + // Represents an installation error, for example an explicit demand not supported + Error: "error", +} + +// Maps a contribution to a licensing behavior +type LicensingOverride struct { + // How the inclusion of this contribution should change based on licensing + Behavior *ContributionLicensingBehaviorType `json:"behavior,omitempty"` + // Fully qualified contribution id which we want to define licensing behavior for + Id *string `json:"id,omitempty"` +} + +// A request for an extension (to be installed or have a license assigned) +type RequestedExtension struct { + // The unique name of the extension + ExtensionName *string `json:"extensionName,omitempty"` + // A list of each request for the extension + ExtensionRequests *[]ExtensionRequest `json:"extensionRequests,omitempty"` + // DisplayName of the publisher that owns the extension being published. + PublisherDisplayName *string `json:"publisherDisplayName,omitempty"` + // Represents the Publisher of the requested extension + PublisherName *string `json:"publisherName,omitempty"` + // The total number of requests for an extension + RequestCount *int `json:"requestCount,omitempty"` +} + +// Entry for a specific data provider's resulting data +type ResolvedDataProvider struct { + // The total time the data provider took to resolve its data (in milliseconds) + Duration *float32 `json:"duration,omitempty"` + Error *string `json:"error,omitempty"` + Id *string `json:"id,omitempty"` +} + +type Scope struct { + Description *string `json:"description,omitempty"` + Title *string `json:"title,omitempty"` + Value *string `json:"value,omitempty"` +} + +// Information about the extension +type SupportedExtension struct { + // Unique Identifier for this extension + Extension *string `json:"extension,omitempty"` + // Unique Identifier for this publisher + Publisher *string `json:"publisher,omitempty"` + // Supported version for this extension + Version *string `json:"version,omitempty"` +} diff --git a/azuredevops/featureavailability/client.go b/azuredevops/featureavailability/client.go new file mode 100644 index 00000000..fcfe9a9a --- /dev/null +++ b/azuredevops/featureavailability/client.go @@ -0,0 +1,222 @@ +// -------------------------------------------------------------------------------------------- +// 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 featureavailability + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" +) + +type Client interface { + // [Preview API] Retrieve a listing of all feature flags and their current states for a user + GetAllFeatureFlags(context.Context, GetAllFeatureFlagsArgs) (*[]FeatureFlag, error) + // [Preview API] Retrieve information on a single feature flag and its current states + GetFeatureFlagByName(context.Context, GetFeatureFlagByNameArgs) (*FeatureFlag, error) + // [Preview API] Retrieve information on a single feature flag and its current states for a user + GetFeatureFlagByNameAndUserEmail(context.Context, GetFeatureFlagByNameAndUserEmailArgs) (*FeatureFlag, error) + // [Preview API] Retrieve information on a single feature flag and its current states for a user + GetFeatureFlagByNameAndUserId(context.Context, GetFeatureFlagByNameAndUserIdArgs) (*FeatureFlag, error) + // [Preview API] Change the state of an individual feature flag for a name + UpdateFeatureFlag(context.Context, UpdateFeatureFlagArgs) (*FeatureFlag, 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, + } +} + +// [Preview API] Retrieve a listing of all feature flags and their current states for a user +func (client *ClientImpl) GetAllFeatureFlags(ctx context.Context, args GetAllFeatureFlagsArgs) (*[]FeatureFlag, error) { + queryParams := url.Values{} + if args.UserEmail != nil { + queryParams.Add("userEmail", *args.UserEmail) + } + locationId, _ := uuid.Parse("3e2b80f8-9e6f-441e-8393-005610692d9c") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []FeatureFlag + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAllFeatureFlags function +type GetAllFeatureFlagsArgs struct { + // (optional) The email of the user to check + UserEmail *string +} + +// [Preview API] Retrieve information on a single feature flag and its current states +func (client *ClientImpl) GetFeatureFlagByName(ctx context.Context, args GetFeatureFlagByNameArgs) (*FeatureFlag, error) { + routeValues := make(map[string]string) + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + queryParams := url.Values{} + if args.CheckFeatureExists != nil { + queryParams.Add("checkFeatureExists", strconv.FormatBool(*args.CheckFeatureExists)) + } + locationId, _ := uuid.Parse("3e2b80f8-9e6f-441e-8393-005610692d9c") + 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 FeatureFlag + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeatureFlagByName function +type GetFeatureFlagByNameArgs struct { + // (required) The name of the feature to retrieve + Name *string + // (optional) Check if feature exists + CheckFeatureExists *bool +} + +// [Preview API] Retrieve information on a single feature flag and its current states for a user +func (client *ClientImpl) GetFeatureFlagByNameAndUserEmail(ctx context.Context, args GetFeatureFlagByNameAndUserEmailArgs) (*FeatureFlag, error) { + routeValues := make(map[string]string) + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + queryParams := url.Values{} + if args.UserEmail == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "userEmail"} + } + queryParams.Add("userEmail", *args.UserEmail) + if args.CheckFeatureExists != nil { + queryParams.Add("checkFeatureExists", strconv.FormatBool(*args.CheckFeatureExists)) + } + locationId, _ := uuid.Parse("3e2b80f8-9e6f-441e-8393-005610692d9c") + 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 FeatureFlag + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeatureFlagByNameAndUserEmail function +type GetFeatureFlagByNameAndUserEmailArgs struct { + // (required) The name of the feature to retrieve + Name *string + // (required) The email of the user to check + UserEmail *string + // (optional) Check if feature exists + CheckFeatureExists *bool +} + +// [Preview API] Retrieve information on a single feature flag and its current states for a user +func (client *ClientImpl) GetFeatureFlagByNameAndUserId(ctx context.Context, args GetFeatureFlagByNameAndUserIdArgs) (*FeatureFlag, error) { + routeValues := make(map[string]string) + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + queryParams := url.Values{} + if args.UserId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "userId"} + } + queryParams.Add("userId", (*args.UserId).String()) + if args.CheckFeatureExists != nil { + queryParams.Add("checkFeatureExists", strconv.FormatBool(*args.CheckFeatureExists)) + } + locationId, _ := uuid.Parse("3e2b80f8-9e6f-441e-8393-005610692d9c") + 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 FeatureFlag + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeatureFlagByNameAndUserId function +type GetFeatureFlagByNameAndUserIdArgs struct { + // (required) The name of the feature to retrieve + Name *string + // (required) The id of the user to check + UserId *uuid.UUID + // (optional) Check if feature exists + CheckFeatureExists *bool +} + +// [Preview API] Change the state of an individual feature flag for a name +func (client *ClientImpl) UpdateFeatureFlag(ctx context.Context, args UpdateFeatureFlagArgs) (*FeatureFlag, error) { + if args.State == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.State"} + } + routeValues := make(map[string]string) + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + queryParams := url.Values{} + if args.UserEmail != nil { + queryParams.Add("userEmail", *args.UserEmail) + } + if args.CheckFeatureExists != nil { + queryParams.Add("checkFeatureExists", strconv.FormatBool(*args.CheckFeatureExists)) + } + if args.SetAtApplicationLevelAlso != nil { + queryParams.Add("setAtApplicationLevelAlso", strconv.FormatBool(*args.SetAtApplicationLevelAlso)) + } + body, marshalErr := json.Marshal(*args.State) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("3e2b80f8-9e6f-441e-8393-005610692d9c") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue FeatureFlag + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateFeatureFlag function +type UpdateFeatureFlagArgs struct { + // (required) State that should be set + State *FeatureFlagPatch + // (required) The name of the feature to change + Name *string + // (optional) + UserEmail *string + // (optional) Checks if the feature exists before setting the state + CheckFeatureExists *bool + // (optional) + SetAtApplicationLevelAlso *bool +} diff --git a/azuredevops/featureavailability/models.go b/azuredevops/featureavailability/models.go new file mode 100644 index 00000000..147a8e5d --- /dev/null +++ b/azuredevops/featureavailability/models.go @@ -0,0 +1,22 @@ +// -------------------------------------------------------------------------------------------- +// 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 featureavailability + +type FeatureFlag struct { + Description *string `json:"description,omitempty"` + EffectiveState *string `json:"effectiveState,omitempty"` + ExplicitState *string `json:"explicitState,omitempty"` + Name *string `json:"name,omitempty"` + Uri *string `json:"uri,omitempty"` +} + +// This is passed to the FeatureFlagController to edit the status of a feature flag +type FeatureFlagPatch struct { + State *string `json:"state,omitempty"` +} diff --git a/azuredevops/featuremanagement/client.go b/azuredevops/featuremanagement/client.go new file mode 100644 index 00000000..cab96789 --- /dev/null +++ b/azuredevops/featuremanagement/client.go @@ -0,0 +1,393 @@ +// -------------------------------------------------------------------------------------------- +// 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 featuremanagement + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" +) + +type Client interface { + // [Preview API] Get a specific feature by its id + GetFeature(context.Context, GetFeatureArgs) (*ContributedFeature, error) + // [Preview API] Get a list of all defined features + GetFeatures(context.Context, GetFeaturesArgs) (*[]ContributedFeature, error) + // [Preview API] Get the state of the specified feature for the given user/all-users scope + GetFeatureState(context.Context, GetFeatureStateArgs) (*ContributedFeatureState, error) + // [Preview API] Get the state of the specified feature for the given named scope + GetFeatureStateForScope(context.Context, GetFeatureStateForScopeArgs) (*ContributedFeatureState, error) + // [Preview API] Get the effective state for a list of feature ids + QueryFeatureStates(context.Context, QueryFeatureStatesArgs) (*ContributedFeatureStateQuery, error) + // [Preview API] Get the states of the specified features for the default scope + QueryFeatureStatesForDefaultScope(context.Context, QueryFeatureStatesForDefaultScopeArgs) (*ContributedFeatureStateQuery, error) + // [Preview API] Get the states of the specified features for the specific named scope + QueryFeatureStatesForNamedScope(context.Context, QueryFeatureStatesForNamedScopeArgs) (*ContributedFeatureStateQuery, error) + // [Preview API] Set the state of a feature + SetFeatureState(context.Context, SetFeatureStateArgs) (*ContributedFeatureState, error) + // [Preview API] Set the state of a feature at a specific scope + SetFeatureStateForScope(context.Context, SetFeatureStateForScopeArgs) (*ContributedFeatureState, 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, + } +} + +// [Preview API] Get a specific feature by its id +func (client *ClientImpl) GetFeature(ctx context.Context, args GetFeatureArgs) (*ContributedFeature, error) { + routeValues := make(map[string]string) + if args.FeatureId == nil || *args.FeatureId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeatureId"} + } + routeValues["featureId"] = *args.FeatureId + + locationId, _ := uuid.Parse("c4209f25-7a27-41dd-9f04-06080c7b6afd") + 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 ContributedFeature + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeature function +type GetFeatureArgs struct { + // (required) The contribution id of the feature + FeatureId *string +} + +// [Preview API] Get a list of all defined features +func (client *ClientImpl) GetFeatures(ctx context.Context, args GetFeaturesArgs) (*[]ContributedFeature, error) { + queryParams := url.Values{} + if args.TargetContributionId != nil { + queryParams.Add("targetContributionId", *args.TargetContributionId) + } + locationId, _ := uuid.Parse("c4209f25-7a27-41dd-9f04-06080c7b6afd") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []ContributedFeature + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeatures function +type GetFeaturesArgs struct { + // (optional) Optional target contribution. If null/empty, return all features. If specified include the features that target the specified contribution. + TargetContributionId *string +} + +// [Preview API] Get the state of the specified feature for the given user/all-users scope +func (client *ClientImpl) GetFeatureState(ctx context.Context, args GetFeatureStateArgs) (*ContributedFeatureState, error) { + routeValues := make(map[string]string) + if args.FeatureId == nil || *args.FeatureId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeatureId"} + } + routeValues["featureId"] = *args.FeatureId + if args.UserScope == nil || *args.UserScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + + locationId, _ := uuid.Parse("98911314-3f9b-4eaf-80e8-83900d8e85d9") + 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 ContributedFeatureState + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeatureState function +type GetFeatureStateArgs struct { + // (required) Contribution id of the feature + FeatureId *string + // (required) User-Scope at which to get the value. Should be "me" for the current user or "host" for all users. + UserScope *string +} + +// [Preview API] Get the state of the specified feature for the given named scope +func (client *ClientImpl) GetFeatureStateForScope(ctx context.Context, args GetFeatureStateForScopeArgs) (*ContributedFeatureState, error) { + routeValues := make(map[string]string) + if args.FeatureId == nil || *args.FeatureId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeatureId"} + } + routeValues["featureId"] = *args.FeatureId + if args.UserScope == nil || *args.UserScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + if args.ScopeName == nil || *args.ScopeName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeName"} + } + routeValues["scopeName"] = *args.ScopeName + if args.ScopeValue == nil || *args.ScopeValue == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeValue"} + } + routeValues["scopeValue"] = *args.ScopeValue + + locationId, _ := uuid.Parse("dd291e43-aa9f-4cee-8465-a93c78e414a4") + 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 ContributedFeatureState + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeatureStateForScope function +type GetFeatureStateForScopeArgs struct { + // (required) Contribution id of the feature + FeatureId *string + // (required) User-Scope at which to get the value. Should be "me" for the current user or "host" for all users. + UserScope *string + // (required) Scope at which to get the feature setting for (e.g. "project" or "team") + ScopeName *string + // (required) Value of the scope (e.g. the project or team id) + ScopeValue *string +} + +// [Preview API] Get the effective state for a list of feature ids +func (client *ClientImpl) QueryFeatureStates(ctx context.Context, args QueryFeatureStatesArgs) (*ContributedFeatureStateQuery, error) { + if args.Query == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"} + } + body, marshalErr := json.Marshal(*args.Query) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2b4486ad-122b-400c-ae65-17b6672c1f9d") + 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 ContributedFeatureStateQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryFeatureStates function +type QueryFeatureStatesArgs struct { + // (required) Features to query along with current scope values + Query *ContributedFeatureStateQuery +} + +// [Preview API] Get the states of the specified features for the default scope +func (client *ClientImpl) QueryFeatureStatesForDefaultScope(ctx context.Context, args QueryFeatureStatesForDefaultScopeArgs) (*ContributedFeatureStateQuery, error) { + if args.Query == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"} + } + routeValues := make(map[string]string) + if args.UserScope == nil || *args.UserScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + + body, marshalErr := json.Marshal(*args.Query) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("3f810f28-03e2-4239-b0bc-788add3005e5") + 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 ContributedFeatureStateQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryFeatureStatesForDefaultScope function +type QueryFeatureStatesForDefaultScopeArgs struct { + // (required) Query describing the features to query. + Query *ContributedFeatureStateQuery + // (required) + UserScope *string +} + +// [Preview API] Get the states of the specified features for the specific named scope +func (client *ClientImpl) QueryFeatureStatesForNamedScope(ctx context.Context, args QueryFeatureStatesForNamedScopeArgs) (*ContributedFeatureStateQuery, error) { + if args.Query == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"} + } + routeValues := make(map[string]string) + if args.UserScope == nil || *args.UserScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + if args.ScopeName == nil || *args.ScopeName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeName"} + } + routeValues["scopeName"] = *args.ScopeName + if args.ScopeValue == nil || *args.ScopeValue == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeValue"} + } + routeValues["scopeValue"] = *args.ScopeValue + + body, marshalErr := json.Marshal(*args.Query) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("f29e997b-c2da-4d15-8380-765788a1a74c") + 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 ContributedFeatureStateQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryFeatureStatesForNamedScope function +type QueryFeatureStatesForNamedScopeArgs struct { + // (required) Query describing the features to query. + Query *ContributedFeatureStateQuery + // (required) + UserScope *string + // (required) + ScopeName *string + // (required) + ScopeValue *string +} + +// [Preview API] Set the state of a feature +func (client *ClientImpl) SetFeatureState(ctx context.Context, args SetFeatureStateArgs) (*ContributedFeatureState, error) { + if args.Feature == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Feature"} + } + routeValues := make(map[string]string) + if args.FeatureId == nil || *args.FeatureId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeatureId"} + } + routeValues["featureId"] = *args.FeatureId + if args.UserScope == nil || *args.UserScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + + queryParams := url.Values{} + if args.Reason != nil { + queryParams.Add("reason", *args.Reason) + } + if args.ReasonCode != nil { + queryParams.Add("reasonCode", *args.ReasonCode) + } + body, marshalErr := json.Marshal(*args.Feature) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("98911314-3f9b-4eaf-80e8-83900d8e85d9") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ContributedFeatureState + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the SetFeatureState function +type SetFeatureStateArgs struct { + // (required) Posted feature state object. Should specify the effective value. + Feature *ContributedFeatureState + // (required) Contribution id of the feature + FeatureId *string + // (required) User-Scope at which to set the value. Should be "me" for the current user or "host" for all users. + UserScope *string + // (optional) Reason for changing the state + Reason *string + // (optional) Short reason code + ReasonCode *string +} + +// [Preview API] Set the state of a feature at a specific scope +func (client *ClientImpl) SetFeatureStateForScope(ctx context.Context, args SetFeatureStateForScopeArgs) (*ContributedFeatureState, error) { + if args.Feature == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Feature"} + } + routeValues := make(map[string]string) + if args.FeatureId == nil || *args.FeatureId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeatureId"} + } + routeValues["featureId"] = *args.FeatureId + if args.UserScope == nil || *args.UserScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + if args.ScopeName == nil || *args.ScopeName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeName"} + } + routeValues["scopeName"] = *args.ScopeName + if args.ScopeValue == nil || *args.ScopeValue == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeValue"} + } + routeValues["scopeValue"] = *args.ScopeValue + + queryParams := url.Values{} + if args.Reason != nil { + queryParams.Add("reason", *args.Reason) + } + if args.ReasonCode != nil { + queryParams.Add("reasonCode", *args.ReasonCode) + } + body, marshalErr := json.Marshal(*args.Feature) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("dd291e43-aa9f-4cee-8465-a93c78e414a4") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ContributedFeatureState + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the SetFeatureStateForScope function +type SetFeatureStateForScopeArgs struct { + // (required) Posted feature state object. Should specify the effective value. + Feature *ContributedFeatureState + // (required) Contribution id of the feature + FeatureId *string + // (required) User-Scope at which to set the value. Should be "me" for the current user or "host" for all users. + UserScope *string + // (required) Scope at which to get the feature setting for (e.g. "project" or "team") + ScopeName *string + // (required) Value of the scope (e.g. the project or team id) + ScopeValue *string + // (optional) Reason for changing the state + Reason *string + // (optional) Short reason code + ReasonCode *string +} diff --git a/azuredevops/featuremanagement/models.go b/azuredevops/featuremanagement/models.go new file mode 100644 index 00000000..a45bf2c9 --- /dev/null +++ b/azuredevops/featuremanagement/models.go @@ -0,0 +1,118 @@ +// -------------------------------------------------------------------------------------------- +// 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 featuremanagement + +import ( + "github.com/google/uuid" +) + +// A feature that can be enabled or disabled +type ContributedFeature struct { + // Named links describing the feature + Links interface{} `json:"_links,omitempty"` + // If true, the feature is enabled unless overridden at some scope + DefaultState *bool `json:"defaultState,omitempty"` + // Rules for setting the default value if not specified by any setting/scope. Evaluated in order until a rule returns an Enabled or Disabled state (not Undefined) + DefaultValueRules *[]ContributedFeatureValueRule `json:"defaultValueRules,omitempty"` + // The description of the feature + Description *string `json:"description,omitempty"` + // Extra properties for the feature + FeatureProperties *map[string]interface{} `json:"featureProperties,omitempty"` + // Handler for listening to setter calls on feature value. These listeners are only invoked after a successful set has occurred + FeatureStateChangedListeners *[]ContributedFeatureListener `json:"featureStateChangedListeners,omitempty"` + // The full contribution id of the feature + Id *string `json:"id,omitempty"` + // If this is set to true, then the id for this feature will be added to the list of claims for the request. + IncludeAsClaim *bool `json:"includeAsClaim,omitempty"` + // The friendly name of the feature + Name *string `json:"name,omitempty"` + // Suggested order to display feature in. + Order *int `json:"order,omitempty"` + // Rules for overriding a feature value. These rules are run before explicit user/host state values are checked. They are evaluated in order until a rule returns an Enabled or Disabled state (not Undefined) + OverrideRules *[]ContributedFeatureValueRule `json:"overrideRules,omitempty"` + // The scopes/levels at which settings can set the enabled/disabled state of this feature + Scopes *[]ContributedFeatureSettingScope `json:"scopes,omitempty"` + // The service instance id of the service that owns this feature + ServiceInstanceType *uuid.UUID `json:"serviceInstanceType,omitempty"` + // Tags associated with the feature. + Tags *[]string `json:"tags,omitempty"` +} + +// The current state of a feature within a given scope +type ContributedFeatureEnabledValue string + +type contributedFeatureEnabledValueValuesType struct { + Undefined ContributedFeatureEnabledValue + Disabled ContributedFeatureEnabledValue + Enabled ContributedFeatureEnabledValue +} + +var ContributedFeatureEnabledValueValues = contributedFeatureEnabledValueValuesType{ + // The state of the feature is not set for the specified scope + Undefined: "undefined", + // The feature is disabled at the specified scope + Disabled: "disabled", + // The feature is enabled at the specified scope + Enabled: "enabled", +} + +type ContributedFeatureHandlerSettings struct { + // Name of the handler to run + Name *string `json:"name,omitempty"` + // Properties to feed to the handler + Properties *map[string]interface{} `json:"properties,omitempty"` +} + +// An identifier and properties used to pass into a handler for a listener or plugin +type ContributedFeatureListener struct { + // Name of the handler to run + Name *string `json:"name,omitempty"` + // Properties to feed to the handler + Properties *map[string]interface{} `json:"properties,omitempty"` +} + +// The scope to which a feature setting applies +type ContributedFeatureSettingScope struct { + // The name of the settings scope to use when reading/writing the setting + SettingScope *string `json:"settingScope,omitempty"` + // Whether this is a user-scope or this is a host-wide (all users) setting + UserScoped *bool `json:"userScoped,omitempty"` +} + +// A contributed feature/state pair +type ContributedFeatureState struct { + // The full contribution id of the feature + FeatureId *string `json:"featureId,omitempty"` + // True if the effective state was set by an override rule (indicating that the state cannot be managed by the end user) + Overridden *bool `json:"overridden,omitempty"` + // Reason that the state was set (by a plugin/rule). + Reason *string `json:"reason,omitempty"` + // The scope at which this state applies + Scope *ContributedFeatureSettingScope `json:"scope,omitempty"` + // The current state of this feature + State *ContributedFeatureEnabledValue `json:"state,omitempty"` +} + +// A query for the effective contributed feature states for a list of feature ids +type ContributedFeatureStateQuery struct { + // The list of feature ids to query + FeatureIds *[]string `json:"featureIds,omitempty"` + // The query result containing the current feature states for each of the queried feature ids + FeatureStates *map[string]ContributedFeatureState `json:"featureStates,omitempty"` + // A dictionary of scope values (project name, etc.) to use in the query (if querying across scopes) + ScopeValues *map[string]string `json:"scopeValues,omitempty"` +} + +// A rule for dynamically getting the enabled/disabled state of a feature +type ContributedFeatureValueRule struct { + // Name of the handler to run + Name *string `json:"name,omitempty"` + // Properties to feed to the handler + Properties *map[string]interface{} `json:"properties,omitempty"` +} diff --git a/azuredevops/feed/client.go b/azuredevops/feed/client.go new file mode 100644 index 00000000..fdc3d77b --- /dev/null +++ b/azuredevops/feed/client.go @@ -0,0 +1,1433 @@ +// -------------------------------------------------------------------------------------------- +// 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 feed + +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("7ab4e64e-c4d8-4f50-ae73-5ef2e21642a5") + +type Client interface { + // [Preview API] Create a feed, a container for various package types. + CreateFeed(context.Context, CreateFeedArgs) (*Feed, error) + // [Preview API] Create a new view on the referenced feed. + CreateFeedView(context.Context, CreateFeedViewArgs) (*FeedView, error) + // [Preview API] Remove a feed and all its packages. The action does not result in packages moving to the RecycleBin and is not reversible. + DeleteFeed(context.Context, DeleteFeedArgs) error + // [Preview API] Delete the retention policy for a feed. + DeleteFeedRetentionPolicies(context.Context, DeleteFeedRetentionPoliciesArgs) error + // [Preview API] Delete a feed view. + DeleteFeedView(context.Context, DeleteFeedViewArgs) error + // [Preview API] Generate a SVG badge for the latest version of a package. The generated SVG is typically used as the image in an HTML link which takes users to the feed containing the package to accelerate discovery and consumption. + GetBadge(context.Context, GetBadgeArgs) (*string, error) + // [Preview API] Get the settings for a specific feed. + GetFeed(context.Context, GetFeedArgs) (*Feed, error) + // [Preview API] Query a feed to determine its current state. + GetFeedChange(context.Context, GetFeedChangeArgs) (*FeedChange, error) + // [Preview API] Query to determine which feeds have changed since the last call, tracked through the provided continuationToken. Only changes to a feed itself are returned and impact the continuationToken, not additions or alterations to packages within the feeds. + GetFeedChanges(context.Context, GetFeedChangesArgs) (*FeedChangesResponse, error) + // [Preview API] Get the permissions for a feed. + GetFeedPermissions(context.Context, GetFeedPermissionsArgs) (*[]FeedPermission, error) + // [Preview API] Get the retention policy for a feed. + GetFeedRetentionPolicies(context.Context, GetFeedRetentionPoliciesArgs) (*FeedRetentionPolicy, error) + // [Preview API] Get all feeds in an account where you have the provided role access. + GetFeeds(context.Context, GetFeedsArgs) (*[]Feed, error) + // [Preview API] Get a view by Id. + GetFeedView(context.Context, GetFeedViewArgs) (*FeedView, error) + // [Preview API] Get all views for a feed. + GetFeedViews(context.Context, GetFeedViewsArgs) (*[]FeedView, error) + // [Preview API] Get all service-wide feed creation and administration permissions. + GetGlobalPermissions(context.Context, GetGlobalPermissionsArgs) (*[]GlobalPermission, error) + // [Preview API] Get details about a specific package. + GetPackage(context.Context, GetPackageArgs) (*Package, error) + // [Preview API] Get a batch of package changes made to a feed. The changes returned are 'most recent change' so if an Add is followed by an Update before you begin enumerating, you'll only see one change in the batch. While consuming batches using the continuation token, you may see changes to the same package version multiple times if they are happening as you enumerate. + GetPackageChanges(context.Context, GetPackageChangesArgs) (*PackageChangesResponse, error) + // [Preview API] Get details about all of the packages in the feed. Use the various filters to include or exclude information from the result set. + GetPackages(context.Context, GetPackagesArgs) (*[]Package, error) + // [Preview API] Get details about a specific package version. + GetPackageVersion(context.Context, GetPackageVersionArgs) (*PackageVersion, error) + // [Preview API] Gets provenance for a package version. + GetPackageVersionProvenance(context.Context, GetPackageVersionProvenanceArgs) (*PackageVersionProvenance, error) + // [Preview API] Get a list of package versions, optionally filtering by state. + GetPackageVersions(context.Context, GetPackageVersionsArgs) (*[]PackageVersion, error) + // [Preview API] Get information about a package and all its versions within the recycle bin. + GetRecycleBinPackage(context.Context, GetRecycleBinPackageArgs) (*Package, error) + // [Preview API] Query for packages within the recycle bin. + GetRecycleBinPackages(context.Context, GetRecycleBinPackagesArgs) (*[]Package, error) + // [Preview API] Get information about a package version within the recycle bin. + GetRecycleBinPackageVersion(context.Context, GetRecycleBinPackageVersionArgs) (*RecycleBinPackageVersion, error) + // [Preview API] Get a list of package versions within the recycle bin. + GetRecycleBinPackageVersions(context.Context, GetRecycleBinPackageVersionsArgs) (*[]RecycleBinPackageVersion, error) + // [Preview API] + QueryPackageMetrics(context.Context, QueryPackageMetricsArgs) (*[]PackageMetrics, error) + // [Preview API] + QueryPackageVersionMetrics(context.Context, QueryPackageVersionMetricsArgs) (*[]PackageVersionMetrics, error) + // [Preview API] Update the permissions on a feed. + SetFeedPermissions(context.Context, SetFeedPermissionsArgs) (*[]FeedPermission, error) + // [Preview API] Set the retention policy for a feed. + SetFeedRetentionPolicies(context.Context, SetFeedRetentionPoliciesArgs) (*FeedRetentionPolicy, error) + // [Preview API] Set service-wide permissions that govern feed creation and administration. + SetGlobalPermissions(context.Context, SetGlobalPermissionsArgs) (*[]GlobalPermission, error) + // [Preview API] Change the attributes of a feed. + UpdateFeed(context.Context, UpdateFeedArgs) (*Feed, error) + // [Preview API] Update a view. + UpdateFeedView(context.Context, UpdateFeedViewArgs) (*FeedView, 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 a feed, a container for various package types. +func (client *ClientImpl) CreateFeed(ctx context.Context, args CreateFeedArgs) (*Feed, error) { + if args.Feed == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Feed"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.Feed) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("c65009a7-474a-4ad1-8b42-7d852107ef8c") + 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 Feed + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateFeed function +type CreateFeedArgs struct { + // (required) A JSON object containing both required and optional attributes for the feed. Name is the only required value. + Feed *Feed + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Create a new view on the referenced feed. +func (client *ClientImpl) CreateFeedView(ctx context.Context, args CreateFeedViewArgs) (*FeedView, error) { + if args.View == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.View"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + body, marshalErr := json.Marshal(*args.View) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("42a8502a-6785-41bc-8c16-89477d930877") + 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 FeedView + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateFeedView function +type CreateFeedViewArgs struct { + // (required) View to be created. + View *FeedView + // (required) Name or Id of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Remove a feed and all its packages. The action does not result in packages moving to the RecycleBin and is not reversible. +func (client *ClientImpl) DeleteFeed(ctx context.Context, args DeleteFeedArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + locationId, _ := uuid.Parse("c65009a7-474a-4ad1-8b42-7d852107ef8c") + _, 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 DeleteFeed function +type DeleteFeedArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Delete the retention policy for a feed. +func (client *ClientImpl) DeleteFeedRetentionPolicies(ctx context.Context, args DeleteFeedRetentionPoliciesArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + locationId, _ := uuid.Parse("ed52a011-0112-45b5-9f9e-e14efffb3193") + _, 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 DeleteFeedRetentionPolicies function +type DeleteFeedRetentionPoliciesArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Delete a feed view. +func (client *ClientImpl) DeleteFeedView(ctx context.Context, args DeleteFeedViewArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.ViewId == nil || *args.ViewId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ViewId"} + } + routeValues["viewId"] = *args.ViewId + + locationId, _ := uuid.Parse("42a8502a-6785-41bc-8c16-89477d930877") + _, 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 DeleteFeedView function +type DeleteFeedViewArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (required) Name or Id of the view. + ViewId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Generate a SVG badge for the latest version of a package. The generated SVG is typically used as the image in an HTML link which takes users to the feed containing the package to accelerate discovery and consumption. +func (client *ClientImpl) GetBadge(ctx context.Context, args GetBadgeArgs) (*string, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageId"} + } + routeValues["packageId"] = (*args.PackageId).String() + + locationId, _ := uuid.Parse("61d885fd-10f3-4a55-82b6-476d866b673f") + 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 string + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBadge function +type GetBadgeArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (required) Id of the package (GUID Id, not name). + PackageId *uuid.UUID + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get the settings for a specific feed. +func (client *ClientImpl) GetFeed(ctx context.Context, args GetFeedArgs) (*Feed, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + queryParams := url.Values{} + if args.IncludeDeletedUpstreams != nil { + queryParams.Add("includeDeletedUpstreams", strconv.FormatBool(*args.IncludeDeletedUpstreams)) + } + locationId, _ := uuid.Parse("c65009a7-474a-4ad1-8b42-7d852107ef8c") + 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 Feed + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeed function +type GetFeedArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string + // (optional) Include upstreams that have been deleted in the response. + IncludeDeletedUpstreams *bool +} + +// [Preview API] Query a feed to determine its current state. +func (client *ClientImpl) GetFeedChange(ctx context.Context, args GetFeedChangeArgs) (*FeedChange, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + locationId, _ := uuid.Parse("29ba2dad-389a-4661-b5d3-de76397ca05b") + 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 FeedChange + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeedChange function +type GetFeedChangeArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Query to determine which feeds have changed since the last call, tracked through the provided continuationToken. Only changes to a feed itself are returned and impact the continuationToken, not additions or alterations to packages within the feeds. +func (client *ClientImpl) GetFeedChanges(ctx context.Context, args GetFeedChangesArgs) (*FeedChangesResponse, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.IncludeDeleted != nil { + queryParams.Add("includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", strconv.FormatUint(*args.ContinuationToken, 10)) + } + if args.BatchSize != nil { + queryParams.Add("batchSize", strconv.Itoa(*args.BatchSize)) + } + locationId, _ := uuid.Parse("29ba2dad-389a-4661-b5d3-de76397ca05b") + 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 FeedChangesResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeedChanges function +type GetFeedChangesArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) If true, get changes for all feeds including deleted feeds. The default value is false. + IncludeDeleted *bool + // (optional) A continuation token which acts as a bookmark to a previously retrieved change. This token allows the user to continue retrieving changes in batches, picking up where the previous batch left off. If specified, all the changes that occur strictly after the token will be returned. If not specified or 0, iteration will start with the first change. + ContinuationToken *uint64 + // (optional) Number of package changes to fetch. The default value is 1000. The maximum value is 2000. + BatchSize *int +} + +// [Preview API] Get the permissions for a feed. +func (client *ClientImpl) GetFeedPermissions(ctx context.Context, args GetFeedPermissionsArgs) (*[]FeedPermission, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + queryParams := url.Values{} + if args.IncludeIds != nil { + queryParams.Add("includeIds", strconv.FormatBool(*args.IncludeIds)) + } + if args.ExcludeInheritedPermissions != nil { + queryParams.Add("excludeInheritedPermissions", strconv.FormatBool(*args.ExcludeInheritedPermissions)) + } + if args.IdentityDescriptor != nil { + queryParams.Add("identityDescriptor", *args.IdentityDescriptor) + } + locationId, _ := uuid.Parse("be8c1476-86a7-44ed-b19d-aec0e9275cd8") + 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 []FeedPermission + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeedPermissions function +type GetFeedPermissionsArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string + // (optional) True to include user Ids in the response. Default is false. + IncludeIds *bool + // (optional) True to only return explicitly set permissions on the feed. Default is false. + ExcludeInheritedPermissions *bool + // (optional) Filter permissions to the provided identity. + IdentityDescriptor *string +} + +// [Preview API] Get the retention policy for a feed. +func (client *ClientImpl) GetFeedRetentionPolicies(ctx context.Context, args GetFeedRetentionPoliciesArgs) (*FeedRetentionPolicy, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + locationId, _ := uuid.Parse("ed52a011-0112-45b5-9f9e-e14efffb3193") + 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 FeedRetentionPolicy + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeedRetentionPolicies function +type GetFeedRetentionPoliciesArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get all feeds in an account where you have the provided role access. +func (client *ClientImpl) GetFeeds(ctx context.Context, args GetFeedsArgs) (*[]Feed, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.FeedRole != nil { + queryParams.Add("feedRole", string(*args.FeedRole)) + } + if args.IncludeDeletedUpstreams != nil { + queryParams.Add("includeDeletedUpstreams", strconv.FormatBool(*args.IncludeDeletedUpstreams)) + } + locationId, _ := uuid.Parse("c65009a7-474a-4ad1-8b42-7d852107ef8c") + 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 []Feed + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeeds function +type GetFeedsArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) Filter by this role, either Administrator(4), Contributor(3), or Reader(2) level permissions. + FeedRole *FeedRole + // (optional) Include upstreams that have been deleted in the response. + IncludeDeletedUpstreams *bool +} + +// [Preview API] Get a view by Id. +func (client *ClientImpl) GetFeedView(ctx context.Context, args GetFeedViewArgs) (*FeedView, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.ViewId == nil || *args.ViewId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ViewId"} + } + routeValues["viewId"] = *args.ViewId + + locationId, _ := uuid.Parse("42a8502a-6785-41bc-8c16-89477d930877") + 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 FeedView + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeedView function +type GetFeedViewArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (required) Name or Id of the view. + ViewId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get all views for a feed. +func (client *ClientImpl) GetFeedViews(ctx context.Context, args GetFeedViewsArgs) (*[]FeedView, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + locationId, _ := uuid.Parse("42a8502a-6785-41bc-8c16-89477d930877") + 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 []FeedView + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFeedViews function +type GetFeedViewsArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get all service-wide feed creation and administration permissions. +func (client *ClientImpl) GetGlobalPermissions(ctx context.Context, args GetGlobalPermissionsArgs) (*[]GlobalPermission, error) { + queryParams := url.Values{} + if args.IncludeIds != nil { + queryParams.Add("includeIds", strconv.FormatBool(*args.IncludeIds)) + } + locationId, _ := uuid.Parse("a74419ef-b477-43df-8758-3cd1cd5f56c6") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GlobalPermission + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetGlobalPermissions function +type GetGlobalPermissionsArgs struct { + // (optional) Set to true to add IdentityIds to the permission objects. + IncludeIds *bool +} + +// [Preview API] Get details about a specific package. +func (client *ClientImpl) GetPackage(ctx context.Context, args GetPackageArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageId == nil || *args.PackageId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageId"} + } + routeValues["packageId"] = *args.PackageId + + queryParams := url.Values{} + if args.IncludeAllVersions != nil { + queryParams.Add("includeAllVersions", strconv.FormatBool(*args.IncludeAllVersions)) + } + if args.IncludeUrls != nil { + queryParams.Add("includeUrls", strconv.FormatBool(*args.IncludeUrls)) + } + if args.IsListed != nil { + queryParams.Add("isListed", strconv.FormatBool(*args.IsListed)) + } + if args.IsRelease != nil { + queryParams.Add("isRelease", strconv.FormatBool(*args.IsRelease)) + } + if args.IncludeDeleted != nil { + queryParams.Add("includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + if args.IncludeDescription != nil { + queryParams.Add("includeDescription", strconv.FormatBool(*args.IncludeDescription)) + } + locationId, _ := uuid.Parse("7a20d846-c929-4acc-9ea2-0d5a7df1b197") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackage function +type GetPackageArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (required) The package Id (GUID Id, not the package name). + PackageId *string + // (optional) Project ID or project name + Project *string + // (optional) True to return all versions of the package in the response. Default is false (latest version only). + IncludeAllVersions *bool + // (optional) True to return REST Urls with the response. Default is True. + IncludeUrls *bool + // (optional) Only applicable for NuGet packages, setting it for other package types will result in a 404. If false, delisted package versions will be returned. Use this to filter the response when includeAllVersions is set to true. Default is unset (do not return delisted packages). + IsListed *bool + // (optional) Only applicable for Nuget packages. Use this to filter the response when includeAllVersions is set to true. Default is True (only return packages without prerelease versioning). + IsRelease *bool + // (optional) Return deleted or unpublished versions of packages in the response. Default is False. + IncludeDeleted *bool + // (optional) Return the description for every version of each package in the response. Default is False. + IncludeDescription *bool +} + +// [Preview API] Get a batch of package changes made to a feed. The changes returned are 'most recent change' so if an Add is followed by an Update before you begin enumerating, you'll only see one change in the batch. While consuming batches using the continuation token, you may see changes to the same package version multiple times if they are happening as you enumerate. +func (client *ClientImpl) GetPackageChanges(ctx context.Context, args GetPackageChangesArgs) (*PackageChangesResponse, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + queryParams := url.Values{} + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", strconv.FormatUint(*args.ContinuationToken, 10)) + } + if args.BatchSize != nil { + queryParams.Add("batchSize", strconv.Itoa(*args.BatchSize)) + } + locationId, _ := uuid.Parse("323a0631-d083-4005-85ae-035114dfb681") + 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 PackageChangesResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageChanges function +type GetPackageChangesArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string + // (optional) A continuation token which acts as a bookmark to a previously retrieved change. This token allows the user to continue retrieving changes in batches, picking up where the previous batch left off. If specified, all the changes that occur strictly after the token will be returned. If not specified or 0, iteration will start with the first change. + ContinuationToken *uint64 + // (optional) Number of package changes to fetch. The default value is 1000. The maximum value is 2000. + BatchSize *int +} + +// [Preview API] Get details about all of the packages in the feed. Use the various filters to include or exclude information from the result set. +func (client *ClientImpl) GetPackages(ctx context.Context, args GetPackagesArgs) (*[]Package, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + queryParams := url.Values{} + if args.ProtocolType != nil { + queryParams.Add("protocolType", *args.ProtocolType) + } + if args.PackageNameQuery != nil { + queryParams.Add("packageNameQuery", *args.PackageNameQuery) + } + if args.NormalizedPackageName != nil { + queryParams.Add("normalizedPackageName", *args.NormalizedPackageName) + } + if args.IncludeUrls != nil { + queryParams.Add("includeUrls", strconv.FormatBool(*args.IncludeUrls)) + } + if args.IncludeAllVersions != nil { + queryParams.Add("includeAllVersions", strconv.FormatBool(*args.IncludeAllVersions)) + } + if args.IsListed != nil { + queryParams.Add("isListed", strconv.FormatBool(*args.IsListed)) + } + if args.GetTopPackageVersions != nil { + queryParams.Add("getTopPackageVersions", strconv.FormatBool(*args.GetTopPackageVersions)) + } + if args.IsRelease != nil { + queryParams.Add("isRelease", strconv.FormatBool(*args.IsRelease)) + } + if args.IncludeDescription != nil { + queryParams.Add("includeDescription", strconv.FormatBool(*args.IncludeDescription)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.IncludeDeleted != nil { + queryParams.Add("includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + if args.IsCached != nil { + queryParams.Add("isCached", strconv.FormatBool(*args.IsCached)) + } + if args.DirectUpstreamId != nil { + queryParams.Add("directUpstreamId", (*args.DirectUpstreamId).String()) + } + locationId, _ := uuid.Parse("7a20d846-c929-4acc-9ea2-0d5a7df1b197") + 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 []Package + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackages function +type GetPackagesArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string + // (optional) One of the supported artifact package types. + ProtocolType *string + // (optional) Filter to packages that contain the provided string. Characters in the string must conform to the package name constraints. + PackageNameQuery *string + // (optional) [Obsolete] Used for legacy scenarios and may be removed in future versions. + NormalizedPackageName *string + // (optional) True to return REST Urls with the response. Default is True. + IncludeUrls *bool + // (optional) True to return all versions of the package in the response. Default is false (latest version only). + IncludeAllVersions *bool + // (optional) Only applicable for NuGet packages, setting it for other package types will result in a 404. If false, delisted package versions will be returned. Use this to filter the response when includeAllVersions is set to true. Default is unset (do not return delisted packages). + IsListed *bool + // (optional) Changes the behavior of $top and $skip to return all versions of each package up to $top. Must be used in conjunction with includeAllVersions=true + GetTopPackageVersions *bool + // (optional) Only applicable for Nuget packages. Use this to filter the response when includeAllVersions is set to true. Default is True (only return packages without prerelease versioning). + IsRelease *bool + // (optional) Return the description for every version of each package in the response. Default is False. + IncludeDescription *bool + // (optional) Get the top N packages (or package versions where getTopPackageVersions=true) + Top *int + // (optional) Skip the first N packages (or package versions where getTopPackageVersions=true) + Skip *int + // (optional) Return deleted or unpublished versions of packages in the response. Default is False. + IncludeDeleted *bool + // (optional) [Obsolete] Used for legacy scenarios and may be removed in future versions. + IsCached *bool + // (optional) Filter results to return packages from a specific upstream. + DirectUpstreamId *uuid.UUID +} + +// [Preview API] Get details about a specific package version. +func (client *ClientImpl) GetPackageVersion(ctx context.Context, args GetPackageVersionArgs) (*PackageVersion, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageId == nil || *args.PackageId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageId"} + } + routeValues["packageId"] = *args.PackageId + if args.PackageVersionId == nil || *args.PackageVersionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersionId"} + } + routeValues["packageVersionId"] = *args.PackageVersionId + + queryParams := url.Values{} + if args.IncludeUrls != nil { + queryParams.Add("includeUrls", strconv.FormatBool(*args.IncludeUrls)) + } + if args.IsListed != nil { + queryParams.Add("isListed", strconv.FormatBool(*args.IsListed)) + } + if args.IsDeleted != nil { + queryParams.Add("isDeleted", strconv.FormatBool(*args.IsDeleted)) + } + locationId, _ := uuid.Parse("3b331909-6a86-44cc-b9ec-c1834c35498f") + 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 PackageVersion + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersion function +type GetPackageVersionArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (required) Id of the package (GUID Id, not name). + PackageId *string + // (required) Id of the package version (GUID Id, not name). + PackageVersionId *string + // (optional) Project ID or project name + Project *string + // (optional) True to include urls for each version. Default is true. + IncludeUrls *bool + // (optional) Only applicable for NuGet packages. If false, delisted package versions will be returned. + IsListed *bool + // (optional) This does not have any effect on the requested package version, for other versions returned specifies whether to return only deleted or non-deleted versions of packages in the response. Default is unset (return all versions). + IsDeleted *bool +} + +// [Preview API] Gets provenance for a package version. +func (client *ClientImpl) GetPackageVersionProvenance(ctx context.Context, args GetPackageVersionProvenanceArgs) (*PackageVersionProvenance, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageId"} + } + routeValues["packageId"] = (*args.PackageId).String() + if args.PackageVersionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionId"} + } + routeValues["packageVersionId"] = (*args.PackageVersionId).String() + + locationId, _ := uuid.Parse("0aaeabd4-85cd-4686-8a77-8d31c15690b8") + 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 PackageVersionProvenance + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersionProvenance function +type GetPackageVersionProvenanceArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (required) Id of the package (GUID Id, not name). + PackageId *uuid.UUID + // (required) Id of the package version (GUID Id, not name). + PackageVersionId *uuid.UUID + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get a list of package versions, optionally filtering by state. +func (client *ClientImpl) GetPackageVersions(ctx context.Context, args GetPackageVersionsArgs) (*[]PackageVersion, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageId == nil || *args.PackageId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageId"} + } + routeValues["packageId"] = *args.PackageId + + queryParams := url.Values{} + if args.IncludeUrls != nil { + queryParams.Add("includeUrls", strconv.FormatBool(*args.IncludeUrls)) + } + if args.IsListed != nil { + queryParams.Add("isListed", strconv.FormatBool(*args.IsListed)) + } + if args.IsDeleted != nil { + queryParams.Add("isDeleted", strconv.FormatBool(*args.IsDeleted)) + } + locationId, _ := uuid.Parse("3b331909-6a86-44cc-b9ec-c1834c35498f") + 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 []PackageVersion + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersions function +type GetPackageVersionsArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (required) Id of the package (GUID Id, not name). + PackageId *string + // (optional) Project ID or project name + Project *string + // (optional) True to include urls for each version. Default is true. + IncludeUrls *bool + // (optional) Only applicable for NuGet packages. If false, delisted package versions will be returned. + IsListed *bool + // (optional) If set specifies whether to return only deleted or non-deleted versions of packages in the response. Default is unset (return all versions). + IsDeleted *bool +} + +// [Preview API] Get information about a package and all its versions within the recycle bin. +func (client *ClientImpl) GetRecycleBinPackage(ctx context.Context, args GetRecycleBinPackageArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageId"} + } + routeValues["packageId"] = (*args.PackageId).String() + + queryParams := url.Values{} + if args.IncludeUrls != nil { + queryParams.Add("includeUrls", strconv.FormatBool(*args.IncludeUrls)) + } + locationId, _ := uuid.Parse("2704e72c-f541-4141-99be-2004b50b05fa") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRecycleBinPackage function +type GetRecycleBinPackageArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (required) The package Id (GUID Id, not the package name). + PackageId *uuid.UUID + // (optional) Project ID or project name + Project *string + // (optional) True to return REST Urls with the response. Default is True. + IncludeUrls *bool +} + +// [Preview API] Query for packages within the recycle bin. +func (client *ClientImpl) GetRecycleBinPackages(ctx context.Context, args GetRecycleBinPackagesArgs) (*[]Package, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + queryParams := url.Values{} + if args.ProtocolType != nil { + queryParams.Add("protocolType", *args.ProtocolType) + } + if args.PackageNameQuery != nil { + queryParams.Add("packageNameQuery", *args.PackageNameQuery) + } + if args.IncludeUrls != nil { + queryParams.Add("includeUrls", strconv.FormatBool(*args.IncludeUrls)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.IncludeAllVersions != nil { + queryParams.Add("includeAllVersions", strconv.FormatBool(*args.IncludeAllVersions)) + } + locationId, _ := uuid.Parse("2704e72c-f541-4141-99be-2004b50b05fa") + 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 []Package + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRecycleBinPackages function +type GetRecycleBinPackagesArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string + // (optional) Type of package (e.g. NuGet, npm, ...). + ProtocolType *string + // (optional) Filter to packages matching this name. + PackageNameQuery *string + // (optional) True to return REST Urls with the response. Default is True. + IncludeUrls *bool + // (optional) Get the top N packages. + Top *int + // (optional) Skip the first N packages. + Skip *int + // (optional) True to return all versions of the package in the response. Default is false (latest version only). + IncludeAllVersions *bool +} + +// [Preview API] Get information about a package version within the recycle bin. +func (client *ClientImpl) GetRecycleBinPackageVersion(ctx context.Context, args GetRecycleBinPackageVersionArgs) (*RecycleBinPackageVersion, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageId"} + } + routeValues["packageId"] = (*args.PackageId).String() + if args.PackageVersionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionId"} + } + routeValues["packageVersionId"] = (*args.PackageVersionId).String() + + queryParams := url.Values{} + if args.IncludeUrls != nil { + queryParams.Add("includeUrls", strconv.FormatBool(*args.IncludeUrls)) + } + locationId, _ := uuid.Parse("aceb4be7-8737-4820-834c-4c549e10fdc7") + 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 RecycleBinPackageVersion + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRecycleBinPackageVersion function +type GetRecycleBinPackageVersionArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (required) The package Id (GUID Id, not the package name). + PackageId *uuid.UUID + // (required) The package version Id 9guid Id, not the version string). + PackageVersionId *uuid.UUID + // (optional) Project ID or project name + Project *string + // (optional) True to return REST Urls with the response. Default is True. + IncludeUrls *bool +} + +// [Preview API] Get a list of package versions within the recycle bin. +func (client *ClientImpl) GetRecycleBinPackageVersions(ctx context.Context, args GetRecycleBinPackageVersionsArgs) (*[]RecycleBinPackageVersion, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageId"} + } + routeValues["packageId"] = (*args.PackageId).String() + + queryParams := url.Values{} + if args.IncludeUrls != nil { + queryParams.Add("includeUrls", strconv.FormatBool(*args.IncludeUrls)) + } + locationId, _ := uuid.Parse("aceb4be7-8737-4820-834c-4c549e10fdc7") + 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 []RecycleBinPackageVersion + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRecycleBinPackageVersions function +type GetRecycleBinPackageVersionsArgs struct { + // (required) Name or Id of the feed. + FeedId *string + // (required) The package Id (GUID Id, not the package name). + PackageId *uuid.UUID + // (optional) Project ID or project name + Project *string + // (optional) True to return REST Urls with the response. Default is True. + IncludeUrls *bool +} + +// [Preview API] +func (client *ClientImpl) QueryPackageMetrics(ctx context.Context, args QueryPackageMetricsArgs) (*[]PackageMetrics, error) { + if args.PackageIdQuery == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageIdQuery"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + body, marshalErr := json.Marshal(*args.PackageIdQuery) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bddc9b3c-8a59-4a9f-9b40-ee1dcaa2cc0d") + 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 []PackageMetrics + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryPackageMetrics function +type QueryPackageMetricsArgs struct { + // (required) + PackageIdQuery *PackageMetricsQuery + // (required) + FeedId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) QueryPackageVersionMetrics(ctx context.Context, args QueryPackageVersionMetricsArgs) (*[]PackageVersionMetrics, error) { + if args.PackageVersionIdQuery == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionIdQuery"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageId"} + } + routeValues["packageId"] = (*args.PackageId).String() + + body, marshalErr := json.Marshal(*args.PackageVersionIdQuery) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e6ae8caa-b6a8-4809-b840-91b2a42c19ad") + 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 []PackageVersionMetrics + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryPackageVersionMetrics function +type QueryPackageVersionMetricsArgs struct { + // (required) + PackageVersionIdQuery *PackageVersionMetricsQuery + // (required) + FeedId *string + // (required) + PackageId *uuid.UUID + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Update the permissions on a feed. +func (client *ClientImpl) SetFeedPermissions(ctx context.Context, args SetFeedPermissionsArgs) (*[]FeedPermission, error) { + if args.FeedPermission == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.FeedPermission"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + body, marshalErr := json.Marshal(*args.FeedPermission) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("be8c1476-86a7-44ed-b19d-aec0e9275cd8") + 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 []FeedPermission + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the SetFeedPermissions function +type SetFeedPermissionsArgs struct { + // (required) Permissions to set. + FeedPermission *[]FeedPermission + // (required) Name or Id of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Set the retention policy for a feed. +func (client *ClientImpl) SetFeedRetentionPolicies(ctx context.Context, args SetFeedRetentionPoliciesArgs) (*FeedRetentionPolicy, error) { + if args.Policy == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Policy"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + body, marshalErr := json.Marshal(*args.Policy) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ed52a011-0112-45b5-9f9e-e14efffb3193") + resp, 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 nil, err + } + + var responseValue FeedRetentionPolicy + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the SetFeedRetentionPolicies function +type SetFeedRetentionPoliciesArgs struct { + // (required) Feed retention policy. + Policy *FeedRetentionPolicy + // (required) Name or ID of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Set service-wide permissions that govern feed creation and administration. +func (client *ClientImpl) SetGlobalPermissions(ctx context.Context, args SetGlobalPermissionsArgs) (*[]GlobalPermission, error) { + if args.GlobalPermissions == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GlobalPermissions"} + } + body, marshalErr := json.Marshal(*args.GlobalPermissions) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a74419ef-b477-43df-8758-3cd1cd5f56c6") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []GlobalPermission + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the SetGlobalPermissions function +type SetGlobalPermissionsArgs struct { + // (required) New permissions for the organization. + GlobalPermissions *[]GlobalPermission +} + +// [Preview API] Change the attributes of a feed. +func (client *ClientImpl) UpdateFeed(ctx context.Context, args UpdateFeedArgs) (*Feed, error) { + if args.Feed == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Feed"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + body, marshalErr := json.Marshal(*args.Feed) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("c65009a7-474a-4ad1-8b42-7d852107ef8c") + 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 Feed + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateFeed function +type UpdateFeedArgs struct { + // (required) A JSON object containing the feed settings to be updated. + Feed *FeedUpdate + // (required) Name or Id of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Update a view. +func (client *ClientImpl) UpdateFeedView(ctx context.Context, args UpdateFeedViewArgs) (*FeedView, error) { + if args.View == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.View"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.ViewId == nil || *args.ViewId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ViewId"} + } + routeValues["viewId"] = *args.ViewId + + body, marshalErr := json.Marshal(*args.View) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("42a8502a-6785-41bc-8c16-89477d930877") + 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 FeedView + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateFeedView function +type UpdateFeedViewArgs struct { + // (required) New settings to apply to the specified view. + View *FeedView + // (required) Name or Id of the feed. + FeedId *string + // (required) Name or Id of the view. + ViewId *string + // (optional) Project ID or project name + Project *string +} diff --git a/azuredevops/feed/models.go b/azuredevops/feed/models.go new file mode 100644 index 00000000..d454bf0c --- /dev/null +++ b/azuredevops/feed/models.go @@ -0,0 +1,633 @@ +// -------------------------------------------------------------------------------------------- +// 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 feed + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" +) + +// Type of operation last performed. +type ChangeType string + +type changeTypeValuesType struct { + AddOrUpdate ChangeType + Delete ChangeType +} + +var ChangeTypeValues = changeTypeValuesType{ + // A package version was added or updated. + AddOrUpdate: "addOrUpdate", + // A package version was deleted. + Delete: "delete", +} + +// A container for artifacts. +type Feed struct { + // Supported capabilities of a feed. + Capabilities *FeedCapabilities `json:"capabilities,omitempty"` + // This will either be the feed GUID or the feed GUID and view GUID depending on how the feed was accessed. + FullyQualifiedId *string `json:"fullyQualifiedId,omitempty"` + // Full name of the view, in feed@view format. + FullyQualifiedName *string `json:"fullyQualifiedName,omitempty"` + // A GUID that uniquely identifies this feed. + Id *uuid.UUID `json:"id,omitempty"` + // If set, all packages in the feed are immutable. It is important to note that feed views are immutable; therefore, this flag will always be set for views. + IsReadOnly *bool `json:"isReadOnly,omitempty"` + // A name for the feed. feed names must follow these rules: Must not exceed 64 characters Must not contain whitespaces Must not start with an underscore or a period Must not end with a period Must not contain any of the following illegal characters: , |, /, \\, ?, :, &, $, *, \", #, [, ] ]]> + Name *string `json:"name,omitempty"` + // The project that this feed is associated with. + Project *ProjectReference `json:"project,omitempty"` + // OBSOLETE: This should always be true. Setting to false will override all sources in UpstreamSources. + UpstreamEnabled *bool `json:"upstreamEnabled,omitempty"` + // A list of sources that this feed will fetch packages from. An empty list indicates that this feed will not search any additional sources for packages. + UpstreamSources *[]UpstreamSource `json:"upstreamSources,omitempty"` + // Definition of the view. + View *FeedView `json:"view,omitempty"` + // View Id. + ViewId *uuid.UUID `json:"viewId,omitempty"` + // View name. + ViewName *string `json:"viewName,omitempty"` + // Related REST links. + Links interface{} `json:"_links,omitempty"` + // If set, this feed supports generation of package badges. + BadgesEnabled *bool `json:"badgesEnabled,omitempty"` + // The view that the feed administrator has indicated is the default experience for readers. + DefaultViewId *uuid.UUID `json:"defaultViewId,omitempty"` + // The date that this feed was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // A description for the feed. Descriptions must not exceed 255 characters. + Description *string `json:"description,omitempty"` + // If set, the feed will hide all deleted/unpublished versions + HideDeletedPackageVersions *bool `json:"hideDeletedPackageVersions,omitempty"` + // Explicit permissions for the feed. + Permissions *[]FeedPermission `json:"permissions,omitempty"` + // If set, time that the UpstreamEnabled property was changed. Will be null if UpstreamEnabled was never changed after Feed creation. + UpstreamEnabledChangedDate *azuredevops.Time `json:"upstreamEnabledChangedDate,omitempty"` + // The URL of the base feed in GUID form. + Url *string `json:"url,omitempty"` +} + +type FeedBatchOperation string + +type feedBatchOperationValuesType struct { + SaveCachedPackages FeedBatchOperation +} + +var FeedBatchOperationValues = feedBatchOperationValuesType{ + SaveCachedPackages: "saveCachedPackages", +} + +// [Flags] Capabilities are used to track features that are available to individual feeds. In general, newly created feeds should be given all available capabilities. These flags track breaking changes in behaviour to feeds, or changes that require user reaction. +type FeedCapabilities string + +type feedCapabilitiesValuesType struct { + None FeedCapabilities + UpstreamV2 FeedCapabilities + UnderMaintenance FeedCapabilities + DefaultCapabilities FeedCapabilities +} + +var FeedCapabilitiesValues = feedCapabilitiesValuesType{ + // No flags exist for this feed + None: "none", + // This feed can serve packages from upstream sources Upstream packages must be manually promoted to views + UpstreamV2: "upstreamV2", + // This feed is currently under maintenance and may have reduced functionality + UnderMaintenance: "underMaintenance", + // The capabilities given to a newly created feed + DefaultCapabilities: "defaultCapabilities", +} + +// A container that encapsulates the state of the feed after a create, update, or delete. +type FeedChange struct { + // The type of operation. + ChangeType *ChangeType `json:"changeType,omitempty"` + // The state of the feed after a after a create, update, or delete operation completed. + Feed *Feed `json:"feed,omitempty"` + // A token that identifies the next change in the log of changes. + FeedContinuationToken *uint64 `json:"feedContinuationToken,omitempty"` + // A token that identifies the latest package change for this feed. This can be used to quickly determine if there have been any changes to packages in a specific feed. + LatestPackageContinuationToken *uint64 `json:"latestPackageContinuationToken,omitempty"` +} + +// A result set containing the feed changes for the range that was requested. +type FeedChangesResponse struct { + Links interface{} `json:"_links,omitempty"` + // The number of changes in this set. + Count *int `json:"count,omitempty"` + // A container that encapsulates the state of the feed after a create, update, or delete. + FeedChanges *[]FeedChange `json:"feedChanges,omitempty"` + // When iterating through the log of changes this value indicates the value that should be used for the next continuation token. + NextFeedContinuationToken *uint64 `json:"nextFeedContinuationToken,omitempty"` +} + +// An object that contains all of the settings for a specific feed. +type FeedCore struct { + // Supported capabilities of a feed. + Capabilities *FeedCapabilities `json:"capabilities,omitempty"` + // This will either be the feed GUID or the feed GUID and view GUID depending on how the feed was accessed. + FullyQualifiedId *string `json:"fullyQualifiedId,omitempty"` + // Full name of the view, in feed@view format. + FullyQualifiedName *string `json:"fullyQualifiedName,omitempty"` + // A GUID that uniquely identifies this feed. + Id *uuid.UUID `json:"id,omitempty"` + // If set, all packages in the feed are immutable. It is important to note that feed views are immutable; therefore, this flag will always be set for views. + IsReadOnly *bool `json:"isReadOnly,omitempty"` + // A name for the feed. feed names must follow these rules: Must not exceed 64 characters Must not contain whitespaces Must not start with an underscore or a period Must not end with a period Must not contain any of the following illegal characters: , |, /, \\, ?, :, &, $, *, \", #, [, ] ]]> + Name *string `json:"name,omitempty"` + // The project that this feed is associated with. + Project *ProjectReference `json:"project,omitempty"` + // OBSOLETE: This should always be true. Setting to false will override all sources in UpstreamSources. + UpstreamEnabled *bool `json:"upstreamEnabled,omitempty"` + // A list of sources that this feed will fetch packages from. An empty list indicates that this feed will not search any additional sources for packages. + UpstreamSources *[]UpstreamSource `json:"upstreamSources,omitempty"` + // Definition of the view. + View *FeedView `json:"view,omitempty"` + // View Id. + ViewId *uuid.UUID `json:"viewId,omitempty"` + // View name. + ViewName *string `json:"viewName,omitempty"` +} + +// Permissions for a feed. +type FeedPermission struct { + // Display name for the identity. + DisplayName *string `json:"displayName,omitempty"` + // Identity associated with this role. + IdentityDescriptor *string `json:"identityDescriptor,omitempty"` + // Id of the identity associated with this role. + IdentityId *uuid.UUID `json:"identityId,omitempty"` + // The role for this identity on a feed. + Role *FeedRole `json:"role,omitempty"` +} + +// Retention policy settings. +type FeedRetentionPolicy struct { + // This attribute is deprecated and is not honoured by retention + AgeLimitInDays *int `json:"ageLimitInDays,omitempty"` + // Maximum versions to preserve per package and package type. + CountLimit *int `json:"countLimit,omitempty"` + // Number of days to preserve a package version after its latest download. + DaysToKeepRecentlyDownloadedPackages *int `json:"daysToKeepRecentlyDownloadedPackages,omitempty"` +} + +type FeedRole string + +type feedRoleValuesType struct { + Custom FeedRole + None FeedRole + Reader FeedRole + Contributor FeedRole + Administrator FeedRole + Collaborator FeedRole +} + +var FeedRoleValues = feedRoleValuesType{ + // Unsupported. + Custom: "custom", + // Unsupported. + None: "none", + // Readers can only read packages and view settings. + Reader: "reader", + // Contributors can do anything to packages in the feed including adding new packages, but they may not modify feed settings. + Contributor: "contributor", + // Administrators have total control over the feed. + Administrator: "administrator", + // Collaborators have the same permissions as readers, but can also ingest packages from configured upstream sources. + Collaborator: "collaborator", +} + +// Update a feed definition with these new values. +type FeedUpdate struct { + // If set, the feed will allow upload of packages that exist on the upstream + AllowUpstreamNameConflict *bool `json:"allowUpstreamNameConflict,omitempty"` + // If set, this feed supports generation of package badges. + BadgesEnabled *bool `json:"badgesEnabled,omitempty"` + // The view that the feed administrator has indicated is the default experience for readers. + DefaultViewId *uuid.UUID `json:"defaultViewId,omitempty"` + // A description for the feed. Descriptions must not exceed 255 characters. + Description *string `json:"description,omitempty"` + // If set, feed will hide all deleted/unpublished versions + HideDeletedPackageVersions *bool `json:"hideDeletedPackageVersions,omitempty"` + // A GUID that uniquely identifies this feed. + Id *uuid.UUID `json:"id,omitempty"` + // A name for the feed. feed names must follow these rules: Must not exceed 64 characters Must not contain whitespaces Must not start with an underscore or a period Must not end with a period Must not contain any of the following illegal characters: , |, /, \\, ?, :, &, $, *, \", #, [, ] ]]> + Name *string `json:"name,omitempty"` + // OBSOLETE: If set, the feed can proxy packages from an upstream feed + UpstreamEnabled *bool `json:"upstreamEnabled,omitempty"` + // A list of sources that this feed will fetch packages from. An empty list indicates that this feed will not search any additional sources for packages. + UpstreamSources *[]UpstreamSource `json:"upstreamSources,omitempty"` +} + +// A view on top of a feed. +type FeedView struct { + // Related REST links. + Links interface{} `json:"_links,omitempty"` + // Id of the view. + Id *uuid.UUID `json:"id,omitempty"` + // Name of the view. + Name *string `json:"name,omitempty"` + // Type of view. + Type *FeedViewType `json:"type,omitempty"` + // Url of the view. + Url *string `json:"url,omitempty"` + // Visibility status of the view. + Visibility *FeedVisibility `json:"visibility,omitempty"` +} + +// The type of view, often used to control capabilities and exposure to options such as promote. Implicit views are internally created only. +type FeedViewType string + +type feedViewTypeValuesType struct { + None FeedViewType + Release FeedViewType + Implicit FeedViewType +} + +var FeedViewTypeValues = feedViewTypeValuesType{ + // Default, unspecified view type. + None: "none", + // View used as a promotion destination to classify released artifacts. + Release: "release", + // Internal view type that is automatically created and managed by the system. + Implicit: "implicit", +} + +// Feed visibility controls the scope in which a certain feed is accessible by a particular user +type FeedVisibility string + +type feedVisibilityValuesType struct { + Private FeedVisibility + Collection FeedVisibility + Organization FeedVisibility +} + +var FeedVisibilityValues = feedVisibilityValuesType{ + // Only accessible by the permissions explicitly set by the feed administrator. + Private: "private", + // Feed is accessible by all the valid users present in the organization where the feed resides (for example across organization 'myorg' at 'dev.azure.com/myorg') + Collection: "collection", + // Feed is accessible by all the valid users present in the enterprise where the feed resides. Note that legacy naming and back compat leaves the name of this value out of sync with its new meaning. + Organization: "organization", +} + +// Permissions for feed service-wide operations such as the creation of new feeds. +type GlobalPermission struct { + // Identity of the user with the provided Role. + IdentityDescriptor *string `json:"identityDescriptor,omitempty"` + // IdentityId corresponding to the IdentityDescriptor + IdentityId *uuid.UUID `json:"identityId,omitempty"` + // Role associated with the Identity. + Role *GlobalRole `json:"role,omitempty"` +} + +type GlobalRole string + +type globalRoleValuesType struct { + Custom GlobalRole + None GlobalRole + FeedCreator GlobalRole + Administrator GlobalRole +} + +var GlobalRoleValues = globalRoleValuesType{ + // Invalid default value. + Custom: "custom", + // Explicit no permissions. + None: "none", + // Ability to create new feeds. + FeedCreator: "feedCreator", + // Read and manage any feed + Administrator: "administrator", +} + +// Core data about any package, including its id and version information and basic state. +type MinimalPackageVersion struct { + // Upstream source this package was ingested from. + DirectUpstreamSourceId *uuid.UUID `json:"directUpstreamSourceId,omitempty"` + // Id for the package. + Id *uuid.UUID `json:"id,omitempty"` + // [Obsolete] Used for legacy scenarios and may be removed in future versions. + IsCachedVersion *bool `json:"isCachedVersion,omitempty"` + // True if this package has been deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + // True if this is the latest version of the package by package type sort order. + IsLatest *bool `json:"isLatest,omitempty"` + // (NuGet Only) True if this package is listed. + IsListed *bool `json:"isListed,omitempty"` + // Normalized version using normalization rules specific to a package type. + NormalizedVersion *string `json:"normalizedVersion,omitempty"` + // Package description. + PackageDescription *string `json:"packageDescription,omitempty"` + // UTC Date the package was published to the service. + PublishDate *azuredevops.Time `json:"publishDate,omitempty"` + // Internal storage id. + StorageId *string `json:"storageId,omitempty"` + // Display version. + Version *string `json:"version,omitempty"` + // List of views containing this package version. + Views *[]FeedView `json:"views,omitempty"` +} + +// A package, which is a container for one or more package versions. +type Package struct { + // Related REST links. + Links interface{} `json:"_links,omitempty"` + // Id of the package. + Id *uuid.UUID `json:"id,omitempty"` + // Used for legacy scenarios and may be removed in future versions. + IsCached *bool `json:"isCached,omitempty"` + // The display name of the package. + Name *string `json:"name,omitempty"` + // The normalized name representing the identity of this package within its package type. + NormalizedName *string `json:"normalizedName,omitempty"` + // Type of the package. + ProtocolType *string `json:"protocolType,omitempty"` + // [Obsolete] - this field is unused and will be removed in a future release. + StarCount *int `json:"starCount,omitempty"` + // Url for this package. + Url *string `json:"url,omitempty"` + // All versions for this package within its feed. + Versions *[]MinimalPackageVersion `json:"versions,omitempty"` +} + +// A single change to a feed's packages. +type PackageChange struct { + // Package that was changed. + Package *Package `json:"package,omitempty"` + // Change that was performed on a package version. + PackageVersionChange *PackageVersionChange `json:"packageVersionChange,omitempty"` +} + +// A set of change operations to a feed's packages. +type PackageChangesResponse struct { + // Related REST links. + Links interface{} `json:"_links,omitempty"` + // Number of changes in this batch. + Count *int `json:"count,omitempty"` + // Token that should be used in future calls for this feed to retrieve new changes. + NextPackageContinuationToken *uint64 `json:"nextPackageContinuationToken,omitempty"` + // List of changes. + PackageChanges *[]PackageChange `json:"packageChanges,omitempty"` +} + +// A dependency on another package version. +type PackageDependency struct { + // Dependency package group (an optional classification within some package types). + Group *string `json:"group,omitempty"` + // Dependency package name. + PackageName *string `json:"packageName,omitempty"` + // Dependency package version range. + VersionRange *string `json:"versionRange,omitempty"` +} + +// A package file for a specific package version, only relevant to package types that contain multiple files per version. +type PackageFile struct { + // Hierarchical representation of files. + Children *[]PackageFile `json:"children,omitempty"` + // File name. + Name *string `json:"name,omitempty"` + // Extended data unique to a specific package type. + ProtocolMetadata *ProtocolMetadata `json:"protocolMetadata,omitempty"` +} + +// All metrics for a certain package id +type PackageMetrics struct { + // Total count of downloads per package id. + DownloadCount *float64 `json:"downloadCount,omitempty"` + // Number of downloads per unique user per package id. + DownloadUniqueUsers *float64 `json:"downloadUniqueUsers,omitempty"` + // UTC date and time when package was last downloaded. + LastDownloaded *azuredevops.Time `json:"lastDownloaded,omitempty"` + // Package id. + PackageId *uuid.UUID `json:"packageId,omitempty"` +} + +// Query to get package metrics +type PackageMetricsQuery struct { + // List of package ids + PackageIds *[]uuid.UUID `json:"packageIds,omitempty"` +} + +// A specific version of a package. +type PackageVersion struct { + // Upstream source this package was ingested from. + DirectUpstreamSourceId *uuid.UUID `json:"directUpstreamSourceId,omitempty"` + // Id for the package. + Id *uuid.UUID `json:"id,omitempty"` + // [Obsolete] Used for legacy scenarios and may be removed in future versions. + IsCachedVersion *bool `json:"isCachedVersion,omitempty"` + // True if this package has been deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + // True if this is the latest version of the package by package type sort order. + IsLatest *bool `json:"isLatest,omitempty"` + // (NuGet Only) True if this package is listed. + IsListed *bool `json:"isListed,omitempty"` + // Normalized version using normalization rules specific to a package type. + NormalizedVersion *string `json:"normalizedVersion,omitempty"` + // Package description. + PackageDescription *string `json:"packageDescription,omitempty"` + // UTC Date the package was published to the service. + PublishDate *azuredevops.Time `json:"publishDate,omitempty"` + // Internal storage id. + StorageId *string `json:"storageId,omitempty"` + // Display version. + Version *string `json:"version,omitempty"` + // List of views containing this package version. + Views *[]FeedView `json:"views,omitempty"` + // Related links + Links interface{} `json:"_links,omitempty"` + // Package version author. + Author *string `json:"author,omitempty"` + // UTC date that this package version was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // List of dependencies for this package version. + Dependencies *[]PackageDependency `json:"dependencies,omitempty"` + // Package version description. + Description *string `json:"description,omitempty"` + // Files associated with this package version, only relevant for multi-file package types. + Files *[]PackageFile `json:"files,omitempty"` + // Other versions of this package. + OtherVersions *[]MinimalPackageVersion `json:"otherVersions,omitempty"` + // Extended data specific to a package type. + ProtocolMetadata *ProtocolMetadata `json:"protocolMetadata,omitempty"` + // List of upstream sources through which a package version moved to land in this feed. + SourceChain *[]UpstreamSource `json:"sourceChain,omitempty"` + // Package version summary. + Summary *string `json:"summary,omitempty"` + // Package version tags. + Tags *[]string `json:"tags,omitempty"` + // Package version url. + Url *string `json:"url,omitempty"` +} + +// A change to a single package version. +type PackageVersionChange struct { + // The type of change that was performed. + ChangeType *ChangeType `json:"changeType,omitempty"` + // Token marker for this change, allowing the caller to send this value back to the service and receive changes beyond this one. + ContinuationToken *uint64 `json:"continuationToken,omitempty"` + // Package version that was changed. + PackageVersion *PackageVersion `json:"packageVersion,omitempty"` +} + +// All metrics for a certain package version id +type PackageVersionMetrics struct { + // Total count of downloads per package version id. + DownloadCount *float64 `json:"downloadCount,omitempty"` + // Number of downloads per unique user per package version id. + DownloadUniqueUsers *float64 `json:"downloadUniqueUsers,omitempty"` + // UTC date and time when package version was last downloaded. + LastDownloaded *azuredevops.Time `json:"lastDownloaded,omitempty"` + // Package id. + PackageId *uuid.UUID `json:"packageId,omitempty"` + // Package version id. + PackageVersionId *uuid.UUID `json:"packageVersionId,omitempty"` +} + +// Query to get package version metrics +type PackageVersionMetricsQuery struct { + // List of package version ids + PackageVersionIds *[]uuid.UUID `json:"packageVersionIds,omitempty"` +} + +// Provenance for a published package version +type PackageVersionProvenance struct { + // Name or Id of the feed. + FeedId *uuid.UUID `json:"feedId,omitempty"` + // Id of the package (GUID Id, not name). + PackageId *uuid.UUID `json:"packageId,omitempty"` + // Id of the package version (GUID Id, not name). + PackageVersionId *uuid.UUID `json:"packageVersionId,omitempty"` + // Provenance information for this package version. + Provenance *Provenance `json:"provenance,omitempty"` +} + +type ProjectReference struct { + // Gets or sets id of the project. + Id *uuid.UUID `json:"id,omitempty"` + // Gets or sets name of the project. + Name *string `json:"name,omitempty"` + // Gets or sets visibility of the project. + Visibility *string `json:"visibility,omitempty"` +} + +// Extended metadata for a specific package type. +type ProtocolMetadata struct { + // Extended metadata for a specific package type, formatted to the associated schema version definition. + Data interface{} `json:"data,omitempty"` + // Schema version. + SchemaVersion *int `json:"schemaVersion,omitempty"` +} + +// Data about the origin of a published package +type Provenance struct { + // Other provenance data. + Data *map[string]string `json:"data,omitempty"` + // Type of provenance source, for example "InternalBuild", "InternalRelease" + ProvenanceSource *string `json:"provenanceSource,omitempty"` + // Identity of user that published the package + PublisherUserIdentity *uuid.UUID `json:"publisherUserIdentity,omitempty"` + // HTTP User-Agent used when pushing the package. + UserAgent *string `json:"userAgent,omitempty"` +} + +// A single package version within the recycle bin. +type RecycleBinPackageVersion struct { + // Upstream source this package was ingested from. + DirectUpstreamSourceId *uuid.UUID `json:"directUpstreamSourceId,omitempty"` + // Id for the package. + Id *uuid.UUID `json:"id,omitempty"` + // [Obsolete] Used for legacy scenarios and may be removed in future versions. + IsCachedVersion *bool `json:"isCachedVersion,omitempty"` + // True if this package has been deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + // True if this is the latest version of the package by package type sort order. + IsLatest *bool `json:"isLatest,omitempty"` + // (NuGet Only) True if this package is listed. + IsListed *bool `json:"isListed,omitempty"` + // Normalized version using normalization rules specific to a package type. + NormalizedVersion *string `json:"normalizedVersion,omitempty"` + // Package description. + PackageDescription *string `json:"packageDescription,omitempty"` + // UTC Date the package was published to the service. + PublishDate *azuredevops.Time `json:"publishDate,omitempty"` + // Internal storage id. + StorageId *string `json:"storageId,omitempty"` + // Display version. + Version *string `json:"version,omitempty"` + // List of views containing this package version. + Views *[]FeedView `json:"views,omitempty"` + // Related links + Links interface{} `json:"_links,omitempty"` + // Package version author. + Author *string `json:"author,omitempty"` + // UTC date that this package version was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // List of dependencies for this package version. + Dependencies *[]PackageDependency `json:"dependencies,omitempty"` + // Package version description. + Description *string `json:"description,omitempty"` + // Files associated with this package version, only relevant for multi-file package types. + Files *[]PackageFile `json:"files,omitempty"` + // Other versions of this package. + OtherVersions *[]MinimalPackageVersion `json:"otherVersions,omitempty"` + // Extended data specific to a package type. + ProtocolMetadata *ProtocolMetadata `json:"protocolMetadata,omitempty"` + // List of upstream sources through which a package version moved to land in this feed. + SourceChain *[]UpstreamSource `json:"sourceChain,omitempty"` + // Package version summary. + Summary *string `json:"summary,omitempty"` + // Package version tags. + Tags *[]string `json:"tags,omitempty"` + // Package version url. + Url *string `json:"url,omitempty"` + // UTC date on which the package will automatically be removed from the recycle bin and permanently deleted. + ScheduledPermanentDeleteDate *azuredevops.Time `json:"scheduledPermanentDeleteDate,omitempty"` +} + +// Upstream source definition, including its Identity, package type, and other associated information. +type UpstreamSource struct { + // UTC date that this upstream was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Locator for connecting to the upstream source in a user friendly format, that may potentially change over time + DisplayLocation *string `json:"displayLocation,omitempty"` + // Identity of the upstream source. + Id *uuid.UUID `json:"id,omitempty"` + // For an internal upstream type, track the Azure DevOps organization that contains it. + InternalUpstreamCollectionId *uuid.UUID `json:"internalUpstreamCollectionId,omitempty"` + // For an internal upstream type, track the feed id being referenced. + InternalUpstreamFeedId *uuid.UUID `json:"internalUpstreamFeedId,omitempty"` + // For an internal upstream type, track the view of the feed being referenced. + InternalUpstreamViewId *uuid.UUID `json:"internalUpstreamViewId,omitempty"` + // Consistent locator for connecting to the upstream source. + Location *string `json:"location,omitempty"` + // Display name. + Name *string `json:"name,omitempty"` + // Package type associated with the upstream source. + Protocol *string `json:"protocol,omitempty"` + // Source type, such as Public or Internal. + UpstreamSourceType *UpstreamSourceType `json:"upstreamSourceType,omitempty"` +} + +// Type of an upstream source, such as Public or Internal. +type UpstreamSourceType string + +type upstreamSourceTypeValuesType struct { + Public UpstreamSourceType + Internal UpstreamSourceType +} + +var UpstreamSourceTypeValues = upstreamSourceTypeValuesType{ + // Publicly available source. + Public: "public", + // Azure DevOps upstream source. + Internal: "internal", +} diff --git a/azuredevops/feedtoken/client.go b/azuredevops/feedtoken/client.go new file mode 100644 index 00000000..4c9eb3f5 --- /dev/null +++ b/azuredevops/feedtoken/client.go @@ -0,0 +1,61 @@ +// -------------------------------------------------------------------------------------------- +// 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 feedtoken + +import ( + "context" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" +) + +var ResourceAreaId, _ = uuid.Parse("cdeb6c7d-6b25-4d6f-b664-c2e3ede202e8") + +type Client interface { + // [Preview API] Get a time-limited session token representing the current user, with permissions scoped to the read/write of Artifacts. + GetPersonalAccessToken(context.Context, GetPersonalAccessTokenArgs) (*FeedSessionToken, 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] Get a time-limited session token representing the current user, with permissions scoped to the read/write of Artifacts. +func (client *ClientImpl) GetPersonalAccessToken(ctx context.Context, args GetPersonalAccessTokenArgs) (*FeedSessionToken, error) { + routeValues := make(map[string]string) + if args.FeedName != nil && *args.FeedName != "" { + routeValues["feedName"] = *args.FeedName + } + + locationId, _ := uuid.Parse("dfdb7ad7-3d8e-4907-911e-19b4a8330550") + 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 FeedSessionToken + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPersonalAccessToken function +type GetPersonalAccessTokenArgs struct { + // (optional) + FeedName *string +} diff --git a/azuredevops/feedtoken/models.go b/azuredevops/feedtoken/models.go new file mode 100644 index 00000000..f7b074c9 --- /dev/null +++ b/azuredevops/feedtoken/models.go @@ -0,0 +1,19 @@ +// -------------------------------------------------------------------------------------------- +// 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 feedtoken + +import ( + "github.com/microsoft/azure-devops-go-api/azuredevops" +) + +// A cut-down version of SessionToken that just has what FeedSessionTokenController needs to serve the UI and which actually generates a TypeScript type for the UI to use +type FeedSessionToken struct { + Token *string `json:"token,omitempty"` + ValidTo *azuredevops.Time `json:"validTo,omitempty"` +} diff --git a/azuredevops/filecontainer/client.go b/azuredevops/filecontainer/client.go new file mode 100644 index 00000000..628ffdae --- /dev/null +++ b/azuredevops/filecontainer/client.go @@ -0,0 +1,206 @@ +// -------------------------------------------------------------------------------------------- +// 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 filecontainer + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" +) + +type Client interface { + // [Preview API] Creates the specified items in in the referenced container. + CreateItems(context.Context, CreateItemsArgs) (*[]FileContainerItem, error) + // [Preview API] Deletes the specified items in a container. + DeleteItem(context.Context, DeleteItemArgs) error + // [Preview API] Gets containers filtered by a comma separated list of artifact uris within the same scope, if not specified returns all containers + GetContainers(context.Context, GetContainersArgs) (*[]FileContainer, error) + // [Preview API] + GetItems(context.Context, GetItemsArgs) (*[]FileContainerItem, 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, + } +} + +// [Preview API] Creates the specified items in in the referenced container. +func (client *ClientImpl) CreateItems(ctx context.Context, args CreateItemsArgs) (*[]FileContainerItem, error) { + if args.Items == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Items"} + } + routeValues := make(map[string]string) + if args.ContainerId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ContainerId"} + } + routeValues["containerId"] = strconv.Itoa(*args.ContainerId) + + queryParams := url.Values{} + if args.Scope != nil { + queryParams.Add("scope", (*args.Scope).String()) + } + body, marshalErr := json.Marshal(*args.Items) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e4f5c81e-e250-447b-9fef-bd48471bea5e") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.4", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []FileContainerItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateItems function +type CreateItemsArgs struct { + // (required) + Items *azuredevops.VssJsonCollectionWrapper + // (required) + ContainerId *int + // (optional) A guid representing the scope of the container. This is often the project id. + Scope *uuid.UUID +} + +// [Preview API] Deletes the specified items in a container. +func (client *ClientImpl) DeleteItem(ctx context.Context, args DeleteItemArgs) error { + routeValues := make(map[string]string) + if args.ContainerId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ContainerId"} + } + routeValues["containerId"] = strconv.FormatUint(*args.ContainerId, 10) + + queryParams := url.Values{} + if args.ItemPath == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "itemPath"} + } + queryParams.Add("itemPath", *args.ItemPath) + if args.Scope != nil { + queryParams.Add("scope", (*args.Scope).String()) + } + locationId, _ := uuid.Parse("e4f5c81e-e250-447b-9fef-bd48471bea5e") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.4", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteItem function +type DeleteItemArgs struct { + // (required) Container Id. + ContainerId *uint64 + // (required) Path to delete. + ItemPath *string + // (optional) A guid representing the scope of the container. This is often the project id. + Scope *uuid.UUID +} + +// [Preview API] Gets containers filtered by a comma separated list of artifact uris within the same scope, if not specified returns all containers +func (client *ClientImpl) GetContainers(ctx context.Context, args GetContainersArgs) (*[]FileContainer, error) { + queryParams := url.Values{} + if args.Scope != nil { + queryParams.Add("scope", (*args.Scope).String()) + } + if args.ArtifactUris != nil { + queryParams.Add("artifactUris", *args.ArtifactUris) + } + locationId, _ := uuid.Parse("e4f5c81e-e250-447b-9fef-bd48471bea5e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.4", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []FileContainer + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetContainers function +type GetContainersArgs struct { + // (optional) A guid representing the scope of the container. This is often the project id. + Scope *uuid.UUID + // (optional) + ArtifactUris *string +} + +// [Preview API] +func (client *ClientImpl) GetItems(ctx context.Context, args GetItemsArgs) (*[]FileContainerItem, error) { + routeValues := make(map[string]string) + if args.ContainerId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ContainerId"} + } + routeValues["containerId"] = strconv.FormatUint(*args.ContainerId, 10) + + queryParams := url.Values{} + if args.Scope != nil { + queryParams.Add("scope", (*args.Scope).String()) + } + if args.ItemPath != nil { + queryParams.Add("itemPath", *args.ItemPath) + } + if args.Metadata != nil { + queryParams.Add("metadata", strconv.FormatBool(*args.Metadata)) + } + if args.Format != nil { + queryParams.Add("$format", *args.Format) + } + if args.DownloadFileName != nil { + queryParams.Add("downloadFileName", *args.DownloadFileName) + } + if args.IncludeDownloadTickets != nil { + queryParams.Add("includeDownloadTickets", strconv.FormatBool(*args.IncludeDownloadTickets)) + } + if args.IsShallow != nil { + queryParams.Add("isShallow", strconv.FormatBool(*args.IsShallow)) + } + locationId, _ := uuid.Parse("e4f5c81e-e250-447b-9fef-bd48471bea5e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.4", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []FileContainerItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetItems function +type GetItemsArgs struct { + // (required) + ContainerId *uint64 + // (optional) + Scope *uuid.UUID + // (optional) + ItemPath *string + // (optional) + Metadata *bool + // (optional) + Format *string + // (optional) + DownloadFileName *string + // (optional) + IncludeDownloadTickets *bool + // (optional) + IsShallow *bool +} diff --git a/azuredevops/filecontainer/models.go b/azuredevops/filecontainer/models.go new file mode 100644 index 00000000..c6cb8bb9 --- /dev/null +++ b/azuredevops/filecontainer/models.go @@ -0,0 +1,129 @@ +// -------------------------------------------------------------------------------------------- +// 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 filecontainer + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" +) + +// Status of a container item. +type ContainerItemStatus string + +type containerItemStatusValuesType struct { + Created ContainerItemStatus + PendingUpload ContainerItemStatus +} + +var ContainerItemStatusValues = containerItemStatusValuesType{ + // Item is created. + Created: "created", + // Item is a file pending for upload. + PendingUpload: "pendingUpload", +} + +// Type of a container item. +type ContainerItemType string + +type containerItemTypeValuesType struct { + Any ContainerItemType + Folder ContainerItemType + File ContainerItemType +} + +var ContainerItemTypeValues = containerItemTypeValuesType{ + // Any item type. + Any: "any", + // Item is a folder which can have child items. + Folder: "folder", + // Item is a file which is stored in the file service. + File: "file", +} + +// [Flags] Options a container can have. +type ContainerOptions string + +type containerOptionsValuesType struct { + None ContainerOptions +} + +var ContainerOptionsValues = containerOptionsValuesType{ + // No option. + None: "none", +} + +// Represents a container that encapsulates a hierarchical file system. +type FileContainer struct { + // Uri of the artifact associated with the container. + ArtifactUri *string `json:"artifactUri,omitempty"` + // Download Url for the content of this item. + ContentLocation *string `json:"contentLocation,omitempty"` + // Owner. + CreatedBy *uuid.UUID `json:"createdBy,omitempty"` + // Creation date. + DateCreated *azuredevops.Time `json:"dateCreated,omitempty"` + // Description. + Description *string `json:"description,omitempty"` + // Id. + Id *uint64 `json:"id,omitempty"` + // Location of the item resource. + ItemLocation *string `json:"itemLocation,omitempty"` + // ItemStore Locator for this container. + LocatorPath *string `json:"locatorPath,omitempty"` + // Name. + Name *string `json:"name,omitempty"` + // Options the container can have. + Options *ContainerOptions `json:"options,omitempty"` + // Project Id. + ScopeIdentifier *uuid.UUID `json:"scopeIdentifier,omitempty"` + // Security token of the artifact associated with the container. + SecurityToken *string `json:"securityToken,omitempty"` + // Identifier of the optional encryption key. + SigningKeyId *uuid.UUID `json:"signingKeyId,omitempty"` + // Total size of the files in bytes. + Size *uint64 `json:"size,omitempty"` +} + +// Represents an item in a container. +type FileContainerItem struct { + // Container Id. + ContainerId *uint64 `json:"containerId,omitempty"` + ContentId *[]byte `json:"contentId,omitempty"` + // Download Url for the content of this item. + ContentLocation *string `json:"contentLocation,omitempty"` + // Creator. + CreatedBy *uuid.UUID `json:"createdBy,omitempty"` + // Creation date. + DateCreated *azuredevops.Time `json:"dateCreated,omitempty"` + // Last modified date. + DateLastModified *azuredevops.Time `json:"dateLastModified,omitempty"` + // Encoding of the file. Zero if not a file. + FileEncoding *int `json:"fileEncoding,omitempty"` + // Hash value of the file. Null if not a file. + FileHash *[]byte `json:"fileHash,omitempty"` + // Id of the file content. + FileId *int `json:"fileId,omitempty"` + // Length of the file. Zero if not of a file. + FileLength *uint64 `json:"fileLength,omitempty"` + // Type of the file. Zero if not a file. + FileType *int `json:"fileType,omitempty"` + // Location of the item resource. + ItemLocation *string `json:"itemLocation,omitempty"` + // Type of the item: Folder, File or String. + ItemType *ContainerItemType `json:"itemType,omitempty"` + // Modifier. + LastModifiedBy *uuid.UUID `json:"lastModifiedBy,omitempty"` + // Unique path that identifies the item. + Path *string `json:"path,omitempty"` + // Project Id. + ScopeIdentifier *uuid.UUID `json:"scopeIdentifier,omitempty"` + // Status of the item: Created or Pending Upload. + Status *ContainerItemStatus `json:"status,omitempty"` + Ticket *string `json:"ticket,omitempty"` +} diff --git a/azuredevops/forminput/models.go b/azuredevops/forminput/models.go new file mode 100644 index 00000000..324cffc5 --- /dev/null +++ b/azuredevops/forminput/models.go @@ -0,0 +1,194 @@ +// -------------------------------------------------------------------------------------------- +// 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 forminput + +import ( + "math/big" +) + +// Enumerates data types that are supported as subscription input values. +type InputDataType string + +type inputDataTypeValuesType struct { + None InputDataType + String InputDataType + Number InputDataType + Boolean InputDataType + Guid InputDataType + Uri InputDataType +} + +var InputDataTypeValues = inputDataTypeValuesType{ + // No data type is specified. + None: "none", + // Represents a textual value. + String: "string", + // Represents a numeric value. + Number: "number", + // Represents a value of true or false. + Boolean: "boolean", + // Represents a Guid. + Guid: "guid", + // Represents a URI. + Uri: "uri", +} + +// Describes an input for subscriptions. +type InputDescriptor struct { + // The ids of all inputs that the value of this input is dependent on. + DependencyInputIds *[]string `json:"dependencyInputIds,omitempty"` + // Description of what this input is used for + Description *string `json:"description,omitempty"` + // The group localized name to which this input belongs and can be shown as a header for the container that will include all the inputs in the group. + GroupName *string `json:"groupName,omitempty"` + // If true, the value information for this input is dynamic and should be fetched when the value of dependency inputs change. + HasDynamicValueInformation *bool `json:"hasDynamicValueInformation,omitempty"` + // Identifier for the subscription input + Id *string `json:"id,omitempty"` + // Mode in which the value of this input should be entered + InputMode *InputMode `json:"inputMode,omitempty"` + // Gets whether this input is confidential, such as for a password or application key + IsConfidential *bool `json:"isConfidential,omitempty"` + // Localized name which can be shown as a label for the subscription input + Name *string `json:"name,omitempty"` + // Custom properties for the input which can be used by the service provider + Properties *map[string]interface{} `json:"properties,omitempty"` + // Underlying data type for the input value. When this value is specified, InputMode, Validation and Values are optional. + Type *string `json:"type,omitempty"` + // Gets whether this input is included in the default generated action description. + UseInDefaultDescription *bool `json:"useInDefaultDescription,omitempty"` + // Information to use to validate this input's value + Validation *InputValidation `json:"validation,omitempty"` + // A hint for input value. It can be used in the UI as the input placeholder. + ValueHint *string `json:"valueHint,omitempty"` + // Information about possible values for this input + Values *InputValues `json:"values,omitempty"` +} + +// Defines a filter for subscription inputs. The filter matches a set of inputs if any (one or more) of the groups evaluates to true. +type InputFilter struct { + // Groups of input filter expressions. This filter matches a set of inputs if any (one or more) of the groups evaluates to true. + Conditions *[]InputFilterCondition `json:"conditions,omitempty"` +} + +// An expression which can be applied to filter a list of subscription inputs +type InputFilterCondition struct { + // Whether or not to do a case sensitive match + CaseSensitive *bool `json:"caseSensitive,omitempty"` + // The Id of the input to filter on + InputId *string `json:"inputId,omitempty"` + // The "expected" input value to compare with the actual input value + InputValue *string `json:"inputValue,omitempty"` + // The operator applied between the expected and actual input value + Operator *InputFilterOperator `json:"operator,omitempty"` +} + +type InputFilterOperator string + +type inputFilterOperatorValuesType struct { + Equals InputFilterOperator + NotEquals InputFilterOperator +} + +var InputFilterOperatorValues = inputFilterOperatorValuesType{ + Equals: "equals", + NotEquals: "notEquals", +} + +// Mode in which a subscription input should be entered (in a UI) +type InputMode string + +type inputModeValuesType struct { + None InputMode + TextBox InputMode + PasswordBox InputMode + Combo InputMode + RadioButtons InputMode + CheckBox InputMode + TextArea InputMode +} + +var InputModeValues = inputModeValuesType{ + // This input should not be shown in the UI + None: "none", + // An input text box should be shown + TextBox: "textBox", + // An password input box should be shown + PasswordBox: "passwordBox", + // A select/combo control should be shown + Combo: "combo", + // Radio buttons should be shown + RadioButtons: "radioButtons", + // Checkbox should be shown(for true/false values) + CheckBox: "checkBox", + // A multi-line text area should be shown + TextArea: "textArea", +} + +// Describes what values are valid for a subscription input +type InputValidation struct { + // Gets or sets the data data type to validate. + DataType *InputDataType `json:"dataType,omitempty"` + // Gets or sets if this is a required field. + IsRequired *bool `json:"isRequired,omitempty"` + // Gets or sets the maximum length of this descriptor. + MaxLength *int `json:"maxLength,omitempty"` + // Gets or sets the minimum value for this descriptor. + MaxValue *big.Float `json:"maxValue,omitempty"` + // Gets or sets the minimum length of this descriptor. + MinLength *int `json:"minLength,omitempty"` + // Gets or sets the minimum value for this descriptor. + MinValue *big.Float `json:"minValue,omitempty"` + // Gets or sets the pattern to validate. + Pattern *string `json:"pattern,omitempty"` + // Gets or sets the error on pattern mismatch. + PatternMismatchErrorMessage *string `json:"patternMismatchErrorMessage,omitempty"` +} + +// Information about a single value for an input +type InputValue struct { + // Any other data about this input + Data *map[string]interface{} `json:"data,omitempty"` + // The text to show for the display of this value + DisplayValue *string `json:"displayValue,omitempty"` + // The value to store for this input + Value *string `json:"value,omitempty"` +} + +// Information about the possible/allowed values for a given subscription input +type InputValues struct { + // The default value to use for this input + DefaultValue *string `json:"defaultValue,omitempty"` + // Errors encountered while computing dynamic values. + Error *InputValuesError `json:"error,omitempty"` + // The id of the input + InputId *string `json:"inputId,omitempty"` + // Should this input be disabled + IsDisabled *bool `json:"isDisabled,omitempty"` + // Should the value be restricted to one of the values in the PossibleValues (True) or are the values in PossibleValues just a suggestion (False) + IsLimitedToPossibleValues *bool `json:"isLimitedToPossibleValues,omitempty"` + // Should this input be made read-only + IsReadOnly *bool `json:"isReadOnly,omitempty"` + // Possible values that this input can take + PossibleValues *[]InputValue `json:"possibleValues,omitempty"` +} + +// Error information related to a subscription input value. +type InputValuesError struct { + // The error message. + Message *string `json:"message,omitempty"` +} + +type InputValuesQuery struct { + CurrentValues *map[string]string `json:"currentValues,omitempty"` + // The input values to return on input, and the result from the consumer on output. + InputValues *[]InputValues `json:"inputValues,omitempty"` + // Subscription containing information about the publisher/consumer and the current input values + Resource interface{} `json:"resource,omitempty"` +} diff --git a/azuredevops/gallery/client.go b/azuredevops/gallery/client.go new file mode 100644 index 00000000..a30dcbce --- /dev/null +++ b/azuredevops/gallery/client.go @@ -0,0 +1,3162 @@ +// -------------------------------------------------------------------------------------------- +// 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 gallery + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "io" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("69d21c00-f135-441b-b5ce-3626378e0819") + +type Client interface { + // [Preview API] + AddAssetForEditExtensionDraft(context.Context, AddAssetForEditExtensionDraftArgs) (*ExtensionDraftAsset, error) + // [Preview API] + AddAssetForNewExtensionDraft(context.Context, AddAssetForNewExtensionDraftArgs) (*ExtensionDraftAsset, error) + // [Preview API] + AssociateAzurePublisher(context.Context, AssociateAzurePublisherArgs) (*AzurePublisher, error) + // [Preview API] + CreateCategory(context.Context, CreateCategoryArgs) (*ExtensionCategory, error) + // [Preview API] + CreateDraftForEditExtension(context.Context, CreateDraftForEditExtensionArgs) (*ExtensionDraft, error) + // [Preview API] + CreateDraftForNewExtension(context.Context, CreateDraftForNewExtensionArgs) (*ExtensionDraft, error) + // [Preview API] + CreateExtension(context.Context, CreateExtensionArgs) (*PublishedExtension, error) + // [Preview API] + CreateExtensionWithPublisher(context.Context, CreateExtensionWithPublisherArgs) (*PublishedExtension, error) + // [Preview API] + CreatePublisher(context.Context, CreatePublisherArgs) (*Publisher, error) + // [Preview API] Creates a new question for an extension. + CreateQuestion(context.Context, CreateQuestionArgs) (*Question, error) + // [Preview API] Creates a new response for a given question for an extension. + CreateResponse(context.Context, CreateResponseArgs) (*Response, error) + // [Preview API] Creates a new review for an extension + CreateReview(context.Context, CreateReviewArgs) (*Review, error) + // [Preview API] + DeleteExtension(context.Context, DeleteExtensionArgs) error + // [Preview API] + DeleteExtensionById(context.Context, DeleteExtensionByIdArgs) error + // [Preview API] + DeletePublisher(context.Context, DeletePublisherArgs) error + // [Preview API] Delete publisher asset like logo + DeletePublisherAsset(context.Context, DeletePublisherAssetArgs) error + // [Preview API] Deletes an existing question and all its associated responses for an extension. (soft delete) + DeleteQuestion(context.Context, DeleteQuestionArgs) error + // [Preview API] Deletes a response for an extension. (soft delete) + DeleteResponse(context.Context, DeleteResponseArgs) error + // [Preview API] Deletes a review + DeleteReview(context.Context, DeleteReviewArgs) error + // [Preview API] + ExtensionValidator(context.Context, ExtensionValidatorArgs) error + // [Preview API] + GenerateKey(context.Context, GenerateKeyArgs) error + // [Preview API] + GetAcquisitionOptions(context.Context, GetAcquisitionOptionsArgs) (*AcquisitionOptions, error) + // [Preview API] + GetAsset(context.Context, GetAssetArgs) (io.ReadCloser, error) + // [Preview API] + GetAssetAuthenticated(context.Context, GetAssetAuthenticatedArgs) (io.ReadCloser, error) + // [Preview API] + GetAssetByName(context.Context, GetAssetByNameArgs) (io.ReadCloser, error) + // [Preview API] + GetAssetFromEditExtensionDraft(context.Context, GetAssetFromEditExtensionDraftArgs) (io.ReadCloser, error) + // [Preview API] + GetAssetFromNewExtensionDraft(context.Context, GetAssetFromNewExtensionDraftArgs) (io.ReadCloser, error) + // [Preview API] + GetAssetWithToken(context.Context, GetAssetWithTokenArgs) (io.ReadCloser, error) + // [Preview API] + GetCategories(context.Context, GetCategoriesArgs) (*[]string, error) + // [Preview API] + GetCategoryDetails(context.Context, GetCategoryDetailsArgs) (*CategoriesResult, error) + // [Preview API] + GetCategoryTree(context.Context, GetCategoryTreeArgs) (*ProductCategory, error) + // [Preview API] + GetCertificate(context.Context, GetCertificateArgs) (io.ReadCloser, error) + // [Preview API] + GetContentVerificationLog(context.Context, GetContentVerificationLogArgs) (io.ReadCloser, error) + // [Preview API] + GetExtension(context.Context, GetExtensionArgs) (*PublishedExtension, error) + // [Preview API] + GetExtensionById(context.Context, GetExtensionByIdArgs) (*PublishedExtension, error) + // [Preview API] + GetExtensionDailyStats(context.Context, GetExtensionDailyStatsArgs) (*ExtensionDailyStats, error) + // [Preview API] This route/location id only supports HTTP POST anonymously, so that the page view daily stat can be incremented from Marketplace client. Trying to call GET on this route should result in an exception. Without this explicit implementation, calling GET on this public route invokes the above GET implementation GetExtensionDailyStats. + GetExtensionDailyStatsAnonymous(context.Context, GetExtensionDailyStatsAnonymousArgs) (*ExtensionDailyStats, error) + // [Preview API] Get install/uninstall events of an extension. If both count and afterDate parameters are specified, count takes precedence. + GetExtensionEvents(context.Context, GetExtensionEventsArgs) (*ExtensionEvents, error) + // [Preview API] Returns extension reports + GetExtensionReports(context.Context, GetExtensionReportsArgs) (interface{}, error) + // [Preview API] Get all setting entries for the given user/all-users scope + GetGalleryUserSettings(context.Context, GetGalleryUserSettingsArgs) (*map[string]interface{}, error) + // [Preview API] This endpoint gets hit when you download a VSTS extension from the Web UI + GetPackage(context.Context, GetPackageArgs) (io.ReadCloser, error) + // [Preview API] + GetPublisher(context.Context, GetPublisherArgs) (*Publisher, error) + // [Preview API] Get publisher asset like logo as a stream + GetPublisherAsset(context.Context, GetPublisherAssetArgs) (io.ReadCloser, error) + // [Preview API] Returns a list of questions with their responses associated with an extension. + GetQuestions(context.Context, GetQuestionsArgs) (*QuestionsResult, error) + // [Preview API] Returns a list of reviews associated with an extension + GetReviews(context.Context, GetReviewsArgs) (*ReviewsResult, error) + // [Preview API] Returns a summary of the reviews + GetReviewsSummary(context.Context, GetReviewsSummaryArgs) (*ReviewSummary, error) + // [Preview API] + GetRootCategories(context.Context, GetRootCategoriesArgs) (*ProductCategoriesResult, error) + // [Preview API] + GetSigningKey(context.Context, GetSigningKeyArgs) (*string, error) + // [Preview API] + GetVerificationLog(context.Context, GetVerificationLogArgs) (io.ReadCloser, error) + // [Preview API] Increments a daily statistic associated with the extension + IncrementExtensionDailyStat(context.Context, IncrementExtensionDailyStatArgs) error + // [Preview API] + PerformEditExtensionDraftOperation(context.Context, PerformEditExtensionDraftOperationArgs) (*ExtensionDraft, error) + // [Preview API] + PerformNewExtensionDraftOperation(context.Context, PerformNewExtensionDraftOperationArgs) (*ExtensionDraft, error) + // [Preview API] API endpoint to publish extension install/uninstall events. This is meant to be invoked by EMS only for sending us data related to install/uninstall of an extension. + PublishExtensionEvents(context.Context, PublishExtensionEventsArgs) error + // [Preview API] + QueryAssociatedAzurePublisher(context.Context, QueryAssociatedAzurePublisherArgs) (*AzurePublisher, error) + // [Preview API] + QueryExtensions(context.Context, QueryExtensionsArgs) (*ExtensionQueryResult, error) + // [Preview API] + QueryPublishers(context.Context, QueryPublishersArgs) (*PublisherQueryResult, error) + // [Preview API] Flags a concern with an existing question for an extension. + ReportQuestion(context.Context, ReportQuestionArgs) (*Concern, error) + // [Preview API] + RequestAcquisition(context.Context, RequestAcquisitionArgs) (*ExtensionAcquisitionRequest, error) + // [Preview API] Send Notification + SendNotifications(context.Context, SendNotificationsArgs) error + // [Preview API] Set all setting entries for the given user/all-users scope + SetGalleryUserSettings(context.Context, SetGalleryUserSettingsArgs) error + // [Preview API] + ShareExtension(context.Context, ShareExtensionArgs) error + // [Preview API] + ShareExtensionById(context.Context, ShareExtensionByIdArgs) error + // [Preview API] + ShareExtensionWithHost(context.Context, ShareExtensionWithHostArgs) error + // [Preview API] + UnshareExtension(context.Context, UnshareExtensionArgs) error + // [Preview API] + UnshareExtensionById(context.Context, UnshareExtensionByIdArgs) error + // [Preview API] + UnshareExtensionWithHost(context.Context, UnshareExtensionWithHostArgs) error + // [Preview API] REST endpoint to update an extension. + UpdateExtension(context.Context, UpdateExtensionArgs) (*PublishedExtension, error) + // [Preview API] + UpdateExtensionById(context.Context, UpdateExtensionByIdArgs) (*PublishedExtension, error) + // [Preview API] + UpdateExtensionProperties(context.Context, UpdateExtensionPropertiesArgs) (*PublishedExtension, error) + // [Preview API] + UpdateExtensionStatistics(context.Context, UpdateExtensionStatisticsArgs) error + // [Preview API] + UpdatePayloadInDraftForEditExtension(context.Context, UpdatePayloadInDraftForEditExtensionArgs) (*ExtensionDraft, error) + // [Preview API] + UpdatePayloadInDraftForNewExtension(context.Context, UpdatePayloadInDraftForNewExtensionArgs) (*ExtensionDraft, error) + // [Preview API] + UpdatePublisher(context.Context, UpdatePublisherArgs) (*Publisher, error) + // [Preview API] Update publisher asset like logo. It accepts asset file as an octet stream and file name is passed in header values. + UpdatePublisherAsset(context.Context, UpdatePublisherAssetArgs) (*map[string]string, error) + // [Preview API] Endpoint to add/modify publisher membership. Currently Supports only addition/modification of 1 user at a time Works only for adding members of same tenant. + UpdatePublisherMembers(context.Context, UpdatePublisherMembersArgs) (*[]PublisherRoleAssignment, error) + // [Preview API] Updates an existing question for an extension. + UpdateQuestion(context.Context, UpdateQuestionArgs) (*Question, error) + // [Preview API] Updates an existing response for a given question for an extension. + UpdateResponse(context.Context, UpdateResponseArgs) (*Response, error) + // [Preview API] Updates or Flags a review + UpdateReview(context.Context, UpdateReviewArgs) (*ReviewPatch, 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) AddAssetForEditExtensionDraft(ctx context.Context, args AddAssetForEditExtensionDraftArgs) (*ExtensionDraftAsset, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.DraftId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DraftId"} + } + routeValues["draftId"] = (*args.DraftId).String() + if args.AssetType == nil || *args.AssetType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AssetType"} + } + routeValues["assetType"] = *args.AssetType + + locationId, _ := uuid.Parse("f1db9c47-6619-4998-a7e5-d7f9f41a4617") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, nil, args.UploadStream, "application/octet-stream", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ExtensionDraftAsset + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddAssetForEditExtensionDraft function +type AddAssetForEditExtensionDraftArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + DraftId *uuid.UUID + // (required) + AssetType *string +} + +// [Preview API] +func (client *ClientImpl) AddAssetForNewExtensionDraft(ctx context.Context, args AddAssetForNewExtensionDraftArgs) (*ExtensionDraftAsset, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.DraftId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DraftId"} + } + routeValues["draftId"] = (*args.DraftId).String() + if args.AssetType == nil || *args.AssetType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AssetType"} + } + routeValues["assetType"] = *args.AssetType + + locationId, _ := uuid.Parse("88c0b1c8-b4f1-498a-9b2a-8446ef9f32e7") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, nil, args.UploadStream, "application/octet-stream", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ExtensionDraftAsset + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddAssetForNewExtensionDraft function +type AddAssetForNewExtensionDraftArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (required) + PublisherName *string + // (required) + DraftId *uuid.UUID + // (required) + AssetType *string +} + +// [Preview API] +func (client *ClientImpl) AssociateAzurePublisher(ctx context.Context, args AssociateAzurePublisherArgs) (*AzurePublisher, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + + queryParams := url.Values{} + if args.AzurePublisherId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "azurePublisherId"} + } + queryParams.Add("azurePublisherId", *args.AzurePublisherId) + locationId, _ := uuid.Parse("efd202a6-9d87-4ebc-9229-d2b8ae2fdb6d") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue AzurePublisher + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AssociateAzurePublisher function +type AssociateAzurePublisherArgs struct { + // (required) + PublisherName *string + // (required) + AzurePublisherId *string +} + +// [Preview API] +func (client *ClientImpl) CreateCategory(ctx context.Context, args CreateCategoryArgs) (*ExtensionCategory, error) { + if args.Category == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Category"} + } + body, marshalErr := json.Marshal(*args.Category) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("476531a3-7024-4516-a76a-ed64d3008ad6") + 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 ExtensionCategory + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateCategory function +type CreateCategoryArgs struct { + // (required) + Category *ExtensionCategory +} + +// [Preview API] +func (client *ClientImpl) CreateDraftForEditExtension(ctx context.Context, args CreateDraftForEditExtensionArgs) (*ExtensionDraft, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + locationId, _ := uuid.Parse("02b33873-4e61-496e-83a2-59d1df46b7d8") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ExtensionDraft + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateDraftForEditExtension function +type CreateDraftForEditExtensionArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string +} + +// [Preview API] +func (client *ClientImpl) CreateDraftForNewExtension(ctx context.Context, args CreateDraftForNewExtensionArgs) (*ExtensionDraft, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + + additionalHeaders := make(map[string]string) + if args.Product != nil { + additionalHeaders["X-Market-UploadFileProduct"] = *args.Product + } + if args.FileName != nil { + additionalHeaders["X-Market-UploadFileName"] = *args.FileName + } + locationId, _ := uuid.Parse("b3ab127d-ebb9-4d22-b611-4e09593c8d79") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, args.UploadStream, "application/octet-stream", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseValue ExtensionDraft + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateDraftForNewExtension function +type CreateDraftForNewExtensionArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (required) + PublisherName *string + // (required) Header to pass the product type of the payload file + Product *string + // (optional) Header to pass the filename of the uploaded data + FileName *string +} + +// [Preview API] +func (client *ClientImpl) CreateExtension(ctx context.Context, args CreateExtensionArgs) (*PublishedExtension, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + locationId, _ := uuid.Parse("a41192c8-9525-4b58-bc86-179fa549d80d") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", nil, nil, args.UploadStream, "application/octet-stream", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PublishedExtension + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateExtension function +type CreateExtensionArgs struct { + // (required) Stream to upload + UploadStream io.Reader +} + +// [Preview API] +func (client *ClientImpl) CreateExtensionWithPublisher(ctx context.Context, args CreateExtensionWithPublisherArgs) (*PublishedExtension, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + + locationId, _ := uuid.Parse("e11ea35a-16fe-4b80-ab11-c4cab88a0966") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, args.UploadStream, "application/octet-stream", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PublishedExtension + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateExtensionWithPublisher function +type CreateExtensionWithPublisherArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (required) + PublisherName *string +} + +// [Preview API] +func (client *ClientImpl) CreatePublisher(ctx context.Context, args CreatePublisherArgs) (*Publisher, error) { + if args.Publisher == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Publisher"} + } + body, marshalErr := json.Marshal(*args.Publisher) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4ddec66a-e4f6-4f5d-999e-9e77710d7ff4") + 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 Publisher + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreatePublisher function +type CreatePublisherArgs struct { + // (required) + Publisher *Publisher +} + +// [Preview API] Creates a new question for an extension. +func (client *ClientImpl) CreateQuestion(ctx context.Context, args CreateQuestionArgs) (*Question, error) { + if args.Question == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Question"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + body, marshalErr := json.Marshal(*args.Question) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("6d1d9741-eca8-4701-a3a5-235afc82dfa4") + 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 Question + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateQuestion function +type CreateQuestionArgs struct { + // (required) Question to be created for the extension. + Question *Question + // (required) Name of the publisher who published the extension. + PublisherName *string + // (required) Name of the extension. + ExtensionName *string +} + +// [Preview API] Creates a new response for a given question for an extension. +func (client *ClientImpl) CreateResponse(ctx context.Context, args CreateResponseArgs) (*Response, error) { + if args.Response == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Response"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.QuestionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.QuestionId"} + } + routeValues["questionId"] = strconv.FormatUint(*args.QuestionId, 10) + + body, marshalErr := json.Marshal(*args.Response) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("7f8ae5e0-46b0-438f-b2e8-13e8513517bd") + 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 Response + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateResponse function +type CreateResponseArgs struct { + // (required) Response to be created for the extension. + Response *Response + // (required) Name of the publisher who published the extension. + PublisherName *string + // (required) Name of the extension. + ExtensionName *string + // (required) Identifier of the question for which response is to be created for the extension. + QuestionId *uint64 +} + +// [Preview API] Creates a new review for an extension +func (client *ClientImpl) CreateReview(ctx context.Context, args CreateReviewArgs) (*Review, error) { + if args.Review == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Review"} + } + routeValues := make(map[string]string) + if args.PubName == nil || *args.PubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PubName"} + } + routeValues["pubName"] = *args.PubName + if args.ExtName == nil || *args.ExtName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtName"} + } + routeValues["extName"] = *args.ExtName + + body, marshalErr := json.Marshal(*args.Review) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e6e85b9d-aa70-40e6-aa28-d0fbf40b91a3") + 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 Review + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateReview function +type CreateReviewArgs struct { + // (required) Review to be created for the extension + Review *Review + // (required) Name of the publisher who published the extension + PubName *string + // (required) Name of the extension + ExtName *string +} + +// [Preview API] +func (client *ClientImpl) DeleteExtension(ctx context.Context, args DeleteExtensionArgs) error { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.Version != nil { + queryParams.Add("version", *args.Version) + } + locationId, _ := uuid.Parse("e11ea35a-16fe-4b80-ab11-c4cab88a0966") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteExtension function +type DeleteExtensionArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (optional) + Version *string +} + +// [Preview API] +func (client *ClientImpl) DeleteExtensionById(ctx context.Context, args DeleteExtensionByIdArgs) error { + routeValues := make(map[string]string) + if args.ExtensionId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ExtensionId"} + } + routeValues["extensionId"] = (*args.ExtensionId).String() + + queryParams := url.Values{} + if args.Version != nil { + queryParams.Add("version", *args.Version) + } + locationId, _ := uuid.Parse("a41192c8-9525-4b58-bc86-179fa549d80d") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteExtensionById function +type DeleteExtensionByIdArgs struct { + // (required) + ExtensionId *uuid.UUID + // (optional) + Version *string +} + +// [Preview API] +func (client *ClientImpl) DeletePublisher(ctx context.Context, args DeletePublisherArgs) error { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + + locationId, _ := uuid.Parse("4ddec66a-e4f6-4f5d-999e-9e77710d7ff4") + _, 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 DeletePublisher function +type DeletePublisherArgs struct { + // (required) + PublisherName *string +} + +// [Preview API] Delete publisher asset like logo +func (client *ClientImpl) DeletePublisherAsset(ctx context.Context, args DeletePublisherAssetArgs) error { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + + queryParams := url.Values{} + if args.AssetType != nil { + queryParams.Add("assetType", *args.AssetType) + } + locationId, _ := uuid.Parse("21143299-34f9-4c62-8ca8-53da691192f9") + _, 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 DeletePublisherAsset function +type DeletePublisherAssetArgs struct { + // (required) Internal name of the publisher + PublisherName *string + // (optional) Type of asset. Default value is 'logo'. + AssetType *string +} + +// [Preview API] Deletes an existing question and all its associated responses for an extension. (soft delete) +func (client *ClientImpl) DeleteQuestion(ctx context.Context, args DeleteQuestionArgs) error { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.QuestionId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.QuestionId"} + } + routeValues["questionId"] = strconv.FormatUint(*args.QuestionId, 10) + + locationId, _ := uuid.Parse("6d1d9741-eca8-4701-a3a5-235afc82dfa4") + _, 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 DeleteQuestion function +type DeleteQuestionArgs struct { + // (required) Name of the publisher who published the extension. + PublisherName *string + // (required) Name of the extension. + ExtensionName *string + // (required) Identifier of the question to be deleted for the extension. + QuestionId *uint64 +} + +// [Preview API] Deletes a response for an extension. (soft delete) +func (client *ClientImpl) DeleteResponse(ctx context.Context, args DeleteResponseArgs) error { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.QuestionId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.QuestionId"} + } + routeValues["questionId"] = strconv.FormatUint(*args.QuestionId, 10) + if args.ResponseId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ResponseId"} + } + routeValues["responseId"] = strconv.FormatUint(*args.ResponseId, 10) + + locationId, _ := uuid.Parse("7f8ae5e0-46b0-438f-b2e8-13e8513517bd") + _, 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 DeleteResponse function +type DeleteResponseArgs struct { + // (required) Name of the publisher who published the extension. + PublisherName *string + // (required) Name of the extension. + ExtensionName *string + // (required) Identifies the question whose response is to be deleted. + QuestionId *uint64 + // (required) Identifies the response to be deleted. + ResponseId *uint64 +} + +// [Preview API] Deletes a review +func (client *ClientImpl) DeleteReview(ctx context.Context, args DeleteReviewArgs) error { + routeValues := make(map[string]string) + if args.PubName == nil || *args.PubName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PubName"} + } + routeValues["pubName"] = *args.PubName + if args.ExtName == nil || *args.ExtName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtName"} + } + routeValues["extName"] = *args.ExtName + if args.ReviewId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ReviewId"} + } + routeValues["reviewId"] = strconv.FormatUint(*args.ReviewId, 10) + + locationId, _ := uuid.Parse("e6e85b9d-aa70-40e6-aa28-d0fbf40b91a3") + _, 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 DeleteReview function +type DeleteReviewArgs struct { + // (required) Name of the publisher who published the extension + PubName *string + // (required) Name of the extension + ExtName *string + // (required) Id of the review which needs to be updated + ReviewId *uint64 +} + +// [Preview API] +func (client *ClientImpl) ExtensionValidator(ctx context.Context, args ExtensionValidatorArgs) error { + if args.AzureRestApiRequestModel == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.AzureRestApiRequestModel"} + } + body, marshalErr := json.Marshal(*args.AzureRestApiRequestModel) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("05e8a5e1-8c59-4c2c-8856-0ff087d1a844") + _, 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 err + } + + return nil +} + +// Arguments for the ExtensionValidator function +type ExtensionValidatorArgs struct { + // (required) + AzureRestApiRequestModel *AzureRestApiRequestModel +} + +// [Preview API] +func (client *ClientImpl) GenerateKey(ctx context.Context, args GenerateKeyArgs) error { + routeValues := make(map[string]string) + if args.KeyType == nil || *args.KeyType == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.KeyType"} + } + routeValues["keyType"] = *args.KeyType + + queryParams := url.Values{} + if args.ExpireCurrentSeconds != nil { + queryParams.Add("expireCurrentSeconds", strconv.Itoa(*args.ExpireCurrentSeconds)) + } + locationId, _ := uuid.Parse("92ed5cf4-c38b-465a-9059-2f2fb7c624b5") + _, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the GenerateKey function +type GenerateKeyArgs struct { + // (required) + KeyType *string + // (optional) + ExpireCurrentSeconds *int +} + +// [Preview API] +func (client *ClientImpl) GetAcquisitionOptions(ctx context.Context, args GetAcquisitionOptionsArgs) (*AcquisitionOptions, error) { + routeValues := make(map[string]string) + if args.ItemId == nil || *args.ItemId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ItemId"} + } + routeValues["itemId"] = *args.ItemId + + queryParams := url.Values{} + if args.InstallationTarget == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "installationTarget"} + } + queryParams.Add("installationTarget", *args.InstallationTarget) + if args.TestCommerce != nil { + queryParams.Add("testCommerce", strconv.FormatBool(*args.TestCommerce)) + } + if args.IsFreeOrTrialInstall != nil { + queryParams.Add("isFreeOrTrialInstall", strconv.FormatBool(*args.IsFreeOrTrialInstall)) + } + locationId, _ := uuid.Parse("9d0a0105-075e-4760-aa15-8bcf54d1bd7d") + 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 AcquisitionOptions + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAcquisitionOptions function +type GetAcquisitionOptionsArgs struct { + // (required) + ItemId *string + // (required) + InstallationTarget *string + // (optional) + TestCommerce *bool + // (optional) + IsFreeOrTrialInstall *bool +} + +// [Preview API] +func (client *ClientImpl) GetAsset(ctx context.Context, args GetAssetArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.ExtensionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ExtensionId"} + } + routeValues["extensionId"] = (*args.ExtensionId).String() + if args.Version == nil || *args.Version == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + if args.AssetType == nil || *args.AssetType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AssetType"} + } + routeValues["assetType"] = *args.AssetType + + queryParams := url.Values{} + if args.AccountToken != nil { + queryParams.Add("accountToken", *args.AccountToken) + } + if args.AcceptDefault != nil { + queryParams.Add("acceptDefault", strconv.FormatBool(*args.AcceptDefault)) + } + additionalHeaders := make(map[string]string) + if args.AccountTokenHeader != nil { + additionalHeaders["X-Market-AccountToken"] = *args.AccountTokenHeader + } + locationId, _ := uuid.Parse("5d545f3d-ef47-488b-8be3-f5ee1517856c") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/octet-stream", additionalHeaders) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetAsset function +type GetAssetArgs struct { + // (required) + ExtensionId *uuid.UUID + // (required) + Version *string + // (required) + AssetType *string + // (optional) + AccountToken *string + // (optional) + AcceptDefault *bool + // (optional) Header to pass the account token + AccountTokenHeader *string +} + +// [Preview API] +func (client *ClientImpl) GetAssetAuthenticated(ctx context.Context, args GetAssetAuthenticatedArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.Version == nil || *args.Version == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + if args.AssetType == nil || *args.AssetType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AssetType"} + } + routeValues["assetType"] = *args.AssetType + + queryParams := url.Values{} + if args.AccountToken != nil { + queryParams.Add("accountToken", *args.AccountToken) + } + additionalHeaders := make(map[string]string) + if args.AccountTokenHeader != nil { + additionalHeaders["X-Market-AccountToken"] = *args.AccountTokenHeader + } + locationId, _ := uuid.Parse("506aff36-2622-4f70-8063-77cce6366d20") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/octet-stream", additionalHeaders) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetAssetAuthenticated function +type GetAssetAuthenticatedArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + Version *string + // (required) + AssetType *string + // (optional) + AccountToken *string + // (optional) Header to pass the account token + AccountTokenHeader *string +} + +// [Preview API] +func (client *ClientImpl) GetAssetByName(ctx context.Context, args GetAssetByNameArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.Version == nil || *args.Version == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + if args.AssetType == nil || *args.AssetType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AssetType"} + } + routeValues["assetType"] = *args.AssetType + + queryParams := url.Values{} + if args.AccountToken != nil { + queryParams.Add("accountToken", *args.AccountToken) + } + if args.AcceptDefault != nil { + queryParams.Add("acceptDefault", strconv.FormatBool(*args.AcceptDefault)) + } + additionalHeaders := make(map[string]string) + if args.AccountTokenHeader != nil { + additionalHeaders["X-Market-AccountToken"] = *args.AccountTokenHeader + } + locationId, _ := uuid.Parse("7529171f-a002-4180-93ba-685f358a0482") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/octet-stream", additionalHeaders) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetAssetByName function +type GetAssetByNameArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + Version *string + // (required) + AssetType *string + // (optional) + AccountToken *string + // (optional) + AcceptDefault *bool + // (optional) Header to pass the account token + AccountTokenHeader *string +} + +// [Preview API] +func (client *ClientImpl) GetAssetFromEditExtensionDraft(ctx context.Context, args GetAssetFromEditExtensionDraftArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.DraftId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DraftId"} + } + routeValues["draftId"] = (*args.DraftId).String() + if args.AssetType == nil || *args.AssetType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AssetType"} + } + routeValues["assetType"] = *args.AssetType + + queryParams := url.Values{} + if args.ExtensionName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "extensionName"} + } + queryParams.Add("extensionName", *args.ExtensionName) + locationId, _ := uuid.Parse("88c0b1c8-b4f1-498a-9b2a-8446ef9f32e7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/octet-stream", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetAssetFromEditExtensionDraft function +type GetAssetFromEditExtensionDraftArgs struct { + // (required) + PublisherName *string + // (required) + DraftId *uuid.UUID + // (required) + AssetType *string + // (required) + ExtensionName *string +} + +// [Preview API] +func (client *ClientImpl) GetAssetFromNewExtensionDraft(ctx context.Context, args GetAssetFromNewExtensionDraftArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.DraftId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DraftId"} + } + routeValues["draftId"] = (*args.DraftId).String() + if args.AssetType == nil || *args.AssetType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AssetType"} + } + routeValues["assetType"] = *args.AssetType + + locationId, _ := uuid.Parse("88c0b1c8-b4f1-498a-9b2a-8446ef9f32e7") + 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 GetAssetFromNewExtensionDraft function +type GetAssetFromNewExtensionDraftArgs struct { + // (required) + PublisherName *string + // (required) + DraftId *uuid.UUID + // (required) + AssetType *string +} + +// [Preview API] +func (client *ClientImpl) GetAssetWithToken(ctx context.Context, args GetAssetWithTokenArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.Version == nil || *args.Version == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + if args.AssetType == nil || *args.AssetType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AssetType"} + } + routeValues["assetType"] = *args.AssetType + if args.AssetToken != nil && *args.AssetToken != "" { + routeValues["assetToken"] = *args.AssetToken + } + + queryParams := url.Values{} + if args.AccountToken != nil { + queryParams.Add("accountToken", *args.AccountToken) + } + if args.AcceptDefault != nil { + queryParams.Add("acceptDefault", strconv.FormatBool(*args.AcceptDefault)) + } + additionalHeaders := make(map[string]string) + if args.AccountTokenHeader != nil { + additionalHeaders["X-Market-AccountToken"] = *args.AccountTokenHeader + } + locationId, _ := uuid.Parse("364415a1-0077-4a41-a7a0-06edd4497492") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/octet-stream", additionalHeaders) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetAssetWithToken function +type GetAssetWithTokenArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + Version *string + // (required) + AssetType *string + // (optional) + AssetToken *string + // (optional) + AccountToken *string + // (optional) + AcceptDefault *bool + // (optional) Header to pass the account token + AccountTokenHeader *string +} + +// [Preview API] +func (client *ClientImpl) GetCategories(ctx context.Context, args GetCategoriesArgs) (*[]string, error) { + queryParams := url.Values{} + if args.Languages != nil { + queryParams.Add("languages", *args.Languages) + } + locationId, _ := uuid.Parse("e0a5a71e-3ac3-43a0-ae7d-0bb5c3046a2a") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, 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 GetCategories function +type GetCategoriesArgs struct { + // (optional) + Languages *string +} + +// [Preview API] +func (client *ClientImpl) GetCategoryDetails(ctx context.Context, args GetCategoryDetailsArgs) (*CategoriesResult, error) { + routeValues := make(map[string]string) + if args.CategoryName == nil || *args.CategoryName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.CategoryName"} + } + routeValues["categoryName"] = *args.CategoryName + + queryParams := url.Values{} + if args.Languages != nil { + queryParams.Add("languages", *args.Languages) + } + if args.Product != nil { + queryParams.Add("product", *args.Product) + } + locationId, _ := uuid.Parse("75d3c04d-84d2-4973-acd2-22627587dabc") + 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 CategoriesResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCategoryDetails function +type GetCategoryDetailsArgs struct { + // (required) + CategoryName *string + // (optional) + Languages *string + // (optional) + Product *string +} + +// [Preview API] +func (client *ClientImpl) GetCategoryTree(ctx context.Context, args GetCategoryTreeArgs) (*ProductCategory, error) { + routeValues := make(map[string]string) + if args.Product == nil || *args.Product == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Product"} + } + routeValues["product"] = *args.Product + if args.CategoryId == nil || *args.CategoryId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.CategoryId"} + } + routeValues["categoryId"] = *args.CategoryId + + queryParams := url.Values{} + if args.Lcid != nil { + queryParams.Add("lcid", strconv.Itoa(*args.Lcid)) + } + if args.Source != nil { + queryParams.Add("source", *args.Source) + } + if args.ProductVersion != nil { + queryParams.Add("productVersion", *args.ProductVersion) + } + if args.Skus != nil { + queryParams.Add("skus", *args.Skus) + } + if args.SubSkus != nil { + queryParams.Add("subSkus", *args.SubSkus) + } + locationId, _ := uuid.Parse("1102bb42-82b0-4955-8d8a-435d6b4cedd3") + 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 ProductCategory + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCategoryTree function +type GetCategoryTreeArgs struct { + // (required) + Product *string + // (required) + CategoryId *string + // (optional) + Lcid *int + // (optional) + Source *string + // (optional) + ProductVersion *string + // (optional) + Skus *string + // (optional) + SubSkus *string +} + +// [Preview API] +func (client *ClientImpl) GetCertificate(ctx context.Context, args GetCertificateArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.Version != nil && *args.Version != "" { + routeValues["version"] = *args.Version + } + + locationId, _ := uuid.Parse("e905ad6a-3f1f-4d08-9f6d-7d357ff8b7d0") + 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 GetCertificate function +type GetCertificateArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (optional) + Version *string +} + +// [Preview API] +func (client *ClientImpl) GetContentVerificationLog(ctx context.Context, args GetContentVerificationLogArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + locationId, _ := uuid.Parse("c0f1c7c4-3557-4ffb-b774-1e48c4865e99") + 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 GetContentVerificationLog function +type GetContentVerificationLogArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string +} + +// [Preview API] +func (client *ClientImpl) GetExtension(ctx context.Context, args GetExtensionArgs) (*PublishedExtension, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.Version != nil { + queryParams.Add("version", *args.Version) + } + if args.Flags != nil { + queryParams.Add("flags", string(*args.Flags)) + } + if args.AccountToken != nil { + queryParams.Add("accountToken", *args.AccountToken) + } + additionalHeaders := make(map[string]string) + if args.AccountTokenHeader != nil { + additionalHeaders["X-Market-AccountToken"] = *args.AccountTokenHeader + } + locationId, _ := uuid.Parse("e11ea35a-16fe-4b80-ab11-c4cab88a0966") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseValue PublishedExtension + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetExtension function +type GetExtensionArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (optional) + Version *string + // (optional) + Flags *ExtensionQueryFlags + // (optional) + AccountToken *string + // (optional) Header to pass the account token + AccountTokenHeader *string +} + +// [Preview API] +func (client *ClientImpl) GetExtensionById(ctx context.Context, args GetExtensionByIdArgs) (*PublishedExtension, error) { + routeValues := make(map[string]string) + if args.ExtensionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ExtensionId"} + } + routeValues["extensionId"] = (*args.ExtensionId).String() + + queryParams := url.Values{} + if args.Version != nil { + queryParams.Add("version", *args.Version) + } + if args.Flags != nil { + queryParams.Add("flags", string(*args.Flags)) + } + locationId, _ := uuid.Parse("a41192c8-9525-4b58-bc86-179fa549d80d") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PublishedExtension + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetExtensionById function +type GetExtensionByIdArgs struct { + // (required) + ExtensionId *uuid.UUID + // (optional) + Version *string + // (optional) + Flags *ExtensionQueryFlags +} + +// [Preview API] +func (client *ClientImpl) GetExtensionDailyStats(ctx context.Context, args GetExtensionDailyStatsArgs) (*ExtensionDailyStats, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.Days != nil { + queryParams.Add("days", strconv.Itoa(*args.Days)) + } + if args.Aggregate != nil { + queryParams.Add("aggregate", string(*args.Aggregate)) + } + if args.AfterDate != nil { + queryParams.Add("afterDate", (*args.AfterDate).String()) + } + locationId, _ := uuid.Parse("ae06047e-51c5-4fb4-ab65-7be488544416") + 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 ExtensionDailyStats + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetExtensionDailyStats function +type GetExtensionDailyStatsArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (optional) + Days *int + // (optional) + Aggregate *ExtensionStatsAggregateType + // (optional) + AfterDate *azuredevops.Time +} + +// [Preview API] This route/location id only supports HTTP POST anonymously, so that the page view daily stat can be incremented from Marketplace client. Trying to call GET on this route should result in an exception. Without this explicit implementation, calling GET on this public route invokes the above GET implementation GetExtensionDailyStats. +func (client *ClientImpl) GetExtensionDailyStatsAnonymous(ctx context.Context, args GetExtensionDailyStatsAnonymousArgs) (*ExtensionDailyStats, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.Version == nil || *args.Version == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + + locationId, _ := uuid.Parse("4fa7adb6-ca65-4075-a232-5f28323288ea") + 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 ExtensionDailyStats + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetExtensionDailyStatsAnonymous function +type GetExtensionDailyStatsAnonymousArgs struct { + // (required) Name of the publisher + PublisherName *string + // (required) Name of the extension + ExtensionName *string + // (required) Version of the extension + Version *string +} + +// [Preview API] Get install/uninstall events of an extension. If both count and afterDate parameters are specified, count takes precedence. +func (client *ClientImpl) GetExtensionEvents(ctx context.Context, args GetExtensionEventsArgs) (*ExtensionEvents, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.Count != nil { + queryParams.Add("count", strconv.Itoa(*args.Count)) + } + if args.AfterDate != nil { + queryParams.Add("afterDate", (*args.AfterDate).String()) + } + if args.Include != nil { + queryParams.Add("include", *args.Include) + } + if args.IncludeProperty != nil { + queryParams.Add("includeProperty", *args.IncludeProperty) + } + locationId, _ := uuid.Parse("3d13c499-2168-4d06-bef4-14aba185dcd5") + 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 ExtensionEvents + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetExtensionEvents function +type GetExtensionEventsArgs struct { + // (required) Name of the publisher + PublisherName *string + // (required) Name of the extension + ExtensionName *string + // (optional) Count of events to fetch, applies to each event type. + Count *int + // (optional) Fetch events that occurred on or after this date + AfterDate *azuredevops.Time + // (optional) Filter options. Supported values: install, uninstall, review, acquisition, sales. Default is to fetch all types of events + Include *string + // (optional) Event properties to include. Currently only 'lastContactDetails' is supported for uninstall events + IncludeProperty *string +} + +// [Preview API] Returns extension reports +func (client *ClientImpl) GetExtensionReports(ctx context.Context, args GetExtensionReportsArgs) (interface{}, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.Days != nil { + queryParams.Add("days", strconv.Itoa(*args.Days)) + } + if args.Count != nil { + queryParams.Add("count", strconv.Itoa(*args.Count)) + } + if args.AfterDate != nil { + queryParams.Add("afterDate", (*args.AfterDate).String()) + } + locationId, _ := uuid.Parse("79e0c74f-157f-437e-845f-74fbb4121d4c") + 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 interface{} + err = client.Client.UnmarshalBody(resp, responseValue) + return responseValue, err +} + +// Arguments for the GetExtensionReports function +type GetExtensionReportsArgs struct { + // (required) Name of the publisher who published the extension + PublisherName *string + // (required) Name of the extension + ExtensionName *string + // (optional) Last n days report. If afterDate and days are specified, days will take priority + Days *int + // (optional) Number of events to be returned + Count *int + // (optional) Use if you want to fetch events newer than the specified date + AfterDate *azuredevops.Time +} + +// [Preview API] Get all setting entries for the given user/all-users scope +func (client *ClientImpl) GetGalleryUserSettings(ctx context.Context, args GetGalleryUserSettingsArgs) (*map[string]interface{}, error) { + routeValues := make(map[string]string) + if args.UserScope == nil || *args.UserScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + if args.Key != nil && *args.Key != "" { + routeValues["key"] = *args.Key + } + + locationId, _ := uuid.Parse("9b75ece3-7960-401c-848b-148ac01ca350") + 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 map[string]interface{} + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetGalleryUserSettings function +type GetGalleryUserSettingsArgs struct { + // (required) User-Scope at which to get the value. Should be "me" for the current user or "host" for all users. + UserScope *string + // (optional) Optional key under which to filter all the entries + Key *string +} + +// [Preview API] This endpoint gets hit when you download a VSTS extension from the Web UI +func (client *ClientImpl) GetPackage(ctx context.Context, args GetPackageArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.Version == nil || *args.Version == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + + queryParams := url.Values{} + if args.AccountToken != nil { + queryParams.Add("accountToken", *args.AccountToken) + } + if args.AcceptDefault != nil { + queryParams.Add("acceptDefault", strconv.FormatBool(*args.AcceptDefault)) + } + additionalHeaders := make(map[string]string) + if args.AccountTokenHeader != nil { + additionalHeaders["X-Market-AccountToken"] = *args.AccountTokenHeader + } + locationId, _ := uuid.Parse("7cb576f8-1cae-4c4b-b7b1-e4af5759e965") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/octet-stream", additionalHeaders) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetPackage function +type GetPackageArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + Version *string + // (optional) + AccountToken *string + // (optional) + AcceptDefault *bool + // (optional) Header to pass the account token + AccountTokenHeader *string +} + +// [Preview API] +func (client *ClientImpl) GetPublisher(ctx context.Context, args GetPublisherArgs) (*Publisher, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + + queryParams := url.Values{} + if args.Flags != nil { + queryParams.Add("flags", strconv.Itoa(*args.Flags)) + } + locationId, _ := uuid.Parse("4ddec66a-e4f6-4f5d-999e-9e77710d7ff4") + 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 Publisher + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPublisher function +type GetPublisherArgs struct { + // (required) + PublisherName *string + // (optional) + Flags *int +} + +// [Preview API] Get publisher asset like logo as a stream +func (client *ClientImpl) GetPublisherAsset(ctx context.Context, args GetPublisherAssetArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + + queryParams := url.Values{} + if args.AssetType != nil { + queryParams.Add("assetType", *args.AssetType) + } + locationId, _ := uuid.Parse("21143299-34f9-4c62-8ca8-53da691192f9") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/octet-stream", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetPublisherAsset function +type GetPublisherAssetArgs struct { + // (required) Internal name of the publisher + PublisherName *string + // (optional) Type of asset. Default value is 'logo'. + AssetType *string +} + +// [Preview API] Returns a list of questions with their responses associated with an extension. +func (client *ClientImpl) GetQuestions(ctx context.Context, args GetQuestionsArgs) (*QuestionsResult, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.Count != nil { + queryParams.Add("count", strconv.Itoa(*args.Count)) + } + if args.Page != nil { + queryParams.Add("page", strconv.Itoa(*args.Page)) + } + if args.AfterDate != nil { + queryParams.Add("afterDate", (*args.AfterDate).String()) + } + locationId, _ := uuid.Parse("c010d03d-812c-4ade-ae07-c1862475eda5") + 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 QuestionsResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetQuestions function +type GetQuestionsArgs struct { + // (required) Name of the publisher who published the extension. + PublisherName *string + // (required) Name of the extension. + ExtensionName *string + // (optional) Number of questions to retrieve (defaults to 10). + Count *int + // (optional) Page number from which set of questions are to be retrieved. + Page *int + // (optional) If provided, results questions are returned which were posted after this date + AfterDate *azuredevops.Time +} + +// [Preview API] Returns a list of reviews associated with an extension +func (client *ClientImpl) GetReviews(ctx context.Context, args GetReviewsArgs) (*ReviewsResult, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.Count != nil { + queryParams.Add("count", strconv.Itoa(*args.Count)) + } + if args.FilterOptions != nil { + queryParams.Add("filterOptions", string(*args.FilterOptions)) + } + if args.BeforeDate != nil { + queryParams.Add("beforeDate", (*args.BeforeDate).String()) + } + if args.AfterDate != nil { + queryParams.Add("afterDate", (*args.AfterDate).String()) + } + locationId, _ := uuid.Parse("5b3f819f-f247-42ad-8c00-dd9ab9ab246d") + 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 ReviewsResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetReviews function +type GetReviewsArgs struct { + // (required) Name of the publisher who published the extension + PublisherName *string + // (required) Name of the extension + ExtensionName *string + // (optional) Number of reviews to retrieve (defaults to 5) + Count *int + // (optional) FilterOptions to filter out empty reviews etcetera, defaults to none + FilterOptions *ReviewFilterOptions + // (optional) Use if you want to fetch reviews older than the specified date, defaults to null + BeforeDate *azuredevops.Time + // (optional) Use if you want to fetch reviews newer than the specified date, defaults to null + AfterDate *azuredevops.Time +} + +// [Preview API] Returns a summary of the reviews +func (client *ClientImpl) GetReviewsSummary(ctx context.Context, args GetReviewsSummaryArgs) (*ReviewSummary, error) { + routeValues := make(map[string]string) + if args.PubName == nil || *args.PubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PubName"} + } + routeValues["pubName"] = *args.PubName + if args.ExtName == nil || *args.ExtName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtName"} + } + routeValues["extName"] = *args.ExtName + + queryParams := url.Values{} + if args.BeforeDate != nil { + queryParams.Add("beforeDate", (*args.BeforeDate).String()) + } + if args.AfterDate != nil { + queryParams.Add("afterDate", (*args.AfterDate).String()) + } + locationId, _ := uuid.Parse("b7b44e21-209e-48f0-ae78-04727fc37d77") + 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 ReviewSummary + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetReviewsSummary function +type GetReviewsSummaryArgs struct { + // (required) Name of the publisher who published the extension + PubName *string + // (required) Name of the extension + ExtName *string + // (optional) Use if you want to fetch summary of reviews older than the specified date, defaults to null + BeforeDate *azuredevops.Time + // (optional) Use if you want to fetch summary of reviews newer than the specified date, defaults to null + AfterDate *azuredevops.Time +} + +// [Preview API] +func (client *ClientImpl) GetRootCategories(ctx context.Context, args GetRootCategoriesArgs) (*ProductCategoriesResult, error) { + routeValues := make(map[string]string) + if args.Product == nil || *args.Product == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Product"} + } + routeValues["product"] = *args.Product + + queryParams := url.Values{} + if args.Lcid != nil { + queryParams.Add("lcid", strconv.Itoa(*args.Lcid)) + } + if args.Source != nil { + queryParams.Add("source", *args.Source) + } + if args.ProductVersion != nil { + queryParams.Add("productVersion", *args.ProductVersion) + } + if args.Skus != nil { + queryParams.Add("skus", *args.Skus) + } + if args.SubSkus != nil { + queryParams.Add("subSkus", *args.SubSkus) + } + locationId, _ := uuid.Parse("31fba831-35b2-46f6-a641-d05de5a877d8") + 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 ProductCategoriesResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRootCategories function +type GetRootCategoriesArgs struct { + // (required) + Product *string + // (optional) + Lcid *int + // (optional) + Source *string + // (optional) + ProductVersion *string + // (optional) + Skus *string + // (optional) + SubSkus *string +} + +// [Preview API] +func (client *ClientImpl) GetSigningKey(ctx context.Context, args GetSigningKeyArgs) (*string, error) { + routeValues := make(map[string]string) + if args.KeyType == nil || *args.KeyType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.KeyType"} + } + routeValues["keyType"] = *args.KeyType + + locationId, _ := uuid.Parse("92ed5cf4-c38b-465a-9059-2f2fb7c624b5") + 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 string + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSigningKey function +type GetSigningKeyArgs struct { + // (required) + KeyType *string +} + +// [Preview API] +func (client *ClientImpl) GetVerificationLog(ctx context.Context, args GetVerificationLogArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.Version == nil || *args.Version == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + + locationId, _ := uuid.Parse("c5523abe-b843-437f-875b-5833064efe4d") + 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 GetVerificationLog function +type GetVerificationLogArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + Version *string +} + +// [Preview API] Increments a daily statistic associated with the extension +func (client *ClientImpl) IncrementExtensionDailyStat(ctx context.Context, args IncrementExtensionDailyStatArgs) error { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.Version == nil || *args.Version == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + + queryParams := url.Values{} + if args.StatType == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "statType"} + } + queryParams.Add("statType", *args.StatType) + locationId, _ := uuid.Parse("4fa7adb6-ca65-4075-a232-5f28323288ea") + _, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the IncrementExtensionDailyStat function +type IncrementExtensionDailyStatArgs struct { + // (required) Name of the publisher + PublisherName *string + // (required) Name of the extension + ExtensionName *string + // (required) Version of the extension + Version *string + // (required) Type of stat to increment + StatType *string +} + +// [Preview API] +func (client *ClientImpl) PerformEditExtensionDraftOperation(ctx context.Context, args PerformEditExtensionDraftOperationArgs) (*ExtensionDraft, error) { + if args.DraftPatch == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DraftPatch"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.DraftId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DraftId"} + } + routeValues["draftId"] = (*args.DraftId).String() + + body, marshalErr := json.Marshal(*args.DraftPatch) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("02b33873-4e61-496e-83a2-59d1df46b7d8") + 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 ExtensionDraft + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the PerformEditExtensionDraftOperation function +type PerformEditExtensionDraftOperationArgs struct { + // (required) + DraftPatch *ExtensionDraftPatch + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + DraftId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) PerformNewExtensionDraftOperation(ctx context.Context, args PerformNewExtensionDraftOperationArgs) (*ExtensionDraft, error) { + if args.DraftPatch == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DraftPatch"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.DraftId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DraftId"} + } + routeValues["draftId"] = (*args.DraftId).String() + + body, marshalErr := json.Marshal(*args.DraftPatch) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b3ab127d-ebb9-4d22-b611-4e09593c8d79") + 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 ExtensionDraft + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the PerformNewExtensionDraftOperation function +type PerformNewExtensionDraftOperationArgs struct { + // (required) + DraftPatch *ExtensionDraftPatch + // (required) + PublisherName *string + // (required) + DraftId *uuid.UUID +} + +// [Preview API] API endpoint to publish extension install/uninstall events. This is meant to be invoked by EMS only for sending us data related to install/uninstall of an extension. +func (client *ClientImpl) PublishExtensionEvents(ctx context.Context, args PublishExtensionEventsArgs) error { + if args.ExtensionEvents == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ExtensionEvents"} + } + body, marshalErr := json.Marshal(*args.ExtensionEvents) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("0bf2bd3a-70e0-4d5d-8bf7-bd4a9c2ab6e7") + _, 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 err + } + + return nil +} + +// Arguments for the PublishExtensionEvents function +type PublishExtensionEventsArgs struct { + // (required) + ExtensionEvents *[]ExtensionEvents +} + +// [Preview API] +func (client *ClientImpl) QueryAssociatedAzurePublisher(ctx context.Context, args QueryAssociatedAzurePublisherArgs) (*AzurePublisher, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + + locationId, _ := uuid.Parse("efd202a6-9d87-4ebc-9229-d2b8ae2fdb6d") + 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 AzurePublisher + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryAssociatedAzurePublisher function +type QueryAssociatedAzurePublisherArgs struct { + // (required) + PublisherName *string +} + +// [Preview API] +func (client *ClientImpl) QueryExtensions(ctx context.Context, args QueryExtensionsArgs) (*ExtensionQueryResult, error) { + if args.ExtensionQuery == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ExtensionQuery"} + } + queryParams := url.Values{} + if args.AccountToken != nil { + queryParams.Add("accountToken", *args.AccountToken) + } + additionalHeaders := make(map[string]string) + if args.AccountTokenHeader != nil { + additionalHeaders["X-Market-AccountToken"] = *args.AccountTokenHeader + } + body, marshalErr := json.Marshal(*args.ExtensionQuery) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("eb9d5ee1-6d43-456b-b80e-8a96fbc014b6") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, queryParams, bytes.NewReader(body), "application/json", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseValue ExtensionQueryResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryExtensions function +type QueryExtensionsArgs struct { + // (required) + ExtensionQuery *ExtensionQuery + // (optional) + AccountToken *string + // (optional) Header to pass the account token + AccountTokenHeader *string +} + +// [Preview API] +func (client *ClientImpl) QueryPublishers(ctx context.Context, args QueryPublishersArgs) (*PublisherQueryResult, error) { + if args.PublisherQuery == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PublisherQuery"} + } + body, marshalErr := json.Marshal(*args.PublisherQuery) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2ad6ee0a-b53f-4034-9d1d-d009fda1212e") + 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 PublisherQueryResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryPublishers function +type QueryPublishersArgs struct { + // (required) + PublisherQuery *PublisherQuery +} + +// [Preview API] Flags a concern with an existing question for an extension. +func (client *ClientImpl) ReportQuestion(ctx context.Context, args ReportQuestionArgs) (*Concern, error) { + if args.Concern == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Concern"} + } + routeValues := make(map[string]string) + if args.PubName == nil || *args.PubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PubName"} + } + routeValues["pubName"] = *args.PubName + if args.ExtName == nil || *args.ExtName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtName"} + } + routeValues["extName"] = *args.ExtName + if args.QuestionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.QuestionId"} + } + routeValues["questionId"] = strconv.FormatUint(*args.QuestionId, 10) + + body, marshalErr := json.Marshal(*args.Concern) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("784910cd-254a-494d-898b-0728549b2f10") + 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 Concern + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReportQuestion function +type ReportQuestionArgs struct { + // (required) User reported concern with a question for the extension. + Concern *Concern + // (required) Name of the publisher who published the extension. + PubName *string + // (required) Name of the extension. + ExtName *string + // (required) Identifier of the question to be updated for the extension. + QuestionId *uint64 +} + +// [Preview API] +func (client *ClientImpl) RequestAcquisition(ctx context.Context, args RequestAcquisitionArgs) (*ExtensionAcquisitionRequest, error) { + if args.AcquisitionRequest == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AcquisitionRequest"} + } + body, marshalErr := json.Marshal(*args.AcquisitionRequest) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("3adb1f2d-e328-446e-be73-9f6d98071c45") + 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 ExtensionAcquisitionRequest + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the RequestAcquisition function +type RequestAcquisitionArgs struct { + // (required) + AcquisitionRequest *ExtensionAcquisitionRequest +} + +// [Preview API] Send Notification +func (client *ClientImpl) SendNotifications(ctx context.Context, args SendNotificationsArgs) error { + if args.NotificationData == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.NotificationData"} + } + body, marshalErr := json.Marshal(*args.NotificationData) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("eab39817-413c-4602-a49f-07ad00844980") + _, 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 err + } + + return nil +} + +// Arguments for the SendNotifications function +type SendNotificationsArgs struct { + // (required) Denoting the data needed to send notification + NotificationData *NotificationsData +} + +// [Preview API] Set all setting entries for the given user/all-users scope +func (client *ClientImpl) SetGalleryUserSettings(ctx context.Context, args SetGalleryUserSettingsArgs) error { + if args.Entries == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Entries"} + } + routeValues := make(map[string]string) + if args.UserScope == nil || *args.UserScope == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + + body, marshalErr := json.Marshal(*args.Entries) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("9b75ece3-7960-401c-848b-148ac01ca350") + _, 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 err + } + + return nil +} + +// Arguments for the SetGalleryUserSettings function +type SetGalleryUserSettingsArgs struct { + // (required) A key-value pair of all settings that need to be set + Entries *map[string]interface{} + // (required) User-Scope at which to get the value. Should be "me" for the current user or "host" for all users. + UserScope *string +} + +// [Preview API] +func (client *ClientImpl) ShareExtension(ctx context.Context, args ShareExtensionArgs) error { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.AccountName == nil || *args.AccountName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AccountName"} + } + routeValues["accountName"] = *args.AccountName + + locationId, _ := uuid.Parse("a1e66d8f-f5de-4d16-8309-91a4e015ee46") + _, 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 ShareExtension function +type ShareExtensionArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + AccountName *string +} + +// [Preview API] +func (client *ClientImpl) ShareExtensionById(ctx context.Context, args ShareExtensionByIdArgs) error { + routeValues := make(map[string]string) + if args.ExtensionId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ExtensionId"} + } + routeValues["extensionId"] = (*args.ExtensionId).String() + if args.AccountName == nil || *args.AccountName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AccountName"} + } + routeValues["accountName"] = *args.AccountName + + locationId, _ := uuid.Parse("1f19631b-a0b4-4a03-89c2-d79785d24360") + _, 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 ShareExtensionById function +type ShareExtensionByIdArgs struct { + // (required) + ExtensionId *uuid.UUID + // (required) + AccountName *string +} + +// [Preview API] +func (client *ClientImpl) ShareExtensionWithHost(ctx context.Context, args ShareExtensionWithHostArgs) error { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.HostType == nil || *args.HostType == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HostType"} + } + routeValues["hostType"] = *args.HostType + if args.HostName == nil || *args.HostName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HostName"} + } + routeValues["hostName"] = *args.HostName + + locationId, _ := uuid.Parse("328a3af8-d124-46e9-9483-01690cd415b9") + _, 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 ShareExtensionWithHost function +type ShareExtensionWithHostArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + HostType *string + // (required) + HostName *string +} + +// [Preview API] +func (client *ClientImpl) UnshareExtension(ctx context.Context, args UnshareExtensionArgs) error { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.AccountName == nil || *args.AccountName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AccountName"} + } + routeValues["accountName"] = *args.AccountName + + locationId, _ := uuid.Parse("a1e66d8f-f5de-4d16-8309-91a4e015ee46") + _, 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 UnshareExtension function +type UnshareExtensionArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + AccountName *string +} + +// [Preview API] +func (client *ClientImpl) UnshareExtensionById(ctx context.Context, args UnshareExtensionByIdArgs) error { + routeValues := make(map[string]string) + if args.ExtensionId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ExtensionId"} + } + routeValues["extensionId"] = (*args.ExtensionId).String() + if args.AccountName == nil || *args.AccountName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.AccountName"} + } + routeValues["accountName"] = *args.AccountName + + locationId, _ := uuid.Parse("1f19631b-a0b4-4a03-89c2-d79785d24360") + _, 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 UnshareExtensionById function +type UnshareExtensionByIdArgs struct { + // (required) + ExtensionId *uuid.UUID + // (required) + AccountName *string +} + +// [Preview API] +func (client *ClientImpl) UnshareExtensionWithHost(ctx context.Context, args UnshareExtensionWithHostArgs) error { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.HostType == nil || *args.HostType == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HostType"} + } + routeValues["hostType"] = *args.HostType + if args.HostName == nil || *args.HostName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HostName"} + } + routeValues["hostName"] = *args.HostName + + locationId, _ := uuid.Parse("328a3af8-d124-46e9-9483-01690cd415b9") + _, 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 UnshareExtensionWithHost function +type UnshareExtensionWithHostArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + HostType *string + // (required) + HostName *string +} + +// [Preview API] REST endpoint to update an extension. +func (client *ClientImpl) UpdateExtension(ctx context.Context, args UpdateExtensionArgs) (*PublishedExtension, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.BypassScopeCheck != nil { + queryParams.Add("bypassScopeCheck", strconv.FormatBool(*args.BypassScopeCheck)) + } + locationId, _ := uuid.Parse("e11ea35a-16fe-4b80-ab11-c4cab88a0966") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.2", routeValues, queryParams, args.UploadStream, "application/octet-stream", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PublishedExtension + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateExtension function +type UpdateExtensionArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (required) Name of the publisher + PublisherName *string + // (required) Name of the extension + ExtensionName *string + // (optional) This parameter decides if the scope change check needs to be invoked or not + BypassScopeCheck *bool +} + +// [Preview API] +func (client *ClientImpl) UpdateExtensionById(ctx context.Context, args UpdateExtensionByIdArgs) (*PublishedExtension, error) { + routeValues := make(map[string]string) + if args.ExtensionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ExtensionId"} + } + routeValues["extensionId"] = (*args.ExtensionId).String() + + locationId, _ := uuid.Parse("a41192c8-9525-4b58-bc86-179fa549d80d") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PublishedExtension + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateExtensionById function +type UpdateExtensionByIdArgs struct { + // (required) + ExtensionId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) UpdateExtensionProperties(ctx context.Context, args UpdateExtensionPropertiesArgs) (*PublishedExtension, error) { + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + queryParams := url.Values{} + if args.Flags == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "flags"} + } + queryParams.Add("flags", string(*args.Flags)) + locationId, _ := uuid.Parse("e11ea35a-16fe-4b80-ab11-c4cab88a0966") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue PublishedExtension + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateExtensionProperties function +type UpdateExtensionPropertiesArgs struct { + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + Flags *PublishedExtensionFlags +} + +// [Preview API] +func (client *ClientImpl) UpdateExtensionStatistics(ctx context.Context, args UpdateExtensionStatisticsArgs) error { + if args.ExtensionStatisticsUpdate == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ExtensionStatisticsUpdate"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + + body, marshalErr := json.Marshal(*args.ExtensionStatisticsUpdate) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("a0ea3204-11e9-422d-a9ca-45851cc41400") + _, 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 err + } + + return nil +} + +// Arguments for the UpdateExtensionStatistics function +type UpdateExtensionStatisticsArgs struct { + // (required) + ExtensionStatisticsUpdate *ExtensionStatisticUpdate + // (required) + PublisherName *string + // (required) + ExtensionName *string +} + +// [Preview API] +func (client *ClientImpl) UpdatePayloadInDraftForEditExtension(ctx context.Context, args UpdatePayloadInDraftForEditExtensionArgs) (*ExtensionDraft, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.DraftId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DraftId"} + } + routeValues["draftId"] = (*args.DraftId).String() + + additionalHeaders := make(map[string]string) + if args.FileName != nil { + additionalHeaders["X-Market-UploadFileName"] = *args.FileName + } + locationId, _ := uuid.Parse("02b33873-4e61-496e-83a2-59d1df46b7d8") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, nil, args.UploadStream, "application/octet-stream", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseValue ExtensionDraft + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdatePayloadInDraftForEditExtension function +type UpdatePayloadInDraftForEditExtensionArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (required) + PublisherName *string + // (required) + ExtensionName *string + // (required) + DraftId *uuid.UUID + // (optional) Header to pass the filename of the uploaded data + FileName *string +} + +// [Preview API] +func (client *ClientImpl) UpdatePayloadInDraftForNewExtension(ctx context.Context, args UpdatePayloadInDraftForNewExtensionArgs) (*ExtensionDraft, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.DraftId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DraftId"} + } + routeValues["draftId"] = (*args.DraftId).String() + + additionalHeaders := make(map[string]string) + if args.FileName != nil { + additionalHeaders["X-Market-UploadFileName"] = *args.FileName + } + locationId, _ := uuid.Parse("b3ab127d-ebb9-4d22-b611-4e09593c8d79") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, nil, args.UploadStream, "application/octet-stream", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseValue ExtensionDraft + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdatePayloadInDraftForNewExtension function +type UpdatePayloadInDraftForNewExtensionArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (required) + PublisherName *string + // (required) + DraftId *uuid.UUID + // (optional) Header to pass the filename of the uploaded data + FileName *string +} + +// [Preview API] +func (client *ClientImpl) UpdatePublisher(ctx context.Context, args UpdatePublisherArgs) (*Publisher, error) { + if args.Publisher == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Publisher"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + + body, marshalErr := json.Marshal(*args.Publisher) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4ddec66a-e4f6-4f5d-999e-9e77710d7ff4") + resp, 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 nil, err + } + + var responseValue Publisher + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdatePublisher function +type UpdatePublisherArgs struct { + // (required) + Publisher *Publisher + // (required) + PublisherName *string +} + +// [Preview API] Update publisher asset like logo. It accepts asset file as an octet stream and file name is passed in header values. +func (client *ClientImpl) UpdatePublisherAsset(ctx context.Context, args UpdatePublisherAssetArgs) (*map[string]string, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + + queryParams := url.Values{} + if args.AssetType != nil { + queryParams.Add("assetType", *args.AssetType) + } + additionalHeaders := make(map[string]string) + if args.FileName != nil { + additionalHeaders["X-Market-UploadFileName"] = *args.FileName + } + locationId, _ := uuid.Parse("21143299-34f9-4c62-8ca8-53da691192f9") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, queryParams, args.UploadStream, "application/octet-stream", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseValue map[string]string + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdatePublisherAsset function +type UpdatePublisherAssetArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (required) Internal name of the publisher + PublisherName *string + // (optional) Type of asset. Default value is 'logo'. + AssetType *string + // (optional) Header to pass the filename of the uploaded data + FileName *string +} + +// [Preview API] Endpoint to add/modify publisher membership. Currently Supports only addition/modification of 1 user at a time Works only for adding members of same tenant. +func (client *ClientImpl) UpdatePublisherMembers(ctx context.Context, args UpdatePublisherMembersArgs) (*[]PublisherRoleAssignment, error) { + if args.RoleAssignments == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RoleAssignments"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + + queryParams := url.Values{} + if args.LimitToCallerIdentityDomain != nil { + queryParams.Add("limitToCallerIdentityDomain", strconv.FormatBool(*args.LimitToCallerIdentityDomain)) + } + body, marshalErr := json.Marshal(*args.RoleAssignments) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4ddec66a-e4f6-4f5d-999e-9e77710d7ff4") + 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 []PublisherRoleAssignment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdatePublisherMembers function +type UpdatePublisherMembersArgs struct { + // (required) List of user identifiers(email address) and role to be added. Currently only one entry is supported. + RoleAssignments *[]PublisherUserRoleAssignmentRef + // (required) The name/id of publisher to which users have to be added + PublisherName *string + // (optional) Should cross tenant addtions be allowed or not. + LimitToCallerIdentityDomain *bool +} + +// [Preview API] Updates an existing question for an extension. +func (client *ClientImpl) UpdateQuestion(ctx context.Context, args UpdateQuestionArgs) (*Question, error) { + if args.Question == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Question"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.QuestionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.QuestionId"} + } + routeValues["questionId"] = strconv.FormatUint(*args.QuestionId, 10) + + body, marshalErr := json.Marshal(*args.Question) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("6d1d9741-eca8-4701-a3a5-235afc82dfa4") + 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 Question + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateQuestion function +type UpdateQuestionArgs struct { + // (required) Updated question to be set for the extension. + Question *Question + // (required) Name of the publisher who published the extension. + PublisherName *string + // (required) Name of the extension. + ExtensionName *string + // (required) Identifier of the question to be updated for the extension. + QuestionId *uint64 +} + +// [Preview API] Updates an existing response for a given question for an extension. +func (client *ClientImpl) UpdateResponse(ctx context.Context, args UpdateResponseArgs) (*Response, error) { + if args.Response == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Response"} + } + routeValues := make(map[string]string) + if args.PublisherName == nil || *args.PublisherName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherName"} + } + routeValues["publisherName"] = *args.PublisherName + if args.ExtensionName == nil || *args.ExtensionName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtensionName"} + } + routeValues["extensionName"] = *args.ExtensionName + if args.QuestionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.QuestionId"} + } + routeValues["questionId"] = strconv.FormatUint(*args.QuestionId, 10) + if args.ResponseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ResponseId"} + } + routeValues["responseId"] = strconv.FormatUint(*args.ResponseId, 10) + + body, marshalErr := json.Marshal(*args.Response) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("7f8ae5e0-46b0-438f-b2e8-13e8513517bd") + 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 Response + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateResponse function +type UpdateResponseArgs struct { + // (required) Updated response to be set for the extension. + Response *Response + // (required) Name of the publisher who published the extension. + PublisherName *string + // (required) Name of the extension. + ExtensionName *string + // (required) Identifier of the question for which response is to be updated for the extension. + QuestionId *uint64 + // (required) Identifier of the response which has to be updated. + ResponseId *uint64 +} + +// [Preview API] Updates or Flags a review +func (client *ClientImpl) UpdateReview(ctx context.Context, args UpdateReviewArgs) (*ReviewPatch, error) { + if args.ReviewPatch == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReviewPatch"} + } + routeValues := make(map[string]string) + if args.PubName == nil || *args.PubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PubName"} + } + routeValues["pubName"] = *args.PubName + if args.ExtName == nil || *args.ExtName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ExtName"} + } + routeValues["extName"] = *args.ExtName + if args.ReviewId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReviewId"} + } + routeValues["reviewId"] = strconv.FormatUint(*args.ReviewId, 10) + + body, marshalErr := json.Marshal(*args.ReviewPatch) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e6e85b9d-aa70-40e6-aa28-d0fbf40b91a3") + 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 ReviewPatch + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateReview function +type UpdateReviewArgs struct { + // (required) ReviewPatch object which contains the changes to be applied to the review + ReviewPatch *ReviewPatch + // (required) Name of the publisher who published the extension + PubName *string + // (required) Name of the extension + ExtName *string + // (required) Id of the review which needs to be updated + ReviewId *uint64 +} diff --git a/azuredevops/gallery/models.go b/azuredevops/gallery/models.go new file mode 100644 index 00000000..5b1001ad --- /dev/null +++ b/azuredevops/gallery/models.go @@ -0,0 +1,1531 @@ +// -------------------------------------------------------------------------------------------- +// 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 gallery + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +// How the acquisition is assigned +type AcquisitionAssignmentType string + +type acquisitionAssignmentTypeValuesType struct { + None AcquisitionAssignmentType + Me AcquisitionAssignmentType + All AcquisitionAssignmentType +} + +var AcquisitionAssignmentTypeValues = acquisitionAssignmentTypeValuesType{ + None: "none", + // Just assign for me + Me: "me", + // Assign for all users in the account + All: "all", +} + +type AcquisitionOperation struct { + // State of the the AcquisitionOperation for the current user + OperationState *AcquisitionOperationState `json:"operationState,omitempty"` + // AcquisitionOperationType: install, request, buy, etc... + OperationType *AcquisitionOperationType `json:"operationType,omitempty"` + // Optional reason to justify current state. Typically used with Disallow state. + Reason *string `json:"reason,omitempty"` +} + +type AcquisitionOperationState string + +type acquisitionOperationStateValuesType struct { + Disallow AcquisitionOperationState + Allow AcquisitionOperationState + Completed AcquisitionOperationState +} + +var AcquisitionOperationStateValues = acquisitionOperationStateValuesType{ + // Not allowed to use this AcquisitionOperation + Disallow: "disallow", + // Allowed to use this AcquisitionOperation + Allow: "allow", + // Operation has already been completed and is no longer available + Completed: "completed", +} + +// Set of different types of operations that can be requested. +type AcquisitionOperationType string + +type acquisitionOperationTypeValuesType struct { + Get AcquisitionOperationType + Install AcquisitionOperationType + Buy AcquisitionOperationType + Try AcquisitionOperationType + Request AcquisitionOperationType + None AcquisitionOperationType + PurchaseRequest AcquisitionOperationType +} + +var AcquisitionOperationTypeValues = acquisitionOperationTypeValuesType{ + // Not yet used + Get: "get", + // Install this extension into the host provided + Install: "install", + // Buy licenses for this extension and install into the host provided + Buy: "buy", + // Try this extension + Try: "try", + // Request this extension for installation + Request: "request", + // No action found + None: "none", + // Request admins for purchasing extension + PurchaseRequest: "purchaseRequest", +} + +// Market item acquisition options (install, buy, etc) for an installation target. +type AcquisitionOptions struct { + // Default Operation for the ItemId in this target + DefaultOperation *AcquisitionOperation `json:"defaultOperation,omitempty"` + // The item id that this options refer to + ItemId *string `json:"itemId,omitempty"` + // Operations allowed for the ItemId in this target + Operations *[]AcquisitionOperation `json:"operations,omitempty"` + // The target that this options refer to + Target *string `json:"target,omitempty"` +} + +type Answers struct { + // Gets or sets the vs marketplace extension name + VsMarketplaceExtensionName *string `json:"vsMarketplaceExtensionName,omitempty"` + // Gets or sets the vs marketplace publisher name + VsMarketplacePublisherName *string `json:"vsMarketplacePublisherName,omitempty"` +} + +type AssetDetails struct { + // Gets or sets the Answers, which contains vs marketplace extension name and publisher name + Answers *Answers `json:"answers,omitempty"` + // Gets or sets the VS publisher Id + PublisherNaturalIdentifier *string `json:"publisherNaturalIdentifier,omitempty"` +} + +type AzurePublisher struct { + AzurePublisherId *string `json:"azurePublisherId,omitempty"` + PublisherName *string `json:"publisherName,omitempty"` +} + +type AzureRestApiRequestModel struct { + // Gets or sets the Asset details + AssetDetails *AssetDetails `json:"assetDetails,omitempty"` + // Gets or sets the asset id + AssetId *string `json:"assetId,omitempty"` + // Gets or sets the asset version + AssetVersion *uint64 `json:"assetVersion,omitempty"` + // Gets or sets the customer support email + CustomerSupportEmail *string `json:"customerSupportEmail,omitempty"` + // Gets or sets the integration contact email + IntegrationContactEmail *string `json:"integrationContactEmail,omitempty"` + // Gets or sets the asset version + Operation *string `json:"operation,omitempty"` + // Gets or sets the plan identifier if any. + PlanId *string `json:"planId,omitempty"` + // Gets or sets the publisher id + PublisherId *string `json:"publisherId,omitempty"` + // Gets or sets the resource type + Type *string `json:"type,omitempty"` +} + +type AzureRestApiResponseModel struct { + // Gets or sets the Asset details + AssetDetails *AssetDetails `json:"assetDetails,omitempty"` + // Gets or sets the asset id + AssetId *string `json:"assetId,omitempty"` + // Gets or sets the asset version + AssetVersion *uint64 `json:"assetVersion,omitempty"` + // Gets or sets the customer support email + CustomerSupportEmail *string `json:"customerSupportEmail,omitempty"` + // Gets or sets the integration contact email + IntegrationContactEmail *string `json:"integrationContactEmail,omitempty"` + // Gets or sets the asset version + Operation *string `json:"operation,omitempty"` + // Gets or sets the plan identifier if any. + PlanId *string `json:"planId,omitempty"` + // Gets or sets the publisher id + PublisherId *string `json:"publisherId,omitempty"` + // Gets or sets the resource type + Type *string `json:"type,omitempty"` + // Gets or sets the Asset operation status + OperationStatus *RestApiResponseStatusModel `json:"operationStatus,omitempty"` +} + +// This is the set of categories in response to the get category query +type CategoriesResult struct { + Categories *[]ExtensionCategory `json:"categories,omitempty"` +} + +// Definition of one title of a category +type CategoryLanguageTitle struct { + // The language for which the title is applicable + Lang *string `json:"lang,omitempty"` + // The language culture id of the lang parameter + Lcid *int `json:"lcid,omitempty"` + // Actual title to be shown on the UI + Title *string `json:"title,omitempty"` +} + +// The structure of a Concern Rather than defining a separate data structure having same fields as QnAItem, we are inheriting from the QnAItem. +type Concern struct { + // Time when the review was first created + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Unique identifier of a QnA item + Id *uint64 `json:"id,omitempty"` + // Get status of item + Status *QnAItemStatus `json:"status,omitempty"` + // Text description of the QnA item + Text *string `json:"text,omitempty"` + // Time when the review was edited/updated + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` + // User details for the item. + User *UserIdentityRef `json:"user,omitempty"` + // Category of the concern + Category *ConcernCategory `json:"category,omitempty"` +} + +type ConcernCategory string + +type concernCategoryValuesType struct { + General ConcernCategory + Abusive ConcernCategory + Spam ConcernCategory +} + +var ConcernCategoryValues = concernCategoryValuesType{ + General: "general", + Abusive: "abusive", + Spam: "spam", +} + +// Stores Last Contact Date +type CustomerLastContact struct { + // account for which customer was last contacted + Account *string `json:"account,omitempty"` + // Date on which the customer was last contacted + LastContactDate *azuredevops.Time `json:"lastContactDate,omitempty"` +} + +type DraftPatchOperation string + +type draftPatchOperationValuesType struct { + Publish DraftPatchOperation + Cancel DraftPatchOperation +} + +var DraftPatchOperationValues = draftPatchOperationValuesType{ + Publish: "publish", + Cancel: "cancel", +} + +type DraftStateType string + +type draftStateTypeValuesType struct { + Unpublished DraftStateType + Published DraftStateType + Cancelled DraftStateType + Error DraftStateType +} + +var DraftStateTypeValues = draftStateTypeValuesType{ + Unpublished: "unpublished", + Published: "published", + Cancelled: "cancelled", + Error: "error", +} + +type EventCounts struct { + // Average rating on the day for extension + AverageRating *float32 `json:"averageRating,omitempty"` + // Number of times the extension was bought in hosted scenario (applies only to VSTS extensions) + BuyCount *int `json:"buyCount,omitempty"` + // Number of times the extension was bought in connected scenario (applies only to VSTS extensions) + ConnectedBuyCount *int `json:"connectedBuyCount,omitempty"` + // Number of times the extension was installed in connected scenario (applies only to VSTS extensions) + ConnectedInstallCount *int `json:"connectedInstallCount,omitempty"` + // Number of times the extension was installed + InstallCount *uint64 `json:"installCount,omitempty"` + // Number of times the extension was installed as a trial (applies only to VSTS extensions) + TryCount *int `json:"tryCount,omitempty"` + // Number of times the extension was uninstalled (applies only to VSTS extensions) + UninstallCount *int `json:"uninstallCount,omitempty"` + // Number of times the extension was downloaded (applies to VSTS extensions and VSCode marketplace click installs) + WebDownloadCount *uint64 `json:"webDownloadCount,omitempty"` + // Number of detail page views + WebPageViews *uint64 `json:"webPageViews,omitempty"` +} + +// Contract for handling the extension acquisition process +type ExtensionAcquisitionRequest struct { + // How the item is being assigned + AssignmentType *AcquisitionAssignmentType `json:"assignmentType,omitempty"` + // The id of the subscription used for purchase + BillingId *string `json:"billingId,omitempty"` + // The marketplace id (publisherName.extensionName) for the item + ItemId *string `json:"itemId,omitempty"` + // The type of operation, such as install, request, purchase + OperationType *AcquisitionOperationType `json:"operationType,omitempty"` + // Additional properties which can be added to the request. + Properties interface{} `json:"properties,omitempty"` + // How many licenses should be purchased + Quantity *int `json:"quantity,omitempty"` + // A list of target guids where the item should be acquired (installed, requested, etc.), such as account id + Targets *[]string `json:"targets,omitempty"` +} + +type ExtensionBadge struct { + Description *string `json:"description,omitempty"` + ImgUri *string `json:"imgUri,omitempty"` + Link *string `json:"link,omitempty"` +} + +type ExtensionCategory struct { + // The name of the products with which this category is associated to. + AssociatedProducts *[]string `json:"associatedProducts,omitempty"` + CategoryId *int `json:"categoryId,omitempty"` + // This is the internal name for a category + CategoryName *string `json:"categoryName,omitempty"` + // This parameter is obsolete. Refer to LanguageTitles for language specific titles + Language *string `json:"language,omitempty"` + // The list of all the titles of this category in various languages + LanguageTitles *[]CategoryLanguageTitle `json:"languageTitles,omitempty"` + // This is the internal name of the parent if this is associated with a parent + ParentCategoryName *string `json:"parentCategoryName,omitempty"` +} + +type ExtensionDailyStat struct { + // Stores the event counts + Counts *EventCounts `json:"counts,omitempty"` + // Generic key/value pair to store extended statistics. Used for sending paid extension stats like Upgrade, Downgrade, Cancel trend etc. + ExtendedStats *map[string]interface{} `json:"extendedStats,omitempty"` + // Timestamp of this data point + StatisticDate *azuredevops.Time `json:"statisticDate,omitempty"` + // Version of the extension + Version *string `json:"version,omitempty"` +} + +type ExtensionDailyStats struct { + // List of extension statistics data points + DailyStats *[]ExtensionDailyStat `json:"dailyStats,omitempty"` + // Id of the extension, this will never be sent back to the client. For internal use only. + ExtensionId *uuid.UUID `json:"extensionId,omitempty"` + // Name of the extension + ExtensionName *string `json:"extensionName,omitempty"` + // Name of the publisher + PublisherName *string `json:"publisherName,omitempty"` + // Count of stats + StatCount *int `json:"statCount,omitempty"` +} + +type ExtensionDeploymentTechnology string + +type extensionDeploymentTechnologyValuesType struct { + Exe ExtensionDeploymentTechnology + Msi ExtensionDeploymentTechnology + Vsix ExtensionDeploymentTechnology + ReferralLink ExtensionDeploymentTechnology +} + +var ExtensionDeploymentTechnologyValues = extensionDeploymentTechnologyValuesType{ + Exe: "exe", + Msi: "msi", + Vsix: "vsix", + ReferralLink: "referralLink", +} + +type ExtensionDraft struct { + Assets *[]ExtensionDraftAsset `json:"assets,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + DraftState *DraftStateType `json:"draftState,omitempty"` + ExtensionName *string `json:"extensionName,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + Payload *ExtensionPayload `json:"payload,omitempty"` + Product *string `json:"product,omitempty"` + PublisherName *string `json:"publisherName,omitempty"` + ValidationErrors *[]azuredevops.KeyValuePair `json:"validationErrors,omitempty"` + ValidationWarnings *[]azuredevops.KeyValuePair `json:"validationWarnings,omitempty"` +} + +type ExtensionDraftAsset struct { + AssetType *string `json:"assetType,omitempty"` + Language *string `json:"language,omitempty"` + Source *string `json:"source,omitempty"` +} + +type ExtensionDraftPatch struct { + ExtensionData *UnpackagedExtensionData `json:"extensionData,omitempty"` + Operation *DraftPatchOperation `json:"operation,omitempty"` +} + +// Stores details of each event +type ExtensionEvent struct { + // Id which identifies each data point uniquely + Id *uint64 `json:"id,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // Timestamp of when the event occurred + StatisticDate *azuredevops.Time `json:"statisticDate,omitempty"` + // Version of the extension + Version *string `json:"version,omitempty"` +} + +// Container object for all extension events. Stores all install and uninstall events related to an extension. The events container is generic so can store data of any type of event. New event types can be added without altering the contract. +type ExtensionEvents struct { + // Generic container for events data. The dictionary key denotes the type of event and the list contains properties related to that event + Events *map[string][]ExtensionEvent `json:"events,omitempty"` + // Id of the extension, this will never be sent back to the client. This field will mainly be used when EMS calls into Gallery REST API to update install/uninstall events for various extensions in one go. + ExtensionId *uuid.UUID `json:"extensionId,omitempty"` + // Name of the extension + ExtensionName *string `json:"extensionName,omitempty"` + // Name of the publisher + PublisherName *string `json:"publisherName,omitempty"` +} + +type ExtensionFile struct { + AssetType *string `json:"assetType,omitempty"` + Language *string `json:"language,omitempty"` + Source *string `json:"source,omitempty"` +} + +// The FilterResult is the set of extensions that matched a particular query filter. +type ExtensionFilterResult struct { + // This is the set of applications that matched the query filter supplied. + Extensions *[]PublishedExtension `json:"extensions,omitempty"` + // The PagingToken is returned from a request when more records exist that match the result than were requested or could be returned. A follow-up query with this paging token can be used to retrieve more results. + PagingToken *string `json:"pagingToken,omitempty"` + // This is the additional optional metadata for the given result. E.g. Total count of results which is useful in case of paged results + ResultMetadata *[]ExtensionFilterResultMetadata `json:"resultMetadata,omitempty"` +} + +// ExtensionFilterResultMetadata is one set of metadata for the result e.g. Total count. There can be multiple metadata items for one metadata. +type ExtensionFilterResultMetadata struct { + // The metadata items for the category + MetadataItems *[]MetadataItem `json:"metadataItems,omitempty"` + // Defines the category of metadata items + MetadataType *string `json:"metadataType,omitempty"` +} + +// Represents the component pieces of an extensions fully qualified name, along with the fully qualified name. +type ExtensionIdentifier struct { + // The ExtensionName component part of the fully qualified ExtensionIdentifier + ExtensionName *string `json:"extensionName,omitempty"` + // The PublisherName component part of the fully qualified ExtensionIdentifier + PublisherName *string `json:"publisherName,omitempty"` +} + +// Type of event +type ExtensionLifecycleEventType string + +type extensionLifecycleEventTypeValuesType struct { + Uninstall ExtensionLifecycleEventType + Install ExtensionLifecycleEventType + Review ExtensionLifecycleEventType + Acquisition ExtensionLifecycleEventType + Sales ExtensionLifecycleEventType + Other ExtensionLifecycleEventType +} + +var ExtensionLifecycleEventTypeValues = extensionLifecycleEventTypeValuesType{ + Uninstall: "uninstall", + Install: "install", + Review: "review", + Acquisition: "acquisition", + Sales: "sales", + Other: "other", +} + +// Package that will be used to create or update a published extension +type ExtensionPackage struct { + // Base 64 encoded extension package + ExtensionManifest *string `json:"extensionManifest,omitempty"` +} + +type ExtensionPayload struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + FileName *string `json:"fileName,omitempty"` + InstallationTargets *[]InstallationTarget `json:"installationTargets,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + IsSignedByMicrosoft *bool `json:"isSignedByMicrosoft,omitempty"` + IsValid *bool `json:"isValid,omitempty"` + Metadata *[]azuredevops.KeyValuePair `json:"metadata,omitempty"` + Type *ExtensionDeploymentTechnology `json:"type,omitempty"` +} + +// Policy with a set of permissions on extension operations +type ExtensionPolicy struct { + // Permissions on 'Install' operation + Install *ExtensionPolicyFlags `json:"install,omitempty"` + // Permission on 'Request' operation + Request *ExtensionPolicyFlags `json:"request,omitempty"` +} + +// [Flags] Set of flags that can be associated with a given permission over an extension +type ExtensionPolicyFlags string + +type extensionPolicyFlagsValuesType struct { + None ExtensionPolicyFlags + Private ExtensionPolicyFlags + Public ExtensionPolicyFlags + Preview ExtensionPolicyFlags + Released ExtensionPolicyFlags + FirstParty ExtensionPolicyFlags + All ExtensionPolicyFlags +} + +var ExtensionPolicyFlagsValues = extensionPolicyFlagsValuesType{ + // No permission + None: "none", + // Permission on private extensions + Private: "private", + // Permission on public extensions + Public: "public", + // Permission in extensions that are in preview + Preview: "preview", + // Permission in released extensions + Released: "released", + // Permission in 1st party extensions + FirstParty: "firstParty", + // Mask that defines all permissions + All: "all", +} + +// An ExtensionQuery is used to search the gallery for a set of extensions that match one of many filter values. +type ExtensionQuery struct { + // When retrieving extensions with a query; frequently the caller only needs a small subset of the assets. The caller may specify a list of asset types that should be returned if the extension contains it. All other assets will not be returned. + AssetTypes *[]string `json:"assetTypes,omitempty"` + // Each filter is a unique query and will have matching set of extensions returned from the request. Each result will have the same index in the resulting array that the filter had in the incoming query. + Filters *[]QueryFilter `json:"filters,omitempty"` + // The Flags are used to determine which set of information the caller would like returned for the matched extensions. + Flags *ExtensionQueryFlags `json:"flags,omitempty"` +} + +// Type of extension filters that are supported in the queries. +type ExtensionQueryFilterType string + +type extensionQueryFilterTypeValuesType struct { + Tag ExtensionQueryFilterType + DisplayName ExtensionQueryFilterType + Private ExtensionQueryFilterType + Id ExtensionQueryFilterType + Category ExtensionQueryFilterType + ContributionType ExtensionQueryFilterType + Name ExtensionQueryFilterType + InstallationTarget ExtensionQueryFilterType + Featured ExtensionQueryFilterType + SearchText ExtensionQueryFilterType + FeaturedInCategory ExtensionQueryFilterType + ExcludeWithFlags ExtensionQueryFilterType + IncludeWithFlags ExtensionQueryFilterType + Lcid ExtensionQueryFilterType + InstallationTargetVersion ExtensionQueryFilterType + InstallationTargetVersionRange ExtensionQueryFilterType + VsixMetadata ExtensionQueryFilterType + PublisherName ExtensionQueryFilterType + PublisherDisplayName ExtensionQueryFilterType + IncludeWithPublisherFlags ExtensionQueryFilterType + OrganizationSharedWith ExtensionQueryFilterType +} + +var ExtensionQueryFilterTypeValues = extensionQueryFilterTypeValuesType{ + // The values are used as tags. All tags are treated as "OR" conditions with each other. There may be some value put on the number of matched tags from the query. + Tag: "tag", + // The Values are an ExtensionName or fragment that is used to match other extension names. + DisplayName: "displayName", + // The Filter is one or more tokens that define what scope to return private extensions for. + Private: "private", + // Retrieve a set of extensions based on their id's. The values should be the extension id's encoded as strings. + Id: "id", + // The category is unlike other filters. It is AND'd with the other filters instead of being a separate query. + Category: "category", + // Certain contribution types may be indexed to allow for query by type. User defined types can't be indexed at the moment. + ContributionType: "contributionType", + // Retrieve an set extension based on the name based identifier. This differs from the internal id (which is being deprecated). + Name: "name", + // The InstallationTarget for an extension defines the target consumer for the extension. This may be something like VS, VSOnline, or VSCode + InstallationTarget: "installationTarget", + // Query for featured extensions, no value is allowed when using the query type. + Featured: "featured", + // The SearchText provided by the user to search for extensions + SearchText: "searchText", + // Query for extensions that are featured in their own category, The filterValue for this is name of category of extensions. + FeaturedInCategory: "featuredInCategory", + // When retrieving extensions from a query, exclude the extensions which are having the given flags. The value specified for this filter should be a string representing the integer values of the flags to be excluded. In case of multiple flags to be specified, a logical OR of the interger values should be given as value for this filter This should be at most one filter of this type. This only acts as a restrictive filter after. In case of having a particular flag in both IncludeWithFlags and ExcludeWithFlags, excludeFlags will remove the included extensions giving empty result for that flag. + ExcludeWithFlags: "excludeWithFlags", + // When retrieving extensions from a query, include the extensions which are having the given flags. The value specified for this filter should be a string representing the integer values of the flags to be included. In case of multiple flags to be specified, a logical OR of the integer values should be given as value for this filter This should be at most one filter of this type. This only acts as a restrictive filter after. In case of having a particular flag in both IncludeWithFlags and ExcludeWithFlags, excludeFlags will remove the included extensions giving empty result for that flag. In case of multiple flags given in IncludeWithFlags in ORed fashion, extensions having any of the given flags will be included. + IncludeWithFlags: "includeWithFlags", + // Filter the extensions based on the LCID values applicable. Any extensions which are not having any LCID values will also be filtered. This is currently only supported for VS extensions. + Lcid: "lcid", + // Filter to provide the version of the installation target. This filter will be used along with InstallationTarget filter. The value should be a valid version string. Currently supported only if search text is provided. + InstallationTargetVersion: "installationTargetVersion", + // Filter type for specifying a range of installation target version. The filter will be used along with InstallationTarget filter. The value should be a pair of well formed version values separated by hyphen(-). Currently supported only if search text is provided. + InstallationTargetVersionRange: "installationTargetVersionRange", + // Filter type for specifying metadata key and value to be used for filtering. + VsixMetadata: "vsixMetadata", + // Filter to get extensions published by a publisher having supplied internal name + PublisherName: "publisherName", + // Filter to get extensions published by all publishers having supplied display name + PublisherDisplayName: "publisherDisplayName", + // When retrieving extensions from a query, include the extensions which have a publisher having the given flags. The value specified for this filter should be a string representing the integer values of the flags to be included. In case of multiple flags to be specified, a logical OR of the integer values should be given as value for this filter There should be at most one filter of this type. This only acts as a restrictive filter after. In case of multiple flags given in IncludeWithFlags in ORed fashion, extensions having any of the given flags will be included. + IncludeWithPublisherFlags: "includeWithPublisherFlags", + // Filter to get extensions shared with particular organization + OrganizationSharedWith: "organizationSharedWith", +} + +// [Flags] Set of flags used to determine which set of information is retrieved when reading published extensions +type ExtensionQueryFlags string + +type extensionQueryFlagsValuesType struct { + None ExtensionQueryFlags + IncludeVersions ExtensionQueryFlags + IncludeFiles ExtensionQueryFlags + IncludeCategoryAndTags ExtensionQueryFlags + IncludeSharedAccounts ExtensionQueryFlags + IncludeVersionProperties ExtensionQueryFlags + ExcludeNonValidated ExtensionQueryFlags + IncludeInstallationTargets ExtensionQueryFlags + IncludeAssetUri ExtensionQueryFlags + IncludeStatistics ExtensionQueryFlags + IncludeLatestVersionOnly ExtensionQueryFlags + UseFallbackAssetUri ExtensionQueryFlags + IncludeMetadata ExtensionQueryFlags + IncludeMinimalPayloadForVsIde ExtensionQueryFlags + IncludeLcids ExtensionQueryFlags + IncludeSharedOrganizations ExtensionQueryFlags + AllAttributes ExtensionQueryFlags +} + +var ExtensionQueryFlagsValues = extensionQueryFlagsValuesType{ + // None is used to retrieve only the basic extension details. + None: "none", + // IncludeVersions will return version information for extensions returned + IncludeVersions: "includeVersions", + // IncludeFiles will return information about which files were found within the extension that were stored independent of the manifest. When asking for files, versions will be included as well since files are returned as a property of the versions. These files can be retrieved using the path to the file without requiring the entire manifest be downloaded. + IncludeFiles: "includeFiles", + // Include the Categories and Tags that were added to the extension definition. + IncludeCategoryAndTags: "includeCategoryAndTags", + // Include the details about which accounts the extension has been shared with if the extension is a private extension. + IncludeSharedAccounts: "includeSharedAccounts", + // Include properties associated with versions of the extension + IncludeVersionProperties: "includeVersionProperties", + // Excluding non-validated extensions will remove any extension versions that either are in the process of being validated or have failed validation. + ExcludeNonValidated: "excludeNonValidated", + // Include the set of installation targets the extension has requested. + IncludeInstallationTargets: "includeInstallationTargets", + // Include the base uri for assets of this extension + IncludeAssetUri: "includeAssetUri", + // Include the statistics associated with this extension + IncludeStatistics: "includeStatistics", + // When retrieving versions from a query, only include the latest version of the extensions that matched. This is useful when the caller doesn't need all the published versions. It will save a significant size in the returned payload. + IncludeLatestVersionOnly: "includeLatestVersionOnly", + // This flag switches the asset uri to use GetAssetByName instead of CDN When this is used, values of base asset uri and base asset uri fallback are switched When this is used, source of asset files are pointed to Gallery service always even if CDN is available + UseFallbackAssetUri: "useFallbackAssetUri", + // This flag is used to get all the metadata values associated with the extension. This is not applicable to VSTS or VSCode extensions and usage is only internal. + IncludeMetadata: "includeMetadata", + // This flag is used to indicate to return very small data for extension required by VS IDE. This flag is only compatible when querying is done by VS IDE + IncludeMinimalPayloadForVsIde: "includeMinimalPayloadForVsIde", + // This flag is used to get Lcid values associated with the extension. This is not applicable to VSTS or VSCode extensions and usage is only internal + IncludeLcids: "includeLcids", + // Include the details about which organizations the extension has been shared with if the extension is a private extension. + IncludeSharedOrganizations: "includeSharedOrganizations", + // AllAttributes is designed to be a mask that defines all sub-elements of the extension should be returned. NOTE: This is not actually All flags. This is now locked to the set defined since changing this enum would be a breaking change and would change the behavior of anyone using it. Try not to use this value when making calls to the service, instead be explicit about the options required. + AllAttributes: "allAttributes", +} + +// This is the set of extensions that matched a supplied query through the filters given. +type ExtensionQueryResult struct { + // For each filter supplied in the query, a filter result will be returned in the query result. + Results *[]ExtensionFilterResult `json:"results,omitempty"` +} + +type ExtensionShare struct { + Id *string `json:"id,omitempty"` + IsOrg *bool `json:"isOrg,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +type ExtensionStatistic struct { + StatisticName *string `json:"statisticName,omitempty"` + Value *float64 `json:"value,omitempty"` +} + +type ExtensionStatisticOperation string + +type extensionStatisticOperationValuesType struct { + None ExtensionStatisticOperation + Set ExtensionStatisticOperation + Increment ExtensionStatisticOperation + Decrement ExtensionStatisticOperation + Delete ExtensionStatisticOperation +} + +var ExtensionStatisticOperationValues = extensionStatisticOperationValuesType{ + None: "none", + Set: "set", + Increment: "increment", + Decrement: "decrement", + Delete: "delete", +} + +type ExtensionStatisticUpdate struct { + ExtensionName *string `json:"extensionName,omitempty"` + Operation *ExtensionStatisticOperation `json:"operation,omitempty"` + PublisherName *string `json:"publisherName,omitempty"` + Statistic *ExtensionStatistic `json:"statistic,omitempty"` +} + +// Stats aggregation type +type ExtensionStatsAggregateType string + +type extensionStatsAggregateTypeValuesType struct { + Daily ExtensionStatsAggregateType +} + +var ExtensionStatsAggregateTypeValues = extensionStatsAggregateTypeValuesType{ + Daily: "daily", +} + +type ExtensionVersion struct { + AssetUri *string `json:"assetUri,omitempty"` + Badges *[]ExtensionBadge `json:"badges,omitempty"` + FallbackAssetUri *string `json:"fallbackAssetUri,omitempty"` + Files *[]ExtensionFile `json:"files,omitempty"` + Flags *ExtensionVersionFlags `json:"flags,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + Properties *[]azuredevops.KeyValuePair `json:"properties,omitempty"` + ValidationResultMessage *string `json:"validationResultMessage,omitempty"` + Version *string `json:"version,omitempty"` + VersionDescription *string `json:"versionDescription,omitempty"` +} + +// [Flags] Set of flags that can be associated with a given extension version. These flags apply to a specific version of the extension. +type ExtensionVersionFlags string + +type extensionVersionFlagsValuesType struct { + None ExtensionVersionFlags + Validated ExtensionVersionFlags +} + +var ExtensionVersionFlagsValues = extensionVersionFlagsValuesType{ + // No flags exist for this version. + None: "none", + // The Validated flag for a version means the extension version has passed validation and can be used.. + Validated: "validated", +} + +// One condition in a QueryFilter. +type FilterCriteria struct { + FilterType *int `json:"filterType,omitempty"` + // The value used in the match based on the filter type. + Value *string `json:"value,omitempty"` +} + +type InstallationTarget struct { + Target *string `json:"target,omitempty"` + TargetVersion *string `json:"targetVersion,omitempty"` +} + +// MetadataItem is one value of metadata under a given category of metadata +type MetadataItem struct { + // The count of the metadata item + Count *int `json:"count,omitempty"` + // The name of the metadata item + Name *string `json:"name,omitempty"` +} + +// Information needed for sending mail notification +type NotificationsData struct { + // Notification data needed + Data *map[string]interface{} `json:"data,omitempty"` + // List of users who should get the notification + Identities *map[string]interface{} `json:"identities,omitempty"` + // Type of Mail Notification.Can be Qna , review or CustomerContact + Type *NotificationTemplateType `json:"type,omitempty"` +} + +// Type of event +type NotificationTemplateType string + +type notificationTemplateTypeValuesType struct { + ReviewNotification NotificationTemplateType + QnaNotification NotificationTemplateType + CustomerContactNotification NotificationTemplateType + PublisherMemberUpdateNotification NotificationTemplateType +} + +var NotificationTemplateTypeValues = notificationTemplateTypeValuesType{ + // Template type for Review Notification. + ReviewNotification: "reviewNotification", + // Template type for Qna Notification. + QnaNotification: "qnaNotification", + // Template type for Customer Contact Notification. + CustomerContactNotification: "customerContactNotification", + // Template type for Publisher Member Notification. + PublisherMemberUpdateNotification: "publisherMemberUpdateNotification", +} + +// PagingDirection is used to define which set direction to move the returned result set based on a previous query. +type PagingDirection string + +type pagingDirectionValuesType struct { + Backward PagingDirection + Forward PagingDirection +} + +var PagingDirectionValues = pagingDirectionValuesType{ + // Backward will return results from earlier in the resultset. + Backward: "backward", + // Forward will return results from later in the resultset. + Forward: "forward", +} + +// This is the set of categories in response to the get category query +type ProductCategoriesResult struct { + Categories *[]ProductCategory `json:"categories,omitempty"` +} + +// This is the interface object to be used by Root Categories and Category Tree APIs for Visual Studio Ide. +type ProductCategory struct { + Children *[]ProductCategory `json:"children,omitempty"` + // Indicator whether this is a leaf or there are children under this category + HasChildren *bool `json:"hasChildren,omitempty"` + // Individual Guid of the Category + Id *uuid.UUID `json:"id,omitempty"` + // Category Title in the requested language + Title *string `json:"title,omitempty"` +} + +type PublishedExtension struct { + Categories *[]string `json:"categories,omitempty"` + DeploymentType *ExtensionDeploymentTechnology `json:"deploymentType,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExtensionId *uuid.UUID `json:"extensionId,omitempty"` + ExtensionName *string `json:"extensionName,omitempty"` + Flags *PublishedExtensionFlags `json:"flags,omitempty"` + InstallationTargets *[]InstallationTarget `json:"installationTargets,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LongDescription *string `json:"longDescription,omitempty"` + // Date on which the extension was first uploaded. + PublishedDate *azuredevops.Time `json:"publishedDate,omitempty"` + Publisher *PublisherFacts `json:"publisher,omitempty"` + // Date on which the extension first went public. + ReleaseDate *azuredevops.Time `json:"releaseDate,omitempty"` + SharedWith *[]ExtensionShare `json:"sharedWith,omitempty"` + ShortDescription *string `json:"shortDescription,omitempty"` + Statistics *[]ExtensionStatistic `json:"statistics,omitempty"` + Tags *[]string `json:"tags,omitempty"` + Versions *[]ExtensionVersion `json:"versions,omitempty"` +} + +// [Flags] Set of flags that can be associated with a given extension. These flags apply to all versions of the extension and not to a specific version. +type PublishedExtensionFlags string + +type publishedExtensionFlagsValuesType struct { + None PublishedExtensionFlags + Disabled PublishedExtensionFlags + BuiltIn PublishedExtensionFlags + Validated PublishedExtensionFlags + Trusted PublishedExtensionFlags + Paid PublishedExtensionFlags + Public PublishedExtensionFlags + MultiVersion PublishedExtensionFlags + System PublishedExtensionFlags + Preview PublishedExtensionFlags + Unpublished PublishedExtensionFlags + Trial PublishedExtensionFlags + Locked PublishedExtensionFlags + Hidden PublishedExtensionFlags +} + +var PublishedExtensionFlagsValues = publishedExtensionFlagsValuesType{ + // No flags exist for this extension. + None: "none", + // The Disabled flag for an extension means the extension can't be changed and won't be used by consumers. The disabled flag is managed by the service and can't be supplied by the Extension Developers. + Disabled: "disabled", + // BuiltIn Extension are available to all Tenants. An explicit registration is not required. This attribute is reserved and can't be supplied by Extension Developers. BuiltIn extensions are by definition Public. There is no need to set the public flag for extensions marked BuiltIn. + BuiltIn: "builtIn", + // This extension has been validated by the service. The extension meets the requirements specified. This attribute is reserved and can't be supplied by the Extension Developers. Validation is a process that ensures that all contributions are well formed. They meet the requirements defined by the contribution type they are extending. Note this attribute will be updated asynchronously as the extension is validated by the developer of the contribution type. There will be restricted access to the extension while this process is performed. + Validated: "validated", + // Trusted extensions are ones that are given special capabilities. These tend to come from Microsoft and can't be published by the general public. Note: BuiltIn extensions are always trusted. + Trusted: "trusted", + // The Paid flag indicates that the commerce can be enabled for this extension. Publisher needs to setup Offer/Pricing plan in Azure. If Paid flag is set and a corresponding Offer is not available, the extension will automatically be marked as Preview. If the publisher intends to make the extension Paid in the future, it is mandatory to set the Preview flag. This is currently available only for VSTS extensions only. + Paid: "paid", + // This extension registration is public, making its visibility open to the public. This means all tenants have the ability to install this extension. Without this flag the extension will be private and will need to be shared with the tenants that can install it. + Public: "public", + // This extension has multiple versions active at one time and version discovery should be done using the defined "Version Discovery" protocol to determine the version available to a specific user or tenant. @TODO: Link to Version Discovery Protocol. + MultiVersion: "multiVersion", + // The system flag is reserved, and cant be used by publishers. + System: "system", + // The Preview flag indicates that the extension is still under preview (not yet of "release" quality). These extensions may be decorated differently in the gallery and may have different policies applied to them. + Preview: "preview", + // The Unpublished flag indicates that the extension can't be installed/downloaded. Users who have installed such an extension can continue to use the extension. + Unpublished: "unpublished", + // The Trial flag indicates that the extension is in Trial version. The flag is right now being used only with respect to Visual Studio extensions. + Trial: "trial", + // The Locked flag indicates that extension has been locked from Marketplace. Further updates/acquisitions are not allowed on the extension until this is present. This should be used along with making the extension private/unpublished. + Locked: "locked", + // This flag is set for extensions we want to hide from Marketplace home and search pages. This will be used to override the exposure of builtIn flags. + Hidden: "hidden", +} + +type Publisher struct { + DisplayName *string `json:"displayName,omitempty"` + EmailAddress *[]string `json:"emailAddress,omitempty"` + Extensions *[]PublishedExtension `json:"extensions,omitempty"` + Flags *PublisherFlags `json:"flags,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LongDescription *string `json:"longDescription,omitempty"` + PublisherId *uuid.UUID `json:"publisherId,omitempty"` + PublisherName *string `json:"publisherName,omitempty"` + ShortDescription *string `json:"shortDescription,omitempty"` + State *PublisherState `json:"state,omitempty"` + Links interface{} `json:"_links,omitempty"` +} + +// Keeping base class separate since publisher DB model class and publisher contract class share these common properties +type PublisherBase struct { + DisplayName *string `json:"displayName,omitempty"` + EmailAddress *[]string `json:"emailAddress,omitempty"` + Extensions *[]PublishedExtension `json:"extensions,omitempty"` + Flags *PublisherFlags `json:"flags,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LongDescription *string `json:"longDescription,omitempty"` + PublisherId *uuid.UUID `json:"publisherId,omitempty"` + PublisherName *string `json:"publisherName,omitempty"` + ShortDescription *string `json:"shortDescription,omitempty"` + State *PublisherState `json:"state,omitempty"` +} + +// High-level information about the publisher, like id's and names +type PublisherFacts struct { + DisplayName *string `json:"displayName,omitempty"` + Flags *PublisherFlags `json:"flags,omitempty"` + PublisherId *uuid.UUID `json:"publisherId,omitempty"` + PublisherName *string `json:"publisherName,omitempty"` +} + +// The FilterResult is the set of publishers that matched a particular query filter. +type PublisherFilterResult struct { + // This is the set of applications that matched the query filter supplied. + Publishers *[]Publisher `json:"publishers,omitempty"` +} + +// [Flags] +type PublisherFlags string + +type publisherFlagsValuesType struct { + UnChanged PublisherFlags + None PublisherFlags + Disabled PublisherFlags + Verified PublisherFlags + Certified PublisherFlags + ServiceFlags PublisherFlags +} + +var PublisherFlagsValues = publisherFlagsValuesType{ + // This should never be returned, it is used to represent a publisher who's flags haven't changed during update calls. + UnChanged: "unChanged", + // No flags exist for this publisher. + None: "none", + // The Disabled flag for a publisher means the publisher can't be changed and won't be used by consumers, this extends to extensions owned by the publisher as well. The disabled flag is managed by the service and can't be supplied by the Extension Developers. + Disabled: "disabled", + // A verified publisher is one that Microsoft has done some review of and ensured the publisher meets a set of requirements. The requirements to become a verified publisher are not listed here. They can be found in public documentation (TBD). + Verified: "verified", + // A Certified publisher is one that is Microsoft verified and in addition meets a set of requirements for its published extensions. The requirements to become a certified publisher are not listed here. They can be found in public documentation (TBD). + Certified: "certified", + // This is the set of flags that can't be supplied by the developer and is managed by the service itself. + ServiceFlags: "serviceFlags", +} + +// [Flags] +type PublisherPermissions string + +type publisherPermissionsValuesType struct { + Read PublisherPermissions + UpdateExtension PublisherPermissions + CreatePublisher PublisherPermissions + PublishExtension PublisherPermissions + Admin PublisherPermissions + TrustedPartner PublisherPermissions + PrivateRead PublisherPermissions + DeleteExtension PublisherPermissions + EditSettings PublisherPermissions + ViewPermissions PublisherPermissions + ManagePermissions PublisherPermissions + DeletePublisher PublisherPermissions +} + +var PublisherPermissionsValues = publisherPermissionsValuesType{ + // This gives the bearer the rights to read Publishers and Extensions. + Read: "read", + // This gives the bearer the rights to update, delete, and share Extensions (but not the ability to create them). + UpdateExtension: "updateExtension", + // This gives the bearer the rights to create new Publishers at the root of the namespace. + CreatePublisher: "createPublisher", + // This gives the bearer the rights to create new Extensions within a publisher. + PublishExtension: "publishExtension", + // Admin gives the bearer the rights to manage restricted attributes of Publishers and Extensions. + Admin: "admin", + // TrustedPartner gives the bearer the rights to publish a extensions with restricted capabilities. + TrustedPartner: "trustedPartner", + // PrivateRead is another form of read designed to allow higher privilege accessors the ability to read private extensions. + PrivateRead: "privateRead", + // This gives the bearer the rights to delete any extension. + DeleteExtension: "deleteExtension", + // This gives the bearer the rights edit the publisher settings. + EditSettings: "editSettings", + // This gives the bearer the rights to see all permissions on the publisher. + ViewPermissions: "viewPermissions", + // This gives the bearer the rights to assign permissions on the publisher. + ManagePermissions: "managePermissions", + // This gives the bearer the rights to delete the publisher. + DeletePublisher: "deletePublisher", +} + +// An PublisherQuery is used to search the gallery for a set of publishers that match one of many filter values. +type PublisherQuery struct { + // Each filter is a unique query and will have matching set of publishers returned from the request. Each result will have the same index in the resulting array that the filter had in the incoming query. + Filters *[]QueryFilter `json:"filters,omitempty"` + // The Flags are used to determine which set of information the caller would like returned for the matched publishers. + Flags *PublisherQueryFlags `json:"flags,omitempty"` +} + +// [Flags] Set of flags used to define the attributes requested when a publisher is returned. Some API's allow the caller to specify the level of detail needed. +type PublisherQueryFlags string + +type publisherQueryFlagsValuesType struct { + None PublisherQueryFlags + IncludeExtensions PublisherQueryFlags + IncludeEmailAddress PublisherQueryFlags +} + +var PublisherQueryFlagsValues = publisherQueryFlagsValuesType{ + // None is used to retrieve only the basic publisher details. + None: "none", + // Is used to include a list of basic extension details for all extensions published by the requested publisher. + IncludeExtensions: "includeExtensions", + // Is used to include email address of all the users who are marked as owners for the publisher + IncludeEmailAddress: "includeEmailAddress", +} + +// This is the set of publishers that matched a supplied query through the filters given. +type PublisherQueryResult struct { + // For each filter supplied in the query, a filter result will be returned in the query result. + Results *[]PublisherFilterResult `json:"results,omitempty"` +} + +// Access definition for a RoleAssignment. +type PublisherRoleAccess string + +type publisherRoleAccessValuesType struct { + Assigned PublisherRoleAccess + Inherited PublisherRoleAccess +} + +var PublisherRoleAccessValues = publisherRoleAccessValuesType{ + // Access has been explicitly set. + Assigned: "assigned", + // Access has been inherited from a higher scope. + Inherited: "inherited", +} + +type PublisherRoleAssignment struct { + // Designates the role as explicitly assigned or inherited. + Access *PublisherRoleAccess `json:"access,omitempty"` + // User friendly description of access assignment. + AccessDisplayName *string `json:"accessDisplayName,omitempty"` + // The user to whom the role is assigned. + Identity *webapi.IdentityRef `json:"identity,omitempty"` + // The role assigned to the user. + Role *PublisherSecurityRole `json:"role,omitempty"` +} + +type PublisherSecurityRole struct { + // Permissions the role is allowed. + AllowPermissions *int `json:"allowPermissions,omitempty"` + // Permissions the role is denied. + DenyPermissions *int `json:"denyPermissions,omitempty"` + // Description of user access defined by the role + Description *string `json:"description,omitempty"` + // User friendly name of the role. + DisplayName *string `json:"displayName,omitempty"` + // Globally unique identifier for the role. + Identifier *string `json:"identifier,omitempty"` + // Unique name of the role in the scope. + Name *string `json:"name,omitempty"` + // Returns the id of the ParentScope. + Scope *string `json:"scope,omitempty"` +} + +// [Flags] +type PublisherState string + +type publisherStateValuesType struct { + None PublisherState + VerificationPending PublisherState + CertificationPending PublisherState + CertificationRejected PublisherState + CertificationRevoked PublisherState +} + +var PublisherStateValues = publisherStateValuesType{ + // No state exists for this publisher. + None: "none", + // This state indicates that publisher has applied for Marketplace verification (via UI) and still not been certified. This state would be reset once the publisher is verified. + VerificationPending: "verificationPending", + // This state indicates that publisher has applied for Marketplace certification (via UI) and still not been certified. This state would be reset once the publisher is certified. + CertificationPending: "certificationPending", + // This state indicates that publisher had applied for Marketplace certification (via UI) but his/her certification got rejected. This state would be reset if and when the publisher is certified. + CertificationRejected: "certificationRejected", + // This state indicates that publisher was certified on the Marketplace, but his/her certification got revoked. This state would never be reset, even after publisher gets re-certified. It would indicate that the publisher certification was revoked at least once. + CertificationRevoked: "certificationRevoked", +} + +type PublisherUserRoleAssignmentRef struct { + // The name of the role assigned. + RoleName *string `json:"roleName,omitempty"` + // Identifier of the user given the role assignment. + UniqueName *string `json:"uniqueName,omitempty"` + // Unique id of the user given the role assignment. + UserId *uuid.UUID `json:"userId,omitempty"` +} + +// The core structure of a QnA item +type QnAItem struct { + // Time when the review was first created + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Unique identifier of a QnA item + Id *uint64 `json:"id,omitempty"` + // Get status of item + Status *QnAItemStatus `json:"status,omitempty"` + // Text description of the QnA item + Text *string `json:"text,omitempty"` + // Time when the review was edited/updated + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` + // User details for the item. + User *UserIdentityRef `json:"user,omitempty"` +} + +// [Flags] Denotes the status of the QnA Item +type QnAItemStatus string + +type qnAItemStatusValuesType struct { + None QnAItemStatus + UserEditable QnAItemStatus + PublisherCreated QnAItemStatus +} + +var QnAItemStatusValues = qnAItemStatusValuesType{ + None: "none", + // The UserEditable flag indicates whether the item is editable by the logged in user. + UserEditable: "userEditable", + // The PublisherCreated flag indicates whether the item has been created by extension publisher. + PublisherCreated: "publisherCreated", +} + +// A filter used to define a set of extensions to return during a query. +type QueryFilter struct { + // The filter values define the set of values in this query. They are applied based on the QueryFilterType. + Criteria *[]FilterCriteria `json:"criteria,omitempty"` + // The PagingDirection is applied to a paging token if one exists. If not the direction is ignored, and Forward from the start of the resultset is used. Direction should be left out of the request unless a paging token is used to help prevent future issues. + Direction *PagingDirection `json:"direction,omitempty"` + // The page number requested by the user. If not provided 1 is assumed by default. + PageNumber *int `json:"pageNumber,omitempty"` + // The page size defines the number of results the caller wants for this filter. The count can't exceed the overall query size limits. + PageSize *int `json:"pageSize,omitempty"` + // The paging token is a distinct type of filter and the other filter fields are ignored. The paging token represents the continuation of a previously executed query. The information about where in the result and what fields are being filtered are embedded in the token. + PagingToken *string `json:"pagingToken,omitempty"` + // Defines the type of sorting to be applied on the results. The page slice is cut of the sorted results only. + SortBy *int `json:"sortBy,omitempty"` + // Defines the order of sorting, 1 for Ascending, 2 for Descending, else default ordering based on the SortBy value + SortOrder *int `json:"sortOrder,omitempty"` +} + +// The structure of the question / thread +type Question struct { + // Time when the review was first created + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Unique identifier of a QnA item + Id *uint64 `json:"id,omitempty"` + // Get status of item + Status *QnAItemStatus `json:"status,omitempty"` + // Text description of the QnA item + Text *string `json:"text,omitempty"` + // Time when the review was edited/updated + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` + // User details for the item. + User *UserIdentityRef `json:"user,omitempty"` + // List of answers in for the question / thread + Responses *[]Response `json:"responses,omitempty"` +} + +type QuestionsResult struct { + // Flag indicating if there are more QnA threads to be shown (for paging) + HasMoreQuestions *bool `json:"hasMoreQuestions,omitempty"` + // List of the QnA threads + Questions *[]Question `json:"questions,omitempty"` +} + +type RatingCountPerRating struct { + // Rating value + Rating *byte `json:"rating,omitempty"` + // Count of total ratings + RatingCount *uint64 `json:"ratingCount,omitempty"` +} + +// The structure of a response +type Response struct { + // Time when the review was first created + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Unique identifier of a QnA item + Id *uint64 `json:"id,omitempty"` + // Get status of item + Status *QnAItemStatus `json:"status,omitempty"` + // Text description of the QnA item + Text *string `json:"text,omitempty"` + // Time when the review was edited/updated + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` + // User details for the item. + User *UserIdentityRef `json:"user,omitempty"` +} + +// The status of a REST Api response status. +type RestApiResponseStatus string + +type restApiResponseStatusValuesType struct { + Completed RestApiResponseStatus + Failed RestApiResponseStatus + Inprogress RestApiResponseStatus + Skipped RestApiResponseStatus +} + +var RestApiResponseStatusValues = restApiResponseStatusValuesType{ + // The operation is completed. + Completed: "completed", + // The operation is failed. + Failed: "failed", + // The operation is in progress. + Inprogress: "inprogress", + // The operation is in skipped. + Skipped: "skipped", +} + +// REST Api Response +type RestApiResponseStatusModel struct { + // Gets or sets the operation details + OperationDetails interface{} `json:"operationDetails,omitempty"` + // Gets or sets the operation id + OperationId *string `json:"operationId,omitempty"` + // Gets or sets the completed status percentage + PercentageCompleted *int `json:"percentageCompleted,omitempty"` + // Gets or sets the status + Status *RestApiResponseStatus `json:"status,omitempty"` + // Gets or sets the status message + StatusMessage *string `json:"statusMessage,omitempty"` +} + +type Review struct { + // Admin Reply, if any, for this review + AdminReply *ReviewReply `json:"adminReply,omitempty"` + // Unique identifier of a review item + Id *uint64 `json:"id,omitempty"` + // Flag for soft deletion + IsDeleted *bool `json:"isDeleted,omitempty"` + IsIgnored *bool `json:"isIgnored,omitempty"` + // Version of the product for which review was submitted + ProductVersion *string `json:"productVersion,omitempty"` + // Rating provided by the user + Rating *byte `json:"rating,omitempty"` + // Reply, if any, for this review + Reply *ReviewReply `json:"reply,omitempty"` + // Text description of the review + Text *string `json:"text,omitempty"` + // Title of the review + Title *string `json:"title,omitempty"` + // Time when the review was edited/updated + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` + // Name of the user + UserDisplayName *string `json:"userDisplayName,omitempty"` + // Id of the user who submitted the review + UserId *uuid.UUID `json:"userId,omitempty"` +} + +// Type of operation +type ReviewEventOperation string + +type reviewEventOperationValuesType struct { + Create ReviewEventOperation + Update ReviewEventOperation + Delete ReviewEventOperation +} + +var ReviewEventOperationValues = reviewEventOperationValuesType{ + Create: "create", + Update: "update", + Delete: "delete", +} + +// Properties associated with Review event +type ReviewEventProperties struct { + // Operation performed on Event - Create\Update + EventOperation *ReviewEventOperation `json:"eventOperation,omitempty"` + // Flag to see if reply is admin reply + IsAdminReply *bool `json:"isAdminReply,omitempty"` + // Flag to record if the review is ignored + IsIgnored *bool `json:"isIgnored,omitempty"` + // Rating at the time of event + Rating *int `json:"rating,omitempty"` + // Reply update date + ReplyDate *azuredevops.Time `json:"replyDate,omitempty"` + // Publisher reply text or admin reply text + ReplyText *string `json:"replyText,omitempty"` + // User who responded to the review + ReplyUserId *uuid.UUID `json:"replyUserId,omitempty"` + // Review Event Type - Review + ResourceType *ReviewResourceType `json:"resourceType,omitempty"` + // Review update date + ReviewDate *azuredevops.Time `json:"reviewDate,omitempty"` + // ReviewId of the review on which the operation is performed + ReviewId *uint64 `json:"reviewId,omitempty"` + // Text in Review Text + ReviewText *string `json:"reviewText,omitempty"` + // User display name at the time of review + UserDisplayName *string `json:"userDisplayName,omitempty"` + // User who gave review + UserId *uuid.UUID `json:"userId,omitempty"` +} + +// [Flags] Options to GetReviews query +type ReviewFilterOptions string + +type reviewFilterOptionsValuesType struct { + None ReviewFilterOptions + FilterEmptyReviews ReviewFilterOptions + FilterEmptyUserNames ReviewFilterOptions +} + +var ReviewFilterOptionsValues = reviewFilterOptionsValuesType{ + // No filtering, all reviews are returned (default option) + None: "none", + // Filter out review items with empty review text + FilterEmptyReviews: "filterEmptyReviews", + // Filter out review items with empty usernames + FilterEmptyUserNames: "filterEmptyUserNames", +} + +type ReviewPatch struct { + // Denotes the patch operation type + Operation *ReviewPatchOperation `json:"operation,omitempty"` + // Use when patch operation is FlagReview + ReportedConcern *UserReportedConcern `json:"reportedConcern,omitempty"` + // Use when patch operation is EditReview + ReviewItem *Review `json:"reviewItem,omitempty"` +} + +// Denotes the patch operation type +type ReviewPatchOperation string + +type reviewPatchOperationValuesType struct { + FlagReview ReviewPatchOperation + UpdateReview ReviewPatchOperation + ReplyToReview ReviewPatchOperation + AdminResponseForReview ReviewPatchOperation + DeleteAdminReply ReviewPatchOperation + DeletePublisherReply ReviewPatchOperation +} + +var ReviewPatchOperationValues = reviewPatchOperationValuesType{ + // Flag a review + FlagReview: "flagReview", + // Update an existing review + UpdateReview: "updateReview", + // Submit a reply for a review + ReplyToReview: "replyToReview", + // Submit an admin response + AdminResponseForReview: "adminResponseForReview", + // Delete an Admin Reply + DeleteAdminReply: "deleteAdminReply", + // Delete Publisher Reply + DeletePublisherReply: "deletePublisherReply", +} + +type ReviewReply struct { + // Id of the reply + Id *uint64 `json:"id,omitempty"` + // Flag for soft deletion + IsDeleted *bool `json:"isDeleted,omitempty"` + // Version of the product when the reply was submitted or updated + ProductVersion *string `json:"productVersion,omitempty"` + // Content of the reply + ReplyText *string `json:"replyText,omitempty"` + // Id of the review, to which this reply belongs + ReviewId *uint64 `json:"reviewId,omitempty"` + // Title of the reply + Title *string `json:"title,omitempty"` + // Date the reply was submitted or updated + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` + // Id of the user who left the reply + UserId *uuid.UUID `json:"userId,omitempty"` +} + +// Type of event +type ReviewResourceType string + +type reviewResourceTypeValuesType struct { + Review ReviewResourceType + PublisherReply ReviewResourceType + AdminReply ReviewResourceType +} + +var ReviewResourceTypeValues = reviewResourceTypeValuesType{ + Review: "review", + PublisherReply: "publisherReply", + AdminReply: "adminReply", +} + +type ReviewsResult struct { + // Flag indicating if there are more reviews to be shown (for paging) + HasMoreReviews *bool `json:"hasMoreReviews,omitempty"` + // List of reviews + Reviews *[]Review `json:"reviews,omitempty"` + // Count of total review items + TotalReviewCount *uint64 `json:"totalReviewCount,omitempty"` +} + +type ReviewSummary struct { + // Average Rating + AverageRating *float32 `json:"averageRating,omitempty"` + // Count of total ratings + RatingCount *uint64 `json:"ratingCount,omitempty"` + // Split of count across rating + RatingSplit *[]RatingCountPerRating `json:"ratingSplit,omitempty"` +} + +// Defines the sort order that can be defined for Extensions query +type SortByType string + +type sortByTypeValuesType struct { + Relevance SortByType + LastUpdatedDate SortByType + Title SortByType + Publisher SortByType + InstallCount SortByType + PublishedDate SortByType + AverageRating SortByType + TrendingDaily SortByType + TrendingWeekly SortByType + TrendingMonthly SortByType + ReleaseDate SortByType + Author SortByType + WeightedRating SortByType +} + +var SortByTypeValues = sortByTypeValuesType{ + // The results will be sorted by relevance in case search query is given, if no search query resutls will be provided as is + Relevance: "relevance", + // The results will be sorted as per Last Updated date of the extensions with recently updated at the top + LastUpdatedDate: "lastUpdatedDate", + // Results will be sorted Alphabetically as per the title of the extension + Title: "title", + // Results will be sorted Alphabetically as per Publisher title + Publisher: "publisher", + // Results will be sorted by Install Count + InstallCount: "installCount", + // The results will be sorted as per Published date of the extensions + PublishedDate: "publishedDate", + // The results will be sorted as per Average ratings of the extensions + AverageRating: "averageRating", + // The results will be sorted as per Trending Daily Score of the extensions + TrendingDaily: "trendingDaily", + // The results will be sorted as per Trending weekly Score of the extensions + TrendingWeekly: "trendingWeekly", + // The results will be sorted as per Trending monthly Score of the extensions + TrendingMonthly: "trendingMonthly", + // The results will be sorted as per ReleaseDate of the extensions (date on which the extension first went public) + ReleaseDate: "releaseDate", + // The results will be sorted as per Author defined in the VSix/Metadata. If not defined, publisher name is used This is specifically needed by VS IDE, other (new and old) clients are not encouraged to use this + Author: "author", + // The results will be sorted as per Weighted Rating of the extension. + WeightedRating: "weightedRating", +} + +// Defines the sort order that can be defined for Extensions query +type SortOrderType string + +type sortOrderTypeValuesType struct { + Default SortOrderType + Ascending SortOrderType + Descending SortOrderType +} + +var SortOrderTypeValues = sortOrderTypeValuesType{ + // Results will be sorted in the default order as per the sorting type defined. The default varies for each type, e.g. for Relevance, default is Descending, for Title default is Ascending etc. + Default: "default", + // The results will be sorted in Ascending order + Ascending: "ascending", + // The results will be sorted in Descending order + Descending: "descending", +} + +type UnpackagedExtensionData struct { + Categories *[]string `json:"categories,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + DraftId *uuid.UUID `json:"draftId,omitempty"` + ExtensionName *string `json:"extensionName,omitempty"` + InstallationTargets *[]InstallationTarget `json:"installationTargets,omitempty"` + IsConvertedToMarkdown *bool `json:"isConvertedToMarkdown,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + PricingCategory *string `json:"pricingCategory,omitempty"` + Product *string `json:"product,omitempty"` + PublisherName *string `json:"publisherName,omitempty"` + QnAEnabled *bool `json:"qnAEnabled,omitempty"` + ReferralUrl *string `json:"referralUrl,omitempty"` + RepositoryUrl *string `json:"repositoryUrl,omitempty"` + Tags *[]string `json:"tags,omitempty"` + Version *string `json:"version,omitempty"` + VsixId *string `json:"vsixId,omitempty"` +} + +// Represents the extension policy applied to a given user +type UserExtensionPolicy struct { + // User display name that this policy refers to + DisplayName *string `json:"displayName,omitempty"` + // The extension policy applied to the user + Permissions *ExtensionPolicy `json:"permissions,omitempty"` + // User id that this policy refers to + UserId *string `json:"userId,omitempty"` +} + +// Identity reference with name and guid +type UserIdentityRef struct { + // User display name + DisplayName *string `json:"displayName,omitempty"` + // User VSID + Id *uuid.UUID `json:"id,omitempty"` +} + +type UserReportedConcern struct { + // Category of the concern + Category *ConcernCategory `json:"category,omitempty"` + // User comment associated with the report + ConcernText *string `json:"concernText,omitempty"` + // Id of the review which was reported + ReviewId *uint64 `json:"reviewId,omitempty"` + // Date the report was submitted + SubmittedDate *azuredevops.Time `json:"submittedDate,omitempty"` + // Id of the user who reported a review + UserId *uuid.UUID `json:"userId,omitempty"` +} diff --git a/azuredevops/git/client.go b/azuredevops/git/client.go new file mode 100644 index 00000000..b8794b7a --- /dev/null +++ b/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).String()) + } + if args.SearchCriteria.ToDate != nil { + queryParams.Add("searchCriteria.toDate", (*args.SearchCriteria.ToDate).String()) + } + 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/azuredevops/git/models.go b/azuredevops/git/models.go new file mode 100644 index 00000000..3ba3b552 --- /dev/null +++ b/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/azuredevops/go.mod b/azuredevops/go.mod new file mode 100644 index 00000000..0486f058 --- /dev/null +++ b/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/azuredevops/go.sum b/azuredevops/go.sum new file mode 100644 index 00000000..b864886e --- /dev/null +++ b/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/azuredevops/graph/client.go b/azuredevops/graph/client.go new file mode 100644 index 00000000..d422e164 --- /dev/null +++ b/azuredevops/graph/client.go @@ -0,0 +1,803 @@ +// -------------------------------------------------------------------------------------------- +// 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 graph + +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/profile" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("bb1e7ec9-e901-4b68-999a-de7012b920f8") + +type Client interface { + // [Preview API] Create a new membership between a container and subject. + AddMembership(context.Context, AddMembershipArgs) (*GraphMembership, error) + // [Preview API] Check to see if a membership relationship between a container and subject exists. + CheckMembershipExistence(context.Context, CheckMembershipExistenceArgs) error + // [Preview API] Create a new Azure DevOps group or materialize an existing AAD group. + CreateGroup(context.Context, CreateGroupArgs) (*GraphGroup, error) + // [Preview API] Materialize an existing AAD or MSA user into the VSTS account. + CreateUser(context.Context, CreateUserArgs) (*GraphUser, error) + // [Preview API] + DeleteAvatar(context.Context, DeleteAvatarArgs) error + // [Preview API] Removes an Azure DevOps group from all of its parent groups. + DeleteGroup(context.Context, DeleteGroupArgs) error + // [Preview API] Disables a user. + DeleteUser(context.Context, DeleteUserArgs) error + // [Preview API] + GetAvatar(context.Context, GetAvatarArgs) (*profile.Avatar, error) + // [Preview API] Resolve a storage key to a descriptor + GetDescriptor(context.Context, GetDescriptorArgs) (*GraphDescriptorResult, error) + // [Preview API] Get a group by its descriptor. + GetGroup(context.Context, GetGroupArgs) (*GraphGroup, error) + // [Preview API] Get a membership relationship between a container and subject. + GetMembership(context.Context, GetMembershipArgs) (*GraphMembership, error) + // [Preview API] Check whether a subject is active or inactive. + GetMembershipState(context.Context, GetMembershipStateArgs) (*GraphMembershipState, error) + // [Preview API] + GetProviderInfo(context.Context, GetProviderInfoArgs) (*GraphProviderInfo, error) + // [Preview API] Resolve a descriptor to a storage key. + GetStorageKey(context.Context, GetStorageKeyArgs) (*GraphStorageKeyResult, error) + // [Preview API] Get a user by its descriptor. + GetUser(context.Context, GetUserArgs) (*GraphUser, error) + // [Preview API] Gets a list of all groups in the current scope (usually organization or account). + ListGroups(context.Context, ListGroupsArgs) (*PagedGraphGroups, error) + // [Preview API] Get all the memberships where this descriptor is a member in the relationship. + ListMemberships(context.Context, ListMembershipsArgs) (*[]GraphMembership, error) + // [Preview API] Get a list of all users in a given scope. + ListUsers(context.Context, ListUsersArgs) (*PagedGraphUsers, error) + // [Preview API] Resolve descriptors to users, groups or scopes (Subjects) in a batch. + LookupSubjects(context.Context, LookupSubjectsArgs) (*map[string]GraphSubject, error) + // [Preview API] Deletes a membership between a container and subject. + RemoveMembership(context.Context, RemoveMembershipArgs) error + // [Preview API] + RequestAccess(context.Context, RequestAccessArgs) error + // [Preview API] + SetAvatar(context.Context, SetAvatarArgs) error + // [Preview API] Update the properties of an Azure DevOps group. + UpdateGroup(context.Context, UpdateGroupArgs) (*GraphGroup, error) + // [Preview API] Map an existing user to a different identity + UpdateUser(context.Context, UpdateUserArgs) (*GraphUser, 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 a new membership between a container and subject. +func (client *ClientImpl) AddMembership(ctx context.Context, args AddMembershipArgs) (*GraphMembership, error) { + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + if args.ContainerDescriptor == nil || *args.ContainerDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ContainerDescriptor"} + } + routeValues["containerDescriptor"] = *args.ContainerDescriptor + + locationId, _ := uuid.Parse("3fd2e6ca-fb30-443a-b579-95b19ed0934c") + 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 GraphMembership + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddMembership function +type AddMembershipArgs struct { + // (required) A descriptor to a group or user that can be the child subject in the relationship. + SubjectDescriptor *string + // (required) A descriptor to a group that can be the container in the relationship. + ContainerDescriptor *string +} + +// [Preview API] Check to see if a membership relationship between a container and subject exists. +func (client *ClientImpl) CheckMembershipExistence(ctx context.Context, args CheckMembershipExistenceArgs) error { + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + if args.ContainerDescriptor == nil || *args.ContainerDescriptor == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ContainerDescriptor"} + } + routeValues["containerDescriptor"] = *args.ContainerDescriptor + + locationId, _ := uuid.Parse("3fd2e6ca-fb30-443a-b579-95b19ed0934c") + _, err := client.Client.Send(ctx, http.MethodHead, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the CheckMembershipExistence function +type CheckMembershipExistenceArgs struct { + // (required) The group or user that is a child subject of the relationship. + SubjectDescriptor *string + // (required) The group that is the container in the relationship. + ContainerDescriptor *string +} + +// [Preview API] Create a new Azure DevOps group or materialize an existing AAD group. +func (client *ClientImpl) CreateGroup(ctx context.Context, args CreateGroupArgs) (*GraphGroup, error) { + if args.CreationContext == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CreationContext"} + } + queryParams := url.Values{} + if args.ScopeDescriptor != nil { + queryParams.Add("scopeDescriptor", *args.ScopeDescriptor) + } + if args.GroupDescriptors != nil { + listAsString := strings.Join((*args.GroupDescriptors)[:], ",") + queryParams.Add("groupDescriptors", listAsString) + } + body, marshalErr := json.Marshal(*args.CreationContext) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ebbe6af8-0b91-4c13-8cf1-777c14858188") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GraphGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateGroup function +type CreateGroupArgs struct { + // (required) The subset of the full graph group used to uniquely find the graph subject in an external provider. + CreationContext *GraphGroupCreationContext + // (optional) A descriptor referencing the scope (collection, project) in which the group should be created. If omitted, will be created in the scope of the enclosing account or organization. Valid only for VSTS groups. + ScopeDescriptor *string + // (optional) A comma separated list of descriptors referencing groups you want the graph group to join + GroupDescriptors *[]string +} + +// [Preview API] Materialize an existing AAD or MSA user into the VSTS account. +func (client *ClientImpl) CreateUser(ctx context.Context, args CreateUserArgs) (*GraphUser, error) { + if args.CreationContext == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CreationContext"} + } + queryParams := url.Values{} + if args.GroupDescriptors != nil { + listAsString := strings.Join((*args.GroupDescriptors)[:], ",") + queryParams.Add("groupDescriptors", listAsString) + } + body, marshalErr := json.Marshal(*args.CreationContext) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("005e26ec-6b77-4e4f-a986-b3827bf241f5") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GraphUser + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateUser function +type CreateUserArgs struct { + // (required) The subset of the full graph user used to uniquely find the graph subject in an external provider. + CreationContext *GraphUserCreationContext + // (optional) A comma separated list of descriptors of groups you want the graph user to join + GroupDescriptors *[]string +} + +// [Preview API] +func (client *ClientImpl) DeleteAvatar(ctx context.Context, args DeleteAvatarArgs) error { + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + + locationId, _ := uuid.Parse("801eaf9c-0585-4be8-9cdb-b0efa074de91") + _, 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 DeleteAvatar function +type DeleteAvatarArgs struct { + // (required) + SubjectDescriptor *string +} + +// [Preview API] Removes an Azure DevOps group from all of its parent groups. +func (client *ClientImpl) DeleteGroup(ctx context.Context, args DeleteGroupArgs) error { + routeValues := make(map[string]string) + if args.GroupDescriptor == nil || *args.GroupDescriptor == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupDescriptor"} + } + routeValues["groupDescriptor"] = *args.GroupDescriptor + + locationId, _ := uuid.Parse("ebbe6af8-0b91-4c13-8cf1-777c14858188") + _, 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 DeleteGroup function +type DeleteGroupArgs struct { + // (required) The descriptor of the group to delete. + GroupDescriptor *string +} + +// [Preview API] Disables a user. +func (client *ClientImpl) DeleteUser(ctx context.Context, args DeleteUserArgs) error { + routeValues := make(map[string]string) + if args.UserDescriptor == nil || *args.UserDescriptor == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserDescriptor"} + } + routeValues["userDescriptor"] = *args.UserDescriptor + + locationId, _ := uuid.Parse("005e26ec-6b77-4e4f-a986-b3827bf241f5") + _, 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 DeleteUser function +type DeleteUserArgs struct { + // (required) The descriptor of the user to delete. + UserDescriptor *string +} + +// [Preview API] +func (client *ClientImpl) GetAvatar(ctx context.Context, args GetAvatarArgs) (*profile.Avatar, error) { + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + + queryParams := url.Values{} + if args.Size != nil { + queryParams.Add("size", string(*args.Size)) + } + if args.Format != nil { + queryParams.Add("format", *args.Format) + } + locationId, _ := uuid.Parse("801eaf9c-0585-4be8-9cdb-b0efa074de91") + 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 profile.Avatar + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAvatar function +type GetAvatarArgs struct { + // (required) + SubjectDescriptor *string + // (optional) + Size *profile.AvatarSize + // (optional) + Format *string +} + +// [Preview API] Resolve a storage key to a descriptor +func (client *ClientImpl) GetDescriptor(ctx context.Context, args GetDescriptorArgs) (*GraphDescriptorResult, error) { + routeValues := make(map[string]string) + if args.StorageKey == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.StorageKey"} + } + routeValues["storageKey"] = (*args.StorageKey).String() + + locationId, _ := uuid.Parse("048aee0a-7072-4cde-ab73-7af77b1e0b4e") + 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 GraphDescriptorResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDescriptor function +type GetDescriptorArgs struct { + // (required) Storage key of the subject (user, group, scope, etc.) to resolve + StorageKey *uuid.UUID +} + +// [Preview API] Get a group by its descriptor. +func (client *ClientImpl) GetGroup(ctx context.Context, args GetGroupArgs) (*GraphGroup, error) { + routeValues := make(map[string]string) + if args.GroupDescriptor == nil || *args.GroupDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupDescriptor"} + } + routeValues["groupDescriptor"] = *args.GroupDescriptor + + locationId, _ := uuid.Parse("ebbe6af8-0b91-4c13-8cf1-777c14858188") + 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 GraphGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetGroup function +type GetGroupArgs struct { + // (required) The descriptor of the desired graph group. + GroupDescriptor *string +} + +// [Preview API] Get a membership relationship between a container and subject. +func (client *ClientImpl) GetMembership(ctx context.Context, args GetMembershipArgs) (*GraphMembership, error) { + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + if args.ContainerDescriptor == nil || *args.ContainerDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ContainerDescriptor"} + } + routeValues["containerDescriptor"] = *args.ContainerDescriptor + + locationId, _ := uuid.Parse("3fd2e6ca-fb30-443a-b579-95b19ed0934c") + 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 GraphMembership + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetMembership function +type GetMembershipArgs struct { + // (required) A descriptor to the child subject in the relationship. + SubjectDescriptor *string + // (required) A descriptor to the container in the relationship. + ContainerDescriptor *string +} + +// [Preview API] Check whether a subject is active or inactive. +func (client *ClientImpl) GetMembershipState(ctx context.Context, args GetMembershipStateArgs) (*GraphMembershipState, error) { + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + + locationId, _ := uuid.Parse("1ffe5c94-1144-4191-907b-d0211cad36a8") + 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 GraphMembershipState + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetMembershipState function +type GetMembershipStateArgs struct { + // (required) Descriptor of the subject (user, group, scope, etc.) to check state of + SubjectDescriptor *string +} + +// [Preview API] +func (client *ClientImpl) GetProviderInfo(ctx context.Context, args GetProviderInfoArgs) (*GraphProviderInfo, error) { + routeValues := make(map[string]string) + if args.UserDescriptor == nil || *args.UserDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserDescriptor"} + } + routeValues["userDescriptor"] = *args.UserDescriptor + + locationId, _ := uuid.Parse("1e377995-6fa2-4588-bd64-930186abdcfa") + 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 GraphProviderInfo + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProviderInfo function +type GetProviderInfoArgs struct { + // (required) + UserDescriptor *string +} + +// [Preview API] Resolve a descriptor to a storage key. +func (client *ClientImpl) GetStorageKey(ctx context.Context, args GetStorageKeyArgs) (*GraphStorageKeyResult, error) { + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + + locationId, _ := uuid.Parse("eb85f8cc-f0f6-4264-a5b1-ffe2e4d4801f") + 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 GraphStorageKeyResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetStorageKey function +type GetStorageKeyArgs struct { + // (required) + SubjectDescriptor *string +} + +// [Preview API] Get a user by its descriptor. +func (client *ClientImpl) GetUser(ctx context.Context, args GetUserArgs) (*GraphUser, error) { + routeValues := make(map[string]string) + if args.UserDescriptor == nil || *args.UserDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserDescriptor"} + } + routeValues["userDescriptor"] = *args.UserDescriptor + + locationId, _ := uuid.Parse("005e26ec-6b77-4e4f-a986-b3827bf241f5") + 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 GraphUser + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetUser function +type GetUserArgs struct { + // (required) The descriptor of the desired user. + UserDescriptor *string +} + +// [Preview API] Gets a list of all groups in the current scope (usually organization or account). +func (client *ClientImpl) ListGroups(ctx context.Context, args ListGroupsArgs) (*PagedGraphGroups, error) { + queryParams := url.Values{} + if args.ScopeDescriptor != nil { + queryParams.Add("scopeDescriptor", *args.ScopeDescriptor) + } + if args.SubjectTypes != nil { + listAsString := strings.Join((*args.SubjectTypes)[:], ",") + queryParams.Add("subjectTypes", listAsString) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("ebbe6af8-0b91-4c13-8cf1-777c14858188") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseBodyValue []GraphGroup + err = client.Client.UnmarshalCollectionBody(resp, &responseBodyValue) + + var responseValue *PagedGraphGroups + if err == nil { + responseValue = &PagedGraphGroups{ + GraphGroups: &responseBodyValue, + ContinuationToken: &[]string{resp.Header.Get("X-MS-ContinuationToken")}, + } + } + + return responseValue, err +} + +// Arguments for the ListGroups function +type ListGroupsArgs struct { + // (optional) Specify a non-default scope (collection, project) to search for groups. + ScopeDescriptor *string + // (optional) A comma separated list of user subject subtypes to reduce the retrieved results, e.g. Microsoft.IdentityModel.Claims.ClaimsIdentity + SubjectTypes *[]string + // (optional) An opaque data blob that allows the next page of data to resume immediately after where the previous page ended. The only reliable way to know if there is more data left is the presence of a continuation token. + ContinuationToken *string +} + +// [Preview API] Get all the memberships where this descriptor is a member in the relationship. +func (client *ClientImpl) ListMemberships(ctx context.Context, args ListMembershipsArgs) (*[]GraphMembership, error) { + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + + queryParams := url.Values{} + if args.Direction != nil { + queryParams.Add("direction", string(*args.Direction)) + } + if args.Depth != nil { + queryParams.Add("depth", strconv.Itoa(*args.Depth)) + } + locationId, _ := uuid.Parse("e34b6394-6b30-4435-94a9-409a5eef3e31") + 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 []GraphMembership + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListMemberships function +type ListMembershipsArgs struct { + // (required) Fetch all direct memberships of this descriptor. + SubjectDescriptor *string + // (optional) Defaults to Up. + Direction *GraphTraversalDirection + // (optional) The maximum number of edges to traverse up or down the membership tree. Currently the only supported value is '1'. + Depth *int +} + +// [Preview API] Get a list of all users in a given scope. +func (client *ClientImpl) ListUsers(ctx context.Context, args ListUsersArgs) (*PagedGraphUsers, error) { + queryParams := url.Values{} + if args.SubjectTypes != nil { + listAsString := strings.Join((*args.SubjectTypes)[:], ",") + queryParams.Add("subjectTypes", listAsString) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("005e26ec-6b77-4e4f-a986-b3827bf241f5") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseBodyValue []GraphUser + err = client.Client.UnmarshalCollectionBody(resp, &responseBodyValue) + + var responseValue *PagedGraphUsers + if err == nil { + responseValue = &PagedGraphUsers{ + GraphUsers: &responseBodyValue, + ContinuationToken: &[]string{resp.Header.Get("X-MS-ContinuationToken")}, + } + } + + return responseValue, err +} + +// Arguments for the ListUsers function +type ListUsersArgs struct { + // (optional) A comma separated list of user subject subtypes to reduce the retrieved results, e.g. msa’, ‘aad’, ‘svc’ (service identity), ‘imp’ (imported identity), etc. + SubjectTypes *[]string + // (optional) An opaque data blob that allows the next page of data to resume immediately after where the previous page ended. The only reliable way to know if there is more data left is the presence of a continuation token. + ContinuationToken *string +} + +// [Preview API] Resolve descriptors to users, groups or scopes (Subjects) in a batch. +func (client *ClientImpl) LookupSubjects(ctx context.Context, args LookupSubjectsArgs) (*map[string]GraphSubject, error) { + if args.SubjectLookup == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SubjectLookup"} + } + body, marshalErr := json.Marshal(*args.SubjectLookup) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4dd4d168-11f2-48c4-83e8-756fa0de027c") + 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 map[string]GraphSubject + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the LookupSubjects function +type LookupSubjectsArgs struct { + // (required) A list of descriptors that specifies a subset of subjects to retrieve. Each descriptor uniquely identifies the subject across all instance scopes, but only at a single point in time. + SubjectLookup *GraphSubjectLookup +} + +// [Preview API] Deletes a membership between a container and subject. +func (client *ClientImpl) RemoveMembership(ctx context.Context, args RemoveMembershipArgs) error { + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + if args.ContainerDescriptor == nil || *args.ContainerDescriptor == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ContainerDescriptor"} + } + routeValues["containerDescriptor"] = *args.ContainerDescriptor + + locationId, _ := uuid.Parse("3fd2e6ca-fb30-443a-b579-95b19ed0934c") + _, 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 RemoveMembership function +type RemoveMembershipArgs struct { + // (required) A descriptor to a group or user that is the child subject in the relationship. + SubjectDescriptor *string + // (required) A descriptor to a group that is the container in the relationship. + ContainerDescriptor *string +} + +// [Preview API] +func (client *ClientImpl) RequestAccess(ctx context.Context, args RequestAccessArgs) error { + if args.Message == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Message"} + } + body, marshalErr := json.Marshal(*args.Message) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("8d54bf92-8c99-47f2-9972-b21341f1722e") + _, 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 err + } + + return nil +} + +// Arguments for the RequestAccess function +type RequestAccessArgs struct { + // (required) + Message *string +} + +// [Preview API] +func (client *ClientImpl) SetAvatar(ctx context.Context, args SetAvatarArgs) error { + if args.Avatar == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Avatar"} + } + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + + body, marshalErr := json.Marshal(*args.Avatar) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("801eaf9c-0585-4be8-9cdb-b0efa074de91") + _, 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 SetAvatar function +type SetAvatarArgs struct { + // (required) + Avatar *profile.Avatar + // (required) + SubjectDescriptor *string +} + +// [Preview API] Update the properties of an Azure DevOps group. +func (client *ClientImpl) UpdateGroup(ctx context.Context, args UpdateGroupArgs) (*GraphGroup, error) { + if args.PatchDocument == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PatchDocument"} + } + routeValues := make(map[string]string) + if args.GroupDescriptor == nil || *args.GroupDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupDescriptor"} + } + routeValues["groupDescriptor"] = *args.GroupDescriptor + + body, marshalErr := json.Marshal(*args.PatchDocument) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ebbe6af8-0b91-4c13-8cf1-777c14858188") + 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 GraphGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateGroup function +type UpdateGroupArgs struct { + // (required) The descriptor of the group to modify. + GroupDescriptor *string + // (required) The JSON+Patch document containing the fields to alter. + PatchDocument *[]webapi.JsonPatchOperation +} + +// [Preview API] Map an existing user to a different identity +func (client *ClientImpl) UpdateUser(ctx context.Context, args UpdateUserArgs) (*GraphUser, error) { + if args.UpdateContext == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateContext"} + } + routeValues := make(map[string]string) + if args.UserDescriptor == nil || *args.UserDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserDescriptor"} + } + routeValues["userDescriptor"] = *args.UserDescriptor + + body, marshalErr := json.Marshal(*args.UpdateContext) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("005e26ec-6b77-4e4f-a986-b3827bf241f5") + 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 GraphUser + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateUser function +type UpdateUserArgs struct { + // (required) The subset of the full graph user used to uniquely find the graph subject in an external provider. + UpdateContext *GraphUserUpdateContext + // (required) the descriptor of the user to update + UserDescriptor *string +} diff --git a/azuredevops/graph/models.go b/azuredevops/graph/models.go new file mode 100644 index 00000000..8c56bb38 --- /dev/null +++ b/azuredevops/graph/models.go @@ -0,0 +1,413 @@ +// -------------------------------------------------------------------------------------------- +// 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 graph + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops/identity" +) + +type GraphCachePolicies struct { + // Size of the cache + CacheSize *int `json:"cacheSize,omitempty"` +} + +// Subject descriptor of a Graph entity +type GraphDescriptorResult struct { + // This field contains zero or more interesting links about the graph descriptor. These links may be invoked to obtain additional relationships or more detailed information about this graph descriptor. + Links interface{} `json:"_links,omitempty"` + Value *string `json:"value,omitempty"` +} + +type GraphGlobalExtendedPropertyBatch struct { + PropertyNameFilters *[]string `json:"propertyNameFilters,omitempty"` + SubjectDescriptors *[]string `json:"subjectDescriptors,omitempty"` +} + +// Graph group entity +type GraphGroup 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"` + // [Internal Use Only] The legacy descriptor is here in case you need to access old version IMS using identity descriptor. + LegacyDescriptor *string `json:"legacyDescriptor,omitempty"` + // The type of source provider for the origin identifier (ex:AD, AAD, MSA) + Origin *string `json:"origin,omitempty"` + // The unique identifier from the system of origin. Typically a sid, object id or Guid. Linking and unlinking operations can cause this value to change for a user because the user is not backed by a different provider and has a different unique id in the new provider. + OriginId *string `json:"originId,omitempty"` + // This field identifies the type of the graph subject (ex: Group, Scope, User). + SubjectKind *string `json:"subjectKind,omitempty"` + // This represents the name of the container of origin for a graph member. (For MSA this is "Windows Live ID", for AD the name of the domain, for AAD the tenantID of the directory, for VSTS groups the ScopeId, etc) + Domain *string `json:"domain,omitempty"` + // The email address of record for a given graph member. This may be different than the principal name. + MailAddress *string `json:"mailAddress,omitempty"` + // This is the PrincipalName of this graph member from the source provider. The source provider may change this field over time and it is not guaranteed to be immutable for the life of the graph member by VSTS. + PrincipalName *string `json:"principalName,omitempty"` + // A short phrase to help human readers disambiguate groups with similar names + Description *string `json:"description,omitempty"` +} + +// Do not attempt to use this type to create a new group. This type does not contain sufficient fields to create a new group. +type GraphGroupCreationContext struct { + // Optional: If provided, we will use this identifier for the storage key of the created group + StorageKey *uuid.UUID `json:"storageKey,omitempty"` +} + +// Use this type to create a new group using the mail address as a reference to an existing group from an external AD or AAD backed provider. This is the subset of GraphGroup fields required for creation of a group for the AAD and AD use case. +type GraphGroupMailAddressCreationContext struct { + // Optional: If provided, we will use this identifier for the storage key of the created group + StorageKey *uuid.UUID `json:"storageKey,omitempty"` + // This should be the mail address or the group in the source AD or AAD provider. Example: jamal@contoso.com Team Services will communicate with the source provider to fill all other fields on creation. + MailAddress *string `json:"mailAddress,omitempty"` +} + +// Use this type to create a new group using the OriginID as a reference to an existing group from an external AD or AAD backed provider. This is the subset of GraphGroup fields required for creation of a group for the AD and AAD use case. +type GraphGroupOriginIdCreationContext struct { + // Optional: If provided, we will use this identifier for the storage key of the created group + StorageKey *uuid.UUID `json:"storageKey,omitempty"` + // This should be the object id or sid of the group from the source AD or AAD provider. Example: d47d025a-ce2f-4a79-8618-e8862ade30dd Team Services will communicate with the source provider to fill all other fields on creation. + OriginId *string `json:"originId,omitempty"` +} + +// Use this type to create a new Vsts group that is not backed by an external provider. +type GraphGroupVstsCreationContext struct { + // Optional: If provided, we will use this identifier for the storage key of the created group + StorageKey *uuid.UUID `json:"storageKey,omitempty"` + // For internal use only in back compat scenarios. + CrossProject *bool `json:"crossProject,omitempty"` + // Used by VSTS groups; if set this will be the group description, otherwise ignored + Description *string `json:"description,omitempty"` + Descriptor *string `json:"descriptor,omitempty"` + // Used by VSTS groups; if set this will be the group DisplayName, otherwise ignored + DisplayName *string `json:"displayName,omitempty"` + // For internal use only in back compat scenarios. + RestrictedVisibility *bool `json:"restrictedVisibility,omitempty"` + // For internal use only in back compat scenarios. + SpecialGroupType *string `json:"specialGroupType,omitempty"` +} + +type GraphMember 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"` + // [Internal Use Only] The legacy descriptor is here in case you need to access old version IMS using identity descriptor. + LegacyDescriptor *string `json:"legacyDescriptor,omitempty"` + // The type of source provider for the origin identifier (ex:AD, AAD, MSA) + Origin *string `json:"origin,omitempty"` + // The unique identifier from the system of origin. Typically a sid, object id or Guid. Linking and unlinking operations can cause this value to change for a user because the user is not backed by a different provider and has a different unique id in the new provider. + OriginId *string `json:"originId,omitempty"` + // This field identifies the type of the graph subject (ex: Group, Scope, User). + SubjectKind *string `json:"subjectKind,omitempty"` + // This represents the name of the container of origin for a graph member. (For MSA this is "Windows Live ID", for AD the name of the domain, for AAD the tenantID of the directory, for VSTS groups the ScopeId, etc) + Domain *string `json:"domain,omitempty"` + // The email address of record for a given graph member. This may be different than the principal name. + MailAddress *string `json:"mailAddress,omitempty"` + // This is the PrincipalName of this graph member from the source provider. The source provider may change this field over time and it is not guaranteed to be immutable for the life of the graph member by VSTS. + PrincipalName *string `json:"principalName,omitempty"` +} + +type GraphMemberSearchFactor string + +type graphMemberSearchFactorValuesType struct { + PrincipalName GraphMemberSearchFactor + DisplayName GraphMemberSearchFactor + AdministratorsGroup GraphMemberSearchFactor + Identifier GraphMemberSearchFactor + MailAddress GraphMemberSearchFactor + General GraphMemberSearchFactor + Alias GraphMemberSearchFactor + DirectoryAlias GraphMemberSearchFactor +} + +var GraphMemberSearchFactorValues = graphMemberSearchFactorValuesType{ + // Domain qualified account name (domain\alias) + PrincipalName: "principalName", + // Display name + DisplayName: "displayName", + // Administrators group + AdministratorsGroup: "administratorsGroup", + // Find the identity using the identifier (SID) + Identifier: "identifier", + // Email address + MailAddress: "mailAddress", + // A general search for an identity. + General: "general", + // Alternate login username (Basic Auth Alias) + Alias: "alias", + // Find identity using DirectoryAlias + DirectoryAlias: "directoryAlias", +} + +// Relationship between a container and a member +type GraphMembership struct { + // This field contains zero or more interesting links about the graph membership. These links may be invoked to obtain additional relationships or more detailed information about this graph membership. + Links interface{} `json:"_links,omitempty"` + ContainerDescriptor *string `json:"containerDescriptor,omitempty"` + MemberDescriptor *string `json:"memberDescriptor,omitempty"` +} + +// Status of a Graph membership (active/inactive) +type GraphMembershipState struct { + // This field contains zero or more interesting links about the graph membership state. These links may be invoked to obtain additional relationships or more detailed information about this graph membership state. + Links interface{} `json:"_links,omitempty"` + // When true, the membership is active + Active *bool `json:"active,omitempty"` +} + +type GraphMembershipTraversal struct { + // Reason why the subject could not be traversed completely + IncompletenessReason *string `json:"incompletenessReason,omitempty"` + // When true, the subject is traversed completely + IsComplete *bool `json:"isComplete,omitempty"` + // The traversed subject descriptor + SubjectDescriptor *string `json:"subjectDescriptor,omitempty"` + // Subject descriptor ids of the traversed members + TraversedSubjectIds *[]uuid.UUID `json:"traversedSubjectIds,omitempty"` + // Subject descriptors of the traversed members + TraversedSubjects *[]string `json:"traversedSubjects,omitempty"` +} + +// Who is the provider for this user and what is the identifier and domain that is used to uniquely identify the user. +type GraphProviderInfo struct { + // 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 represents the name of the container of origin for a graph member. (For MSA this is "Windows Live ID", for AAD the tenantID of the directory.) + Domain *string `json:"domain,omitempty"` + // The type of source provider for the origin identifier (ex: "aad", "msa") + Origin *string `json:"origin,omitempty"` + // The unique identifier from the system of origin. (For MSA this is the PUID in hex notation, for AAD this is the object id.) + OriginId *string `json:"originId,omitempty"` +} + +// Container where a graph entity is defined (organization, project, team) +type GraphScope 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"` + // [Internal Use Only] The legacy descriptor is here in case you need to access old version IMS using identity descriptor. + LegacyDescriptor *string `json:"legacyDescriptor,omitempty"` + // The type of source provider for the origin identifier (ex:AD, AAD, MSA) + Origin *string `json:"origin,omitempty"` + // The unique identifier from the system of origin. Typically a sid, object id or Guid. Linking and unlinking operations can cause this value to change for a user because the user is not backed by a different provider and has a different unique id in the new provider. + OriginId *string `json:"originId,omitempty"` + // This field identifies the type of the graph subject (ex: Group, Scope, User). + SubjectKind *string `json:"subjectKind,omitempty"` + // The subject descriptor that references the administrators group for this scope. Only members of this group can change the contents of this scope or assign other users permissions to access this scope. + AdministratorDescriptor *string `json:"administratorDescriptor,omitempty"` + // When true, this scope is also a securing host for one or more scopes. + IsGlobal *bool `json:"isGlobal,omitempty"` + // The subject descriptor for the closest account or organization in the ancestor tree of this scope. + ParentDescriptor *string `json:"parentDescriptor,omitempty"` + // The type of this scope. Typically ServiceHost or TeamProject. + ScopeType *identity.GroupScopeType `json:"scopeType,omitempty"` + // The subject descriptor for the containing organization in the ancestor tree of this scope. + SecuringHostDescriptor *string `json:"securingHostDescriptor,omitempty"` +} + +// This type is the subset of fields that can be provided by the user to create a Vsts scope. Scope creation is currently limited to internal back-compat scenarios. End users that attempt to create a scope with this API will fail. +type GraphScopeCreationContext struct { + // Set this field to override the default description of this scope's admin group. + AdminGroupDescription *string `json:"adminGroupDescription,omitempty"` + // All scopes have an Administrator Group that controls access to the contents of the scope. Set this field to use a non-default group name for that administrators group. + AdminGroupName *string `json:"adminGroupName,omitempty"` + // Set this optional field if this scope is created on behalf of a user other than the user making the request. This should be the Id of the user that is not the requester. + CreatorId *uuid.UUID `json:"creatorId,omitempty"` + // The scope must be provided with a unique name within the parent scope. This means the created scope can have a parent or child with the same name, but no siblings with the same name. + Name *string `json:"name,omitempty"` + // The type of scope being created. + ScopeType *identity.GroupScopeType `json:"scopeType,omitempty"` + // An optional ID that uniquely represents the scope within it's parent scope. If this parameter is not provided, Vsts will generate on automatically. + StorageKey *uuid.UUID `json:"storageKey,omitempty"` +} + +// Storage key of a Graph entity +type GraphStorageKeyResult struct { + // This field contains zero or more interesting links about the graph storage key. These links may be invoked to obtain additional relationships or more detailed information about this graph storage key. + Links interface{} `json:"_links,omitempty"` + Value *uuid.UUID `json:"value,omitempty"` +} + +// Top-level graph entity +type GraphSubject 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"` + // [Internal Use Only] The legacy descriptor is here in case you need to access old version IMS using identity descriptor. + LegacyDescriptor *string `json:"legacyDescriptor,omitempty"` + // The type of source provider for the origin identifier (ex:AD, AAD, MSA) + Origin *string `json:"origin,omitempty"` + // The unique identifier from the system of origin. Typically a sid, object id or Guid. Linking and unlinking operations can cause this value to change for a user because the user is not backed by a different provider and has a different unique id in the new provider. + OriginId *string `json:"originId,omitempty"` + // This field identifies the type of the graph subject (ex: Group, Scope, User). + SubjectKind *string `json:"subjectKind,omitempty"` +} + +type GraphSubjectBase 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"` +} + +// Batching of subjects to lookup using the Graph API +type GraphSubjectLookup struct { + LookupKeys *[]GraphSubjectLookupKey `json:"lookupKeys,omitempty"` +} + +type GraphSubjectLookupKey struct { + Descriptor *string `json:"descriptor,omitempty"` +} + +type GraphSystemSubject 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"` + // [Internal Use Only] The legacy descriptor is here in case you need to access old version IMS using identity descriptor. + LegacyDescriptor *string `json:"legacyDescriptor,omitempty"` + // The type of source provider for the origin identifier (ex:AD, AAD, MSA) + Origin *string `json:"origin,omitempty"` + // The unique identifier from the system of origin. Typically a sid, object id or Guid. Linking and unlinking operations can cause this value to change for a user because the user is not backed by a different provider and has a different unique id in the new provider. + OriginId *string `json:"originId,omitempty"` + // This field identifies the type of the graph subject (ex: Group, Scope, User). + SubjectKind *string `json:"subjectKind,omitempty"` +} + +type GraphTraversalDirection string + +type graphTraversalDirectionValuesType struct { + Unknown GraphTraversalDirection + Down GraphTraversalDirection + Up GraphTraversalDirection +} + +var GraphTraversalDirectionValues = graphTraversalDirectionValuesType{ + Unknown: "unknown", + Down: "down", + Up: "up", +} + +// Graph user entity +type GraphUser 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"` + // [Internal Use Only] The legacy descriptor is here in case you need to access old version IMS using identity descriptor. + LegacyDescriptor *string `json:"legacyDescriptor,omitempty"` + // The type of source provider for the origin identifier (ex:AD, AAD, MSA) + Origin *string `json:"origin,omitempty"` + // The unique identifier from the system of origin. Typically a sid, object id or Guid. Linking and unlinking operations can cause this value to change for a user because the user is not backed by a different provider and has a different unique id in the new provider. + OriginId *string `json:"originId,omitempty"` + // This field identifies the type of the graph subject (ex: Group, Scope, User). + SubjectKind *string `json:"subjectKind,omitempty"` + // This represents the name of the container of origin for a graph member. (For MSA this is "Windows Live ID", for AD the name of the domain, for AAD the tenantID of the directory, for VSTS groups the ScopeId, etc) + Domain *string `json:"domain,omitempty"` + // The email address of record for a given graph member. This may be different than the principal name. + MailAddress *string `json:"mailAddress,omitempty"` + // This is the PrincipalName of this graph member from the source provider. The source provider may change this field over time and it is not guaranteed to be immutable for the life of the graph member by VSTS. + PrincipalName *string `json:"principalName,omitempty"` + // The short, generally unique name for the user in the backing directory. For AAD users, this corresponds to the mail nickname, which is often but not necessarily similar to the part of the user's mail address before the @ sign. For GitHub users, this corresponds to the GitHub user handle. + DirectoryAlias *string `json:"directoryAlias,omitempty"` + // When true, the group has been deleted in the identity provider + IsDeletedInOrigin *bool `json:"isDeletedInOrigin,omitempty"` + // The meta type of the user in the origin, such as "member", "guest", etc. See UserMetaType for the set of possible values. + MetaType *string `json:"metaType,omitempty"` +} + +// Do not attempt to use this type to create a new user. Use one of the subclasses instead. This type does not contain sufficient fields to create a new user. +type GraphUserCreationContext struct { + // Optional: If provided, we will use this identifier for the storage key of the created user + StorageKey *uuid.UUID `json:"storageKey,omitempty"` +} + +// Use this type to create a new user using the mail address as a reference to an existing user from an external AD or AAD backed provider. This is the subset of GraphUser fields required for creation of a GraphUser for the AD and AAD use case when looking up the user by its mail address in the backing provider. +type GraphUserMailAddressCreationContext struct { + // Optional: If provided, we will use this identifier for the storage key of the created user + StorageKey *uuid.UUID `json:"storageKey,omitempty"` + MailAddress *string `json:"mailAddress,omitempty"` +} + +// Use this type to create a new user using the OriginID as a reference to an existing user from an external AD or AAD backed provider. This is the subset of GraphUser fields required for creation of a GraphUser for the AD and AAD use case when looking up the user by its unique ID in the backing provider. +type GraphUserOriginIdCreationContext struct { + // Optional: If provided, we will use this identifier for the storage key of the created user + StorageKey *uuid.UUID `json:"storageKey,omitempty"` + // This should be the name of the origin provider. Example: github.com + Origin *string `json:"origin,omitempty"` + // This should be the object id or sid of the user from the source AD or AAD provider. Example: d47d025a-ce2f-4a79-8618-e8862ade30dd Team Services will communicate with the source provider to fill all other fields on creation. + OriginId *string `json:"originId,omitempty"` +} + +// Use this type to update an existing user using the OriginID as a reference to an existing user from an external AD or AAD backed provider. This is the subset of GraphUser fields required for creation of a GraphUser for the AD and AAD use case when looking up the user by its unique ID in the backing provider. +type GraphUserOriginIdUpdateContext struct { + // Storage key should not be specified in case of updating user + StorageKey *uuid.UUID `json:"storageKey,omitempty"` + // This should be the object id or sid of the user from the source AD or AAD provider. Example: d47d025a-ce2f-4a79-8618-e8862ade30dd Azure Devops will communicate with the source provider to fill all other fields on creation. + OriginId *string `json:"originId,omitempty"` +} + +// Use this type to create a new user using the principal name as a reference to an existing user from an external AD or AAD backed provider. This is the subset of GraphUser fields required for creation of a GraphUser for the AD and AAD use case when looking up the user by its principal name in the backing provider. +type GraphUserPrincipalNameCreationContext struct { + // Optional: If provided, we will use this identifier for the storage key of the created user + StorageKey *uuid.UUID `json:"storageKey,omitempty"` + // This should be the principal name or upn of the user in the source AD or AAD provider. Example: jamal@contoso.com Team Services will communicate with the source provider to fill all other fields on creation. + PrincipalName *string `json:"principalName,omitempty"` +} + +// Do not attempt to use this type to update user. Use one of the subclasses instead. This type does not contain sufficient fields to create a new user. +type GraphUserUpdateContext struct { + // Deprecated: + StorageKey *uuid.UUID `json:"storageKey,omitempty"` +} + +type PagedGraphGroups struct { + // This will be non-null if there is another page of data. There will never be more than one continuation token returned by a request. + ContinuationToken *[]string `json:"continuationToken,omitempty"` + // The enumerable list of groups found within a page. + GraphGroups *[]GraphGroup `json:"graphGroups,omitempty"` +} + +type PagedGraphUsers struct { + // This will be non-null if there is another page of data. There will never be more than one continuation token returned by a request. + ContinuationToken *[]string `json:"continuationToken,omitempty"` + // The enumerable set of users found within a page. + GraphUsers *[]GraphUser `json:"graphUsers,omitempty"` +} diff --git a/azuredevops/identity/client.go b/azuredevops/identity/client.go new file mode 100644 index 00000000..226eab91 --- /dev/null +++ b/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/azuredevops/identity/models.go b/azuredevops/identity/models.go new file mode 100644 index 00000000..54f9b75e --- /dev/null +++ b/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/azuredevops/licensing/models.go b/azuredevops/licensing/models.go new file mode 100644 index 00000000..f5e24670 --- /dev/null +++ b/azuredevops/licensing/models.go @@ -0,0 +1,284 @@ +// -------------------------------------------------------------------------------------------- +// 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 licensing + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/accounts" + "github.com/microsoft/azure-devops-go-api/azuredevops/commerce" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +// License assigned to a user +type AccessLevel struct { + // Type of Account License (e.g. Express, Stakeholder etc.) + AccountLicenseType *AccountLicenseType `json:"accountLicenseType,omitempty"` + // Assignment Source of the License (e.g. Group, Unknown etc. + AssignmentSource *AssignmentSource `json:"assignmentSource,omitempty"` + // Display name of the License + LicenseDisplayName *string `json:"licenseDisplayName,omitempty"` + // Licensing Source (e.g. Account. MSDN etc.) + LicensingSource *LicensingSource `json:"licensingSource,omitempty"` + // Type of MSDN License (e.g. Visual Studio Professional, Visual Studio Enterprise etc.) + MsdnLicenseType *MsdnLicenseType `json:"msdnLicenseType,omitempty"` + // User status in the account + Status *accounts.AccountUserStatus `json:"status,omitempty"` + // Status message. + StatusMessage *string `json:"statusMessage,omitempty"` +} + +// Represents a license granted to a user in an account +type AccountEntitlement struct { + // Gets or sets the id of the account to which the license belongs + AccountId *uuid.UUID `json:"accountId,omitempty"` + // Gets or sets the date the license was assigned + AssignmentDate *azuredevops.Time `json:"assignmentDate,omitempty"` + // Assignment Source + AssignmentSource *AssignmentSource `json:"assignmentSource,omitempty"` + // Gets or sets the creation date of the user in this account + DateCreated *azuredevops.Time `json:"dateCreated,omitempty"` + // Gets or sets the date of the user last sign-in to this account + LastAccessedDate *azuredevops.Time `json:"lastAccessedDate,omitempty"` + License *License `json:"license,omitempty"` + // Licensing origin + Origin *LicensingOrigin `json:"origin,omitempty"` + // The computed rights of this user in the account. + Rights *AccountRights `json:"rights,omitempty"` + // The status of the user in the account + Status *accounts.AccountUserStatus `json:"status,omitempty"` + // Identity information of the user to which the license belongs + User *webapi.IdentityRef `json:"user,omitempty"` + // Gets the id of the user to which the license belongs + UserId *uuid.UUID `json:"userId,omitempty"` +} + +// Model for updating an AccountEntitlement for a user, used for the Web API +type AccountEntitlementUpdateModel struct { + // Gets or sets the license for the entitlement + License *License `json:"license,omitempty"` +} + +// Represents an Account license +type AccountLicense struct { + // Gets the source of the license + Source *LicensingSource `json:"source,omitempty"` + // Gets the license type for the license + License *AccountLicenseType `json:"license,omitempty"` +} + +type AccountLicenseExtensionUsage struct { + ExtensionId *string `json:"extensionId,omitempty"` + ExtensionName *string `json:"extensionName,omitempty"` + IncludedQuantity *int `json:"includedQuantity,omitempty"` + IsTrial *bool `json:"isTrial,omitempty"` + MinimumLicenseRequired *commerce.MinimumRequiredServiceLevel `json:"minimumLicenseRequired,omitempty"` + MsdnUsedCount *int `json:"msdnUsedCount,omitempty"` + ProvisionedCount *int `json:"provisionedCount,omitempty"` + RemainingTrialDays *int `json:"remainingTrialDays,omitempty"` + TrialExpiryDate *azuredevops.Time `json:"trialExpiryDate,omitempty"` + UsedCount *int `json:"usedCount,omitempty"` +} + +type AccountLicenseType string + +type accountLicenseTypeValuesType struct { + None AccountLicenseType + EarlyAdopter AccountLicenseType + Express AccountLicenseType + Professional AccountLicenseType + Advanced AccountLicenseType + Stakeholder AccountLicenseType +} + +var AccountLicenseTypeValues = accountLicenseTypeValuesType{ + None: "none", + EarlyAdopter: "earlyAdopter", + Express: "express", + Professional: "professional", + Advanced: "advanced", + Stakeholder: "stakeholder", +} + +type AccountRights struct { + Level *VisualStudioOnlineServiceLevel `json:"level,omitempty"` + Reason *string `json:"reason,omitempty"` +} + +type AccountUserLicense struct { + License *int `json:"license,omitempty"` + Source *LicensingSource `json:"source,omitempty"` +} + +type AssignmentSource string + +type assignmentSourceValuesType struct { + None AssignmentSource + Unknown AssignmentSource + GroupRule AssignmentSource +} + +var AssignmentSourceValues = assignmentSourceValuesType{ + None: "none", + Unknown: "unknown", + GroupRule: "groupRule", +} + +type AutoLicense struct { + // Gets the source of the license + Source *LicensingSource `json:"source,omitempty"` +} + +type ClientRightsContainer struct { + CertificateBytes *[]byte `json:"certificateBytes,omitempty"` + Token *string `json:"token,omitempty"` +} + +// Model for assigning an extension to users, used for the Web API +type ExtensionAssignment struct { + // Gets or sets the extension ID to assign. + ExtensionGalleryId *string `json:"extensionGalleryId,omitempty"` + // Set to true if this a auto assignment scenario. + IsAutoAssignment *bool `json:"isAutoAssignment,omitempty"` + // Gets or sets the licensing source. + LicensingSource *LicensingSource `json:"licensingSource,omitempty"` + // Gets or sets the user IDs to assign the extension to. + UserIds *[]uuid.UUID `json:"userIds,omitempty"` +} + +// Model for assigning an extension to users, used for the Web API +type ExtensionSource struct { + // Assignment Source + AssignmentSource *AssignmentSource `json:"assignmentSource,omitempty"` + // extension Identifier + ExtensionGalleryId *string `json:"extensionGalleryId,omitempty"` + // The licensing source of the extension. Account, Msdn, etc. + LicensingSource *LicensingSource `json:"licensingSource,omitempty"` +} + +// The base class for a specific license source and license +type License struct { + // Gets the source of the license + Source *LicensingSource `json:"source,omitempty"` +} + +type LicensingOrigin string + +type licensingOriginValuesType struct { + None LicensingOrigin + OnDemandPrivateProject LicensingOrigin + OnDemandPublicProject LicensingOrigin + UserHubInvitation LicensingOrigin + PrivateProjectInvitation LicensingOrigin + PublicProjectInvitation LicensingOrigin +} + +var LicensingOriginValues = licensingOriginValuesType{ + None: "none", + OnDemandPrivateProject: "onDemandPrivateProject", + OnDemandPublicProject: "onDemandPublicProject", + UserHubInvitation: "userHubInvitation", + PrivateProjectInvitation: "privateProjectInvitation", + PublicProjectInvitation: "publicProjectInvitation", +} + +// [Flags] +type LicensingSettingsSelectProperty string + +type licensingSettingsSelectPropertyValuesType struct { + DefaultAccessLevel LicensingSettingsSelectProperty + AccessLevelOptions LicensingSettingsSelectProperty + All LicensingSettingsSelectProperty +} + +var LicensingSettingsSelectPropertyValues = licensingSettingsSelectPropertyValuesType{ + DefaultAccessLevel: "defaultAccessLevel", + AccessLevelOptions: "accessLevelOptions", + All: "all", +} + +type LicensingSource string + +type licensingSourceValuesType struct { + None LicensingSource + Account LicensingSource + Msdn LicensingSource + Profile LicensingSource + Auto LicensingSource + Trial LicensingSource +} + +var LicensingSourceValues = licensingSourceValuesType{ + None: "none", + Account: "account", + Msdn: "msdn", + Profile: "profile", + Auto: "auto", + Trial: "trial", +} + +// Represents an Msdn license +type MsdnLicense struct { + // Gets the source of the license + Source *LicensingSource `json:"source,omitempty"` + // Gets the license type for the license + License *MsdnLicenseType `json:"license,omitempty"` +} + +type MsdnLicenseType string + +type msdnLicenseTypeValuesType struct { + None MsdnLicenseType + Eligible MsdnLicenseType + Professional MsdnLicenseType + Platforms MsdnLicenseType + TestProfessional MsdnLicenseType + Premium MsdnLicenseType + Ultimate MsdnLicenseType + Enterprise MsdnLicenseType +} + +var MsdnLicenseTypeValues = msdnLicenseTypeValuesType{ + None: "none", + Eligible: "eligible", + Professional: "professional", + Platforms: "platforms", + TestProfessional: "testProfessional", + Premium: "premium", + Ultimate: "ultimate", + Enterprise: "enterprise", +} + +type NoLicense struct { + // Gets the source of the license + Source *LicensingSource `json:"source,omitempty"` +} + +type VisualStudioOnlineServiceLevel string + +type visualStudioOnlineServiceLevelValuesType struct { + None VisualStudioOnlineServiceLevel + Express VisualStudioOnlineServiceLevel + Advanced VisualStudioOnlineServiceLevel + AdvancedPlus VisualStudioOnlineServiceLevel + Stakeholder VisualStudioOnlineServiceLevel +} + +var VisualStudioOnlineServiceLevelValues = visualStudioOnlineServiceLevelValuesType{ + // No service rights. The user cannot access the account + None: "none", + // Default or minimum service level + Express: "express", + // Premium service level - either by purchasing on the Azure portal or by purchasing the appropriate MSDN subscription + Advanced: "advanced", + // Only available to a specific set of MSDN Subscribers + AdvancedPlus: "advancedPlus", + // Stakeholder service level + Stakeholder: "stakeholder", +} diff --git a/azuredevops/licensingrule/models.go b/azuredevops/licensingrule/models.go new file mode 100644 index 00000000..e3b7c383 --- /dev/null +++ b/azuredevops/licensingrule/models.go @@ -0,0 +1,127 @@ +// -------------------------------------------------------------------------------------------- +// 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 licensingrule + +import ( + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/licensing" + "github.com/microsoft/azure-devops-go-api/azuredevops/operations" +) + +type ApplicationStatus struct { + Extensions *[]ExtensionApplicationStatus `json:"extensions,omitempty"` + IsTruncated *bool `json:"isTruncated,omitempty"` + Licenses *[]LicenseApplicationStatus `json:"licenses,omitempty"` + Option *RuleOption `json:"option,omitempty"` + Status *operations.OperationStatus `json:"status,omitempty"` +} + +type ExtensionApplicationStatus struct { + Assigned *int `json:"assigned,omitempty"` + Failed *int `json:"failed,omitempty"` + InsufficientResources *int `json:"insufficientResources,omitempty"` + ExtensionId *string `json:"extensionId,omitempty"` + Incompatible *int `json:"incompatible,omitempty"` + Unassigned *int `json:"unassigned,omitempty"` +} + +// Represents an Extension Rule +type ExtensionRule struct { + // Extension Id + ExtensionId *string `json:"extensionId,omitempty"` + // Status of the group rule (applied, missing licenses, etc) + Status *GroupLicensingRuleStatus `json:"status,omitempty"` +} + +// Batching of subjects to lookup using the Graph API +type GraphSubjectLookup struct { + LookupKeys *[]GraphSubjectLookupKey `json:"lookupKeys,omitempty"` +} + +type GraphSubjectLookupKey struct { + Descriptor *string `json:"descriptor,omitempty"` +} + +// Represents a GroupLicensingRule +type GroupLicensingRule struct { + // Extension Rules + ExtensionRules *[]ExtensionRule `json:"extensionRules,omitempty"` + // License Rule + LicenseRule *LicenseRule `json:"licenseRule,omitempty"` + // SubjectDescriptor for the rule + SubjectDescriptor *string `json:"subjectDescriptor,omitempty"` +} + +type GroupLicensingRuleStatus string + +type groupLicensingRuleStatusValuesType struct { + ApplyPending GroupLicensingRuleStatus + Applied GroupLicensingRuleStatus + Incompatible GroupLicensingRuleStatus + UnableToApply GroupLicensingRuleStatus +} + +var GroupLicensingRuleStatusValues = groupLicensingRuleStatusValuesType{ + // Rule is created or updated, but apply is pending + ApplyPending: "applyPending", + // Rule is applied + Applied: "applied", + // The group rule was incompatible + Incompatible: "incompatible", + // Rule failed to apply unexpectedly and should be retried + UnableToApply: "unableToApply", +} + +// Represents an GroupLicensingRuleUpdate Model +type GroupLicensingRuleUpdate struct { + // Extensions to Add + ExtensionsToAdd *[]string `json:"extensionsToAdd,omitempty"` + // Extensions to Remove + ExtensionsToRemove *[]string `json:"extensionsToRemove,omitempty"` + // New License + License *licensing.License `json:"license,omitempty"` + // SubjectDescriptor for the rule + SubjectDescriptor *string `json:"subjectDescriptor,omitempty"` +} + +type LicenseApplicationStatus struct { + Assigned *int `json:"assigned,omitempty"` + Failed *int `json:"failed,omitempty"` + InsufficientResources *int `json:"insufficientResources,omitempty"` + AccountUserLicense *licensing.AccountUserLicense `json:"accountUserLicense,omitempty"` + License *licensing.License `json:"license,omitempty"` +} + +// Represents a License Rule +type LicenseRule struct { + // The last time the rule was executed (regardless of whether any changes were made) + LastExecuted *azuredevops.Time `json:"lastExecuted,omitempty"` + // License + License *licensing.License `json:"license,omitempty"` + // Status of the group rule (applied, missing licenses, etc) + Status *GroupLicensingRuleStatus `json:"status,omitempty"` +} + +type LicensingApplicationStatus struct { + Assigned *int `json:"assigned,omitempty"` + Failed *int `json:"failed,omitempty"` + InsufficientResources *int `json:"insufficientResources,omitempty"` +} + +type RuleOption string + +type ruleOptionValuesType struct { + ApplyGroupRule RuleOption + TestApplyGroupRule RuleOption +} + +var RuleOptionValues = ruleOptionValuesType{ + ApplyGroupRule: "applyGroupRule", + TestApplyGroupRule: "testApplyGroupRule", +} diff --git a/azuredevops/location/client.go b/azuredevops/location/client.go new file mode 100644 index 00000000..cae74ed3 --- /dev/null +++ b/azuredevops/location/client.go @@ -0,0 +1,325 @@ +// -------------------------------------------------------------------------------------------- +// 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 location + +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/webapi" + "net/http" + "net/url" + "strconv" +) + +type Client interface { + // [Preview API] + DeleteServiceDefinition(context.Context, DeleteServiceDefinitionArgs) error + // [Preview API] This was copied and adapted from TeamFoundationConnectionService.Connect() + GetConnectionData(context.Context, GetConnectionDataArgs) (*ConnectionData, error) + // [Preview API] + GetResourceArea(context.Context, GetResourceAreaArgs) (*ResourceAreaInfo, error) + // [Preview API] + GetResourceAreaByHost(context.Context, GetResourceAreaByHostArgs) (*ResourceAreaInfo, error) + // [Preview API] + GetResourceAreas(context.Context, GetResourceAreasArgs) (*[]ResourceAreaInfo, error) + // [Preview API] + GetResourceAreasByHost(context.Context, GetResourceAreasByHostArgs) (*[]ResourceAreaInfo, error) + // [Preview API] Finds a given service definition. + GetServiceDefinition(context.Context, GetServiceDefinitionArgs) (*ServiceDefinition, error) + // [Preview API] + GetServiceDefinitions(context.Context, GetServiceDefinitionsArgs) (*[]ServiceDefinition, error) + // [Preview API] + UpdateServiceDefinitions(context.Context, UpdateServiceDefinitionsArgs) 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, + } +} + +// [Preview API] +func (client *ClientImpl) DeleteServiceDefinition(ctx context.Context, args DeleteServiceDefinitionArgs) error { + routeValues := make(map[string]string) + if args.ServiceType == nil || *args.ServiceType == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ServiceType"} + } + routeValues["serviceType"] = *args.ServiceType + if args.Identifier == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Identifier"} + } + routeValues["identifier"] = (*args.Identifier).String() + + locationId, _ := uuid.Parse("d810a47d-f4f4-4a62-a03f-fa1860585c4c") + _, 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 DeleteServiceDefinition function +type DeleteServiceDefinitionArgs struct { + // (required) + ServiceType *string + // (required) + Identifier *uuid.UUID +} + +// [Preview API] This was copied and adapted from TeamFoundationConnectionService.Connect() +func (client *ClientImpl) GetConnectionData(ctx context.Context, args GetConnectionDataArgs) (*ConnectionData, error) { + queryParams := url.Values{} + if args.ConnectOptions != nil { + queryParams.Add("connectOptions", string(*args.ConnectOptions)) + } + if args.LastChangeId != nil { + queryParams.Add("lastChangeId", strconv.Itoa(*args.LastChangeId)) + } + if args.LastChangeId64 != nil { + queryParams.Add("lastChangeId64", strconv.FormatUint(*args.LastChangeId64, 10)) + } + locationId, _ := uuid.Parse("00d9565f-ed9c-4a06-9a50-00e7896ccab4") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ConnectionData + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetConnectionData function +type GetConnectionDataArgs struct { + // (optional) + ConnectOptions *webapi.ConnectOptions + // (optional) Obsolete 32-bit LastChangeId + LastChangeId *int + // (optional) Non-truncated 64-bit LastChangeId + LastChangeId64 *uint64 +} + +// [Preview API] +func (client *ClientImpl) GetResourceArea(ctx context.Context, args GetResourceAreaArgs) (*ResourceAreaInfo, error) { + routeValues := make(map[string]string) + if args.AreaId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AreaId"} + } + routeValues["areaId"] = (*args.AreaId).String() + + queryParams := url.Values{} + if args.EnterpriseName != nil { + queryParams.Add("enterpriseName", *args.EnterpriseName) + } + if args.OrganizationName != nil { + queryParams.Add("organizationName", *args.OrganizationName) + } + locationId, _ := uuid.Parse("e81700f7-3be2-46de-8624-2eb35882fcaa") + 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 ResourceAreaInfo + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetResourceArea function +type GetResourceAreaArgs struct { + // (required) + AreaId *uuid.UUID + // (optional) + EnterpriseName *string + // (optional) + OrganizationName *string +} + +// [Preview API] +func (client *ClientImpl) GetResourceAreaByHost(ctx context.Context, args GetResourceAreaByHostArgs) (*ResourceAreaInfo, error) { + routeValues := make(map[string]string) + if args.AreaId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AreaId"} + } + routeValues["areaId"] = (*args.AreaId).String() + + queryParams := url.Values{} + if args.HostId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "hostId"} + } + queryParams.Add("hostId", (*args.HostId).String()) + locationId, _ := uuid.Parse("e81700f7-3be2-46de-8624-2eb35882fcaa") + 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 ResourceAreaInfo + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetResourceAreaByHost function +type GetResourceAreaByHostArgs struct { + // (required) + AreaId *uuid.UUID + // (required) + HostId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) GetResourceAreas(ctx context.Context, args GetResourceAreasArgs) (*[]ResourceAreaInfo, error) { + queryParams := url.Values{} + if args.EnterpriseName != nil { + queryParams.Add("enterpriseName", *args.EnterpriseName) + } + if args.OrganizationName != nil { + queryParams.Add("organizationName", *args.OrganizationName) + } + locationId, _ := uuid.Parse("e81700f7-3be2-46de-8624-2eb35882fcaa") + resp, err := client.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.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetResourceAreas function +type GetResourceAreasArgs struct { + // (optional) + EnterpriseName *string + // (optional) + OrganizationName *string +} + +// [Preview API] +func (client *ClientImpl) GetResourceAreasByHost(ctx context.Context, args GetResourceAreasByHostArgs) (*[]ResourceAreaInfo, error) { + queryParams := url.Values{} + if args.HostId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "hostId"} + } + queryParams.Add("hostId", (*args.HostId).String()) + locationId, _ := uuid.Parse("e81700f7-3be2-46de-8624-2eb35882fcaa") + resp, err := client.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.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetResourceAreasByHost function +type GetResourceAreasByHostArgs struct { + // (required) + HostId *uuid.UUID +} + +// [Preview API] Finds a given service definition. +func (client *ClientImpl) GetServiceDefinition(ctx context.Context, args GetServiceDefinitionArgs) (*ServiceDefinition, error) { + routeValues := make(map[string]string) + if args.ServiceType == nil || *args.ServiceType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ServiceType"} + } + routeValues["serviceType"] = *args.ServiceType + if args.Identifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Identifier"} + } + routeValues["identifier"] = (*args.Identifier).String() + + queryParams := url.Values{} + if args.AllowFaultIn != nil { + queryParams.Add("allowFaultIn", strconv.FormatBool(*args.AllowFaultIn)) + } + if args.PreviewFaultIn != nil { + queryParams.Add("previewFaultIn", strconv.FormatBool(*args.PreviewFaultIn)) + } + locationId, _ := uuid.Parse("d810a47d-f4f4-4a62-a03f-fa1860585c4c") + 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 ServiceDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetServiceDefinition function +type GetServiceDefinitionArgs struct { + // (required) + ServiceType *string + // (required) + Identifier *uuid.UUID + // (optional) If true, we will attempt to fault in a host instance mapping if in SPS. + AllowFaultIn *bool + // (optional) If true, we will calculate and return a host instance mapping, but not persist it. + PreviewFaultIn *bool +} + +// [Preview API] +func (client *ClientImpl) GetServiceDefinitions(ctx context.Context, args GetServiceDefinitionsArgs) (*[]ServiceDefinition, error) { + routeValues := make(map[string]string) + if args.ServiceType != nil && *args.ServiceType != "" { + routeValues["serviceType"] = *args.ServiceType + } + + locationId, _ := uuid.Parse("d810a47d-f4f4-4a62-a03f-fa1860585c4c") + 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 []ServiceDefinition + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetServiceDefinitions function +type GetServiceDefinitionsArgs struct { + // (optional) + ServiceType *string +} + +// [Preview API] +func (client *ClientImpl) UpdateServiceDefinitions(ctx context.Context, args UpdateServiceDefinitionsArgs) error { + if args.ServiceDefinitions == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ServiceDefinitions"} + } + body, marshalErr := json.Marshal(*args.ServiceDefinitions) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("d810a47d-f4f4-4a62-a03f-fa1860585c4c") + _, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the UpdateServiceDefinitions function +type UpdateServiceDefinitionsArgs struct { + // (required) + ServiceDefinitions *azuredevops.VssJsonCollectionWrapper +} diff --git a/azuredevops/location/models.go b/azuredevops/location/models.go new file mode 100644 index 00000000..9b0220fb --- /dev/null +++ b/azuredevops/location/models.go @@ -0,0 +1,149 @@ +// -------------------------------------------------------------------------------------------- +// 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 location + +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 AccessMapping struct { + AccessPoint *string `json:"accessPoint,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Moniker *string `json:"moniker,omitempty"` + // The service which owns this access mapping e.g. TFS, ELS, etc. + ServiceOwner *uuid.UUID `json:"serviceOwner,omitempty"` + // Part of the access mapping which applies context after the access point of the server. + VirtualDirectory *string `json:"virtualDirectory,omitempty"` +} + +// Data transfer class that holds information needed to set up a connection with a VSS server. +type ConnectionData struct { + // The Id of the authenticated user who made this request. More information about the user can be obtained by passing this Id to the Identity service + AuthenticatedUser *identity.Identity `json:"authenticatedUser,omitempty"` + // The Id of the authorized user who made this request. More information about the user can be obtained by passing this Id to the Identity service + AuthorizedUser *identity.Identity `json:"authorizedUser,omitempty"` + // The id for the server. + DeploymentId *uuid.UUID `json:"deploymentId,omitempty"` + // The type for the server Hosted/OnPremises. + DeploymentType *webapi.DeploymentFlags `json:"deploymentType,omitempty"` + // The instance id for this host. + InstanceId *uuid.UUID `json:"instanceId,omitempty"` + // The last user access for this instance. Null if not requested specifically. + LastUserAccess *azuredevops.Time `json:"lastUserAccess,omitempty"` + // Data that the location service holds. + LocationServiceData *LocationServiceData `json:"locationServiceData,omitempty"` + // The virtual directory of the host we are talking to. + WebApplicationRelativeDirectory *string `json:"webApplicationRelativeDirectory,omitempty"` +} + +type InheritLevel string + +type inheritLevelValuesType struct { + None InheritLevel + Deployment InheritLevel + Account InheritLevel + Collection InheritLevel + All InheritLevel +} + +var InheritLevelValues = inheritLevelValuesType{ + None: "none", + Deployment: "deployment", + Account: "account", + Collection: "collection", + All: "all", +} + +type LocationMapping struct { + AccessMappingMoniker *string `json:"accessMappingMoniker,omitempty"` + Location *string `json:"location,omitempty"` +} + +// Data transfer class used to transfer data about the location service data over the web service. +type LocationServiceData struct { + // Data about the access mappings contained by this location service. + AccessMappings *[]AccessMapping `json:"accessMappings,omitempty"` + // Data that the location service holds. + ClientCacheFresh *bool `json:"clientCacheFresh,omitempty"` + // The time to live on the location service cache. + ClientCacheTimeToLive *int `json:"clientCacheTimeToLive,omitempty"` + // The default access mapping moniker for the server. + DefaultAccessMappingMoniker *string `json:"defaultAccessMappingMoniker,omitempty"` + // The obsolete id for the last change that took place on the server (use LastChangeId64). + LastChangeId *int `json:"lastChangeId,omitempty"` + // The non-truncated 64-bit id for the last change that took place on the server. + LastChangeId64 *uint64 `json:"lastChangeId64,omitempty"` + // Data about the service definitions contained by this location service. + ServiceDefinitions *[]ServiceDefinition `json:"serviceDefinitions,omitempty"` + // The identifier of the deployment which is hosting this location data (e.g. SPS, TFS, ELS, Napa, etc.) + ServiceOwner *uuid.UUID `json:"serviceOwner,omitempty"` +} + +type RelativeToSetting string + +type relativeToSettingValuesType struct { + Context RelativeToSetting + WebApplication RelativeToSetting + FullyQualified RelativeToSetting +} + +var RelativeToSettingValues = relativeToSettingValuesType{ + Context: "context", + WebApplication: "webApplication", + FullyQualified: "fullyQualified", +} + +type ResourceAreaInfo struct { + Id *uuid.UUID `json:"id,omitempty"` + LocationUrl *string `json:"locationUrl,omitempty"` + Name *string `json:"name,omitempty"` +} + +type ServiceDefinition struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Identifier *uuid.UUID `json:"identifier,omitempty"` + InheritLevel *InheritLevel `json:"inheritLevel,omitempty"` + LocationMappings *[]LocationMapping `json:"locationMappings,omitempty"` + // Maximum api version that this resource supports (current server version for this resource). Copied from ApiResourceLocation. + MaxVersion *string `json:"maxVersion,omitempty"` + // Minimum api version that this resource supports. Copied from ApiResourceLocation. + MinVersion *string `json:"minVersion,omitempty"` + ParentIdentifier *uuid.UUID `json:"parentIdentifier,omitempty"` + ParentServiceType *string `json:"parentServiceType,omitempty"` + Properties interface{} `json:"properties,omitempty"` + RelativePath *string `json:"relativePath,omitempty"` + RelativeToSetting *RelativeToSetting `json:"relativeToSetting,omitempty"` + // The latest version of this resource location that is in "Release" (non-preview) mode. Copied from ApiResourceLocation. + ReleasedVersion *string `json:"releasedVersion,omitempty"` + // The current resource version supported by this resource location. Copied from ApiResourceLocation. + ResourceVersion *int `json:"resourceVersion,omitempty"` + // The service which owns this definition e.g. TFS, ELS, etc. + ServiceOwner *uuid.UUID `json:"serviceOwner,omitempty"` + ServiceType *string `json:"serviceType,omitempty"` + Status *ServiceStatus `json:"status,omitempty"` + ToolId *string `json:"toolId,omitempty"` +} + +type ServiceStatus string + +type serviceStatusValuesType struct { + Assigned ServiceStatus + Active ServiceStatus + Moving ServiceStatus +} + +var ServiceStatusValues = serviceStatusValuesType{ + Assigned: "assigned", + Active: "active", + Moving: "moving", +} diff --git a/azuredevops/maven/client.go b/azuredevops/maven/client.go new file mode 100644 index 00000000..e37a511a --- /dev/null +++ b/azuredevops/maven/client.go @@ -0,0 +1,354 @@ +// -------------------------------------------------------------------------------------------- +// 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 maven + +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("6f7f8c07-ff36-473c-bcf3-bd6cc9b6c066") + +type Client interface { + // [Preview API] Permanently delete a package from a feed's recycle bin. + DeletePackageVersionFromRecycleBin(context.Context, DeletePackageVersionFromRecycleBinArgs) error + // [Preview API] Fulfills Maven package file download requests by either returning the URL of the requested package file or, in the case of Azure DevOps Server (OnPrem), returning the content as a stream. + DownloadPackage(context.Context, DownloadPackageArgs) (interface{}, error) + // [Preview API] Get information about a package version. + GetPackageVersion(context.Context, GetPackageVersionArgs) (*Package, error) + // [Preview API] Get information about a package version in the recycle bin. + GetPackageVersionMetadataFromRecycleBin(context.Context, GetPackageVersionMetadataFromRecycleBinArgs) (*MavenPackageVersionDeletionState, error) + // [Preview API] Delete a package version from the feed and move it to the feed's recycle bin. + PackageDelete(context.Context, PackageDeleteArgs) error + // [Preview API] Restore a package version from the recycle bin to its associated feed. + RestorePackageVersionFromRecycleBin(context.Context, RestorePackageVersionFromRecycleBinArgs) 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] Permanently delete a package from a feed's recycle bin. +func (client *ClientImpl) DeletePackageVersionFromRecycleBin(ctx context.Context, args DeletePackageVersionFromRecycleBinArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Feed == nil || *args.Feed == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Feed"} + } + routeValues["feed"] = *args.Feed + if args.GroupId == nil || *args.GroupId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + if args.ArtifactId == nil || *args.ArtifactId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ArtifactId"} + } + routeValues["artifactId"] = *args.ArtifactId + if args.Version == nil || *args.Version == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + + locationId, _ := uuid.Parse("f67e10eb-1254-4953-add7-d49b83a16c9f") + _, 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 DeletePackageVersionFromRecycleBin function +type DeletePackageVersionFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + Feed *string + // (required) Group ID of the package. + GroupId *string + // (required) Artifact ID of the package. + ArtifactId *string + // (required) Version of the package. + Version *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Fulfills Maven package file download requests by either returning the URL of the requested package file or, in the case of Azure DevOps Server (OnPrem), returning the content as a stream. +func (client *ClientImpl) DownloadPackage(ctx context.Context, args DownloadPackageArgs) (interface{}, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.GroupId == nil || *args.GroupId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + if args.ArtifactId == nil || *args.ArtifactId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ArtifactId"} + } + routeValues["artifactId"] = *args.ArtifactId + if args.Version == nil || *args.Version == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + if args.FileName == nil || *args.FileName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FileName"} + } + routeValues["fileName"] = *args.FileName + + locationId, _ := uuid.Parse("c338d4b5-d30a-47e2-95b7-f157ef558833") + 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 DownloadPackage function +type DownloadPackageArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) GroupId of the maven package + GroupId *string + // (required) ArtifactId of the maven package + ArtifactId *string + // (required) Version of the package + Version *string + // (required) File name to download + FileName *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get information about a package version. +func (client *ClientImpl) GetPackageVersion(ctx context.Context, args GetPackageVersionArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Feed == nil || *args.Feed == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Feed"} + } + routeValues["feed"] = *args.Feed + if args.GroupId == nil || *args.GroupId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + if args.ArtifactId == nil || *args.ArtifactId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ArtifactId"} + } + routeValues["artifactId"] = *args.ArtifactId + if args.Version == nil || *args.Version == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + + queryParams := url.Values{} + if args.ShowDeleted != nil { + queryParams.Add("showDeleted", strconv.FormatBool(*args.ShowDeleted)) + } + locationId, _ := uuid.Parse("180ed967-377a-4112-986b-607adb14ded4") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersion function +type GetPackageVersionArgs struct { + // (required) Name or ID of the feed. + Feed *string + // (required) Group ID of the package. + GroupId *string + // (required) Artifact ID of the package. + ArtifactId *string + // (required) Version of the package. + Version *string + // (optional) Project ID or project name + Project *string + // (optional) True to show information for deleted packages. + ShowDeleted *bool +} + +// [Preview API] Get information about a package version in the recycle bin. +func (client *ClientImpl) GetPackageVersionMetadataFromRecycleBin(ctx context.Context, args GetPackageVersionMetadataFromRecycleBinArgs) (*MavenPackageVersionDeletionState, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Feed == nil || *args.Feed == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Feed"} + } + routeValues["feed"] = *args.Feed + if args.GroupId == nil || *args.GroupId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + if args.ArtifactId == nil || *args.ArtifactId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ArtifactId"} + } + routeValues["artifactId"] = *args.ArtifactId + if args.Version == nil || *args.Version == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + + locationId, _ := uuid.Parse("f67e10eb-1254-4953-add7-d49b83a16c9f") + 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 MavenPackageVersionDeletionState + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersionMetadataFromRecycleBin function +type GetPackageVersionMetadataFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + Feed *string + // (required) Group ID of the package. + GroupId *string + // (required) Artifact ID of the package. + ArtifactId *string + // (required) Version of the package. + Version *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Delete a package version from the feed and move it to the feed's recycle bin. +func (client *ClientImpl) PackageDelete(ctx context.Context, args PackageDeleteArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Feed == nil || *args.Feed == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Feed"} + } + routeValues["feed"] = *args.Feed + if args.GroupId == nil || *args.GroupId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + if args.ArtifactId == nil || *args.ArtifactId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ArtifactId"} + } + routeValues["artifactId"] = *args.ArtifactId + if args.Version == nil || *args.Version == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + + locationId, _ := uuid.Parse("180ed967-377a-4112-986b-607adb14ded4") + _, 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 PackageDelete function +type PackageDeleteArgs struct { + // (required) Name or ID of the feed. + Feed *string + // (required) Group ID of the package. + GroupId *string + // (required) Artifact ID of the package. + ArtifactId *string + // (required) Version of the package. + Version *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Restore a package version from the recycle bin to its associated feed. +func (client *ClientImpl) RestorePackageVersionFromRecycleBin(ctx context.Context, args RestorePackageVersionFromRecycleBinArgs) error { + if args.PackageVersionDetails == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionDetails"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Feed == nil || *args.Feed == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Feed"} + } + routeValues["feed"] = *args.Feed + if args.GroupId == nil || *args.GroupId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + if args.ArtifactId == nil || *args.ArtifactId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ArtifactId"} + } + routeValues["artifactId"] = *args.ArtifactId + if args.Version == nil || *args.Version == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Version"} + } + routeValues["version"] = *args.Version + + body, marshalErr := json.Marshal(*args.PackageVersionDetails) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("f67e10eb-1254-4953-add7-d49b83a16c9f") + _, 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 err + } + + return nil +} + +// Arguments for the RestorePackageVersionFromRecycleBin function +type RestorePackageVersionFromRecycleBinArgs struct { + // (required) Set the 'Deleted' property to false to restore the package. + PackageVersionDetails *MavenRecycleBinPackageVersionDetails + // (required) Name or ID of the feed. + Feed *string + // (required) Group ID of the package. + GroupId *string + // (required) Artifact ID of the package. + ArtifactId *string + // (required) Version of the package. + Version *string + // (optional) Project ID or project name + Project *string +} diff --git a/azuredevops/maven/models.go b/azuredevops/maven/models.go new file mode 100644 index 00000000..a674a439 --- /dev/null +++ b/azuredevops/maven/models.go @@ -0,0 +1,245 @@ +// -------------------------------------------------------------------------------------------- +// 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 maven + +import ( + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/packagingshared" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type MavenBatchOperationType string + +type mavenBatchOperationTypeValuesType struct { + Promote MavenBatchOperationType + Delete MavenBatchOperationType + PermanentDelete MavenBatchOperationType + RestoreToFeed MavenBatchOperationType +} + +var MavenBatchOperationTypeValues = mavenBatchOperationTypeValuesType{ + // Promote package versions to a release view. If constructing a MavenPackagesBatchRequest object with this type, use BatchPromoteData for its Data property. Not supported in the Recycle Bin. + Promote: "promote", + // Delete package versions. Not supported in the Recycle Bin. + Delete: "delete", + // Permanently delete package versions. Only supported in the Recycle Bin. + PermanentDelete: "permanentDelete", + // Restore unpublished package versions to the feed. Only supported in the Recycle Bin. + RestoreToFeed: "restoreToFeed", +} + +type MavenDistributionManagement struct { + Repository *MavenRepository `json:"repository,omitempty"` + SnapshotRepository *MavenSnapshotRepository `json:"snapshotRepository,omitempty"` +} + +// Identifies a particular Maven package version +type MavenMinimalPackageDetails struct { + // Package artifact ID + Artifact *string `json:"artifact,omitempty"` + // Package group ID + Group *string `json:"group,omitempty"` + // Package version + Version *string `json:"version,omitempty"` +} + +type MavenPackage struct { + ArtifactId *string `json:"artifactId,omitempty"` + ArtifactIndex *webapi.ReferenceLink `json:"artifactIndex,omitempty"` + ArtifactMetadata *webapi.ReferenceLink `json:"artifactMetadata,omitempty"` + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + Files interface{} `json:"files,omitempty"` + GroupId *string `json:"groupId,omitempty"` + Pom *MavenPomMetadata `json:"pom,omitempty"` + RequestedFile *webapi.ReferenceLink `json:"requestedFile,omitempty"` + SnapshotMetadata *webapi.ReferenceLink `json:"snapshotMetadata,omitempty"` + Version *string `json:"version,omitempty"` + Versions interface{} `json:"versions,omitempty"` + VersionsIndex *webapi.ReferenceLink `json:"versionsIndex,omitempty"` +} + +// A batch of operations to apply to package versions. +type MavenPackagesBatchRequest struct { + // Data required to perform the operation. This is optional based on type of operation. Use BatchPromoteData if performing a promote operation. + Data interface{} `json:"data,omitempty"` + // Type of operation that needs to be performed on packages. + Operation *MavenBatchOperationType `json:"operation,omitempty"` + // The packages onto which the operation will be performed. + Packages *[]MavenMinimalPackageDetails `json:"packages,omitempty"` +} + +// Deletion state of a maven package. +type MavenPackageVersionDeletionState struct { + // Artifact Id of the package. + ArtifactId *string `json:"artifactId,omitempty"` + // UTC date the package was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Group Id of the package. + GroupId *string `json:"groupId,omitempty"` + // Version of the package. + Version *string `json:"version,omitempty"` +} + +type MavenPomBuild struct { + Plugins *[]Plugin `json:"plugins,omitempty"` +} + +type MavenPomCi struct { + Notifiers *[]MavenPomCiNotifier `json:"notifiers,omitempty"` + System *string `json:"system,omitempty"` + Url *string `json:"url,omitempty"` +} + +type MavenPomCiNotifier struct { + Configuration *[]string `json:"configuration,omitempty"` + SendOnError *string `json:"sendOnError,omitempty"` + SendOnFailure *string `json:"sendOnFailure,omitempty"` + SendOnSuccess *string `json:"sendOnSuccess,omitempty"` + SendOnWarning *string `json:"sendOnWarning,omitempty"` + Type *string `json:"type,omitempty"` +} + +type MavenPomDependency struct { + ArtifactId *string `json:"artifactId,omitempty"` + GroupId *string `json:"groupId,omitempty"` + Version *string `json:"version,omitempty"` + Optional *bool `json:"optional,omitempty"` + Scope *string `json:"scope,omitempty"` + Type *string `json:"type,omitempty"` +} + +type MavenPomDependencyManagement struct { + Dependencies *[]MavenPomDependency `json:"dependencies,omitempty"` +} + +type MavenPomGav struct { + ArtifactId *string `json:"artifactId,omitempty"` + GroupId *string `json:"groupId,omitempty"` + Version *string `json:"version,omitempty"` +} + +type MavenPomIssueManagement struct { + System *string `json:"system,omitempty"` + Url *string `json:"url,omitempty"` +} + +type MavenPomLicense struct { + Name *string `json:"name,omitempty"` + Url *string `json:"url,omitempty"` + Distribution *string `json:"distribution,omitempty"` +} + +type MavenPomMailingList struct { + Archive *string `json:"archive,omitempty"` + Name *string `json:"name,omitempty"` + OtherArchives *[]string `json:"otherArchives,omitempty"` + Post *string `json:"post,omitempty"` + Subscribe *string `json:"subscribe,omitempty"` + Unsubscribe *string `json:"unsubscribe,omitempty"` +} + +type MavenPomMetadata struct { + ArtifactId *string `json:"artifactId,omitempty"` + GroupId *string `json:"groupId,omitempty"` + Version *string `json:"version,omitempty"` + Build *MavenPomBuild `json:"build,omitempty"` + CiManagement *MavenPomCi `json:"ciManagement,omitempty"` + Contributors *[]MavenPomPerson `json:"contributors,omitempty"` + Dependencies *[]MavenPomDependency `json:"dependencies,omitempty"` + DependencyManagement *MavenPomDependencyManagement `json:"dependencyManagement,omitempty"` + Description *string `json:"description,omitempty"` + Developers *[]MavenPomPerson `json:"developers,omitempty"` + DistributionManagement *MavenDistributionManagement `json:"distributionManagement,omitempty"` + InceptionYear *string `json:"inceptionYear,omitempty"` + IssueManagement *MavenPomIssueManagement `json:"issueManagement,omitempty"` + Licenses *[]MavenPomLicense `json:"licenses,omitempty"` + MailingLists *[]MavenPomMailingList `json:"mailingLists,omitempty"` + ModelVersion *string `json:"modelVersion,omitempty"` + Modules *[]string `json:"modules,omitempty"` + Name *string `json:"name,omitempty"` + Organization *MavenPomOrganization `json:"organization,omitempty"` + Packaging *string `json:"packaging,omitempty"` + Parent *MavenPomParent `json:"parent,omitempty"` + Prerequisites *map[string]string `json:"prerequisites,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Scm *MavenPomScm `json:"scm,omitempty"` + Url *string `json:"url,omitempty"` +} + +type MavenPomOrganization struct { + Name *string `json:"name,omitempty"` + Url *string `json:"url,omitempty"` +} + +type MavenPomParent struct { + ArtifactId *string `json:"artifactId,omitempty"` + GroupId *string `json:"groupId,omitempty"` + Version *string `json:"version,omitempty"` + RelativePath *string `json:"relativePath,omitempty"` +} + +type MavenPomPerson struct { + Email *string `json:"email,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Organization *string `json:"organization,omitempty"` + OrganizationUrl *string `json:"organizationUrl,omitempty"` + Roles *[]string `json:"roles,omitempty"` + Timezone *string `json:"timezone,omitempty"` + Url *string `json:"url,omitempty"` +} + +type MavenPomScm struct { + Connection *string `json:"connection,omitempty"` + DeveloperConnection *string `json:"developerConnection,omitempty"` + Tag *string `json:"tag,omitempty"` + Url *string `json:"url,omitempty"` +} + +type MavenRecycleBinPackageVersionDetails struct { + // Setting to false will undo earlier deletion and restore the package to feed. + Deleted *bool `json:"deleted,omitempty"` +} + +type MavenRepository struct { + UniqueVersion *bool `json:"uniqueVersion,omitempty"` +} + +type MavenSnapshotRepository struct { + UniqueVersion *bool `json:"uniqueVersion,omitempty"` +} + +// Package version metadata for a Maven package +type Package struct { + // Related REST links. + Links interface{} `json:"_links,omitempty"` + // If and when the package was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Package Id. + Id *string `json:"id,omitempty"` + // The display name of the package. + Name *string `json:"name,omitempty"` + // If and when the package was permanently deleted. + PermanentlyDeletedDate *azuredevops.Time `json:"permanentlyDeletedDate,omitempty"` + // The history of upstream sources for this package. The first source in the list is the immediate source from which this package was saved. + SourceChain *[]packagingshared.UpstreamSourceInfo `json:"sourceChain,omitempty"` + // The version of the package. + Version *string `json:"version,omitempty"` +} + +type Plugin struct { + ArtifactId *string `json:"artifactId,omitempty"` + GroupId *string `json:"groupId,omitempty"` + Version *string `json:"version,omitempty"` + Configuration *PluginConfiguration `json:"configuration,omitempty"` +} + +type PluginConfiguration struct { + GoalPrefix *string `json:"goalPrefix,omitempty"` +} diff --git a/azuredevops/memberentitlementmanagement/client.go b/azuredevops/memberentitlementmanagement/client.go new file mode 100644 index 00000000..b57b176c --- /dev/null +++ b/azuredevops/memberentitlementmanagement/client.go @@ -0,0 +1,516 @@ +// -------------------------------------------------------------------------------------------- +// 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 memberentitlementmanagement + +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/licensingrule" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("68ddce18-2501-45f1-a17b-7931a9922690") + +type Client interface { + // [Preview API] Create a group entitlement with license rule, extension rule. + AddGroupEntitlement(context.Context, AddGroupEntitlementArgs) (*GroupEntitlementOperationReference, error) + // [Preview API] Add a member to a Group. + AddMemberToGroup(context.Context, AddMemberToGroupArgs) error + // [Preview API] Add a user, assign license and extensions and make them a member of a project group in an account. + AddUserEntitlement(context.Context, AddUserEntitlementArgs) (*UserEntitlementsPostResponse, error) + // [Preview API] Delete a group entitlement. + DeleteGroupEntitlement(context.Context, DeleteGroupEntitlementArgs) (*GroupEntitlementOperationReference, error) + // [Preview API] Delete a user from the account. + DeleteUserEntitlement(context.Context, DeleteUserEntitlementArgs) error + // [Preview API] Get a group entitlement. + GetGroupEntitlement(context.Context, GetGroupEntitlementArgs) (*GroupEntitlement, error) + // [Preview API] Get the group entitlements for an account. + GetGroupEntitlements(context.Context, GetGroupEntitlementsArgs) (*[]GroupEntitlement, error) + // [Preview API] Get direct members of a Group. + GetGroupMembers(context.Context, GetGroupMembersArgs) (*PagedGraphMemberList, error) + // [Preview API] Get User Entitlement for a user. + GetUserEntitlement(context.Context, GetUserEntitlementArgs) (*UserEntitlement, error) + // [Preview API] Get a paged set of user entitlements matching the filter criteria. If no filter is is passed, a page from all the account users is returned. + GetUserEntitlements(context.Context, GetUserEntitlementsArgs) (*PagedGraphMemberList, error) + // [Preview API] Get summary of Licenses, Extension, Projects, Groups and their assignments in the collection. + GetUsersSummary(context.Context, GetUsersSummaryArgs) (*UsersSummary, error) + // [Preview API] Remove a member from a Group. + RemoveMemberFromGroup(context.Context, RemoveMemberFromGroupArgs) error + // [Preview API] Update entitlements (License Rule, Extensions Rule, Project memberships etc.) for a group. + UpdateGroupEntitlement(context.Context, UpdateGroupEntitlementArgs) (*GroupEntitlementOperationReference, error) + // [Preview API] Edit the entitlements (License, Extensions, Projects, Teams etc) for a user. + UpdateUserEntitlement(context.Context, UpdateUserEntitlementArgs) (*UserEntitlementsPatchResponse, error) + // [Preview API] Edit the entitlements (License, Extensions, Projects, Teams etc) for one or more users. + UpdateUserEntitlements(context.Context, UpdateUserEntitlementsArgs) (*UserEntitlementOperationReference, 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 a group entitlement with license rule, extension rule. +func (client *ClientImpl) AddGroupEntitlement(ctx context.Context, args AddGroupEntitlementArgs) (*GroupEntitlementOperationReference, error) { + if args.GroupEntitlement == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GroupEntitlement"} + } + queryParams := url.Values{} + if args.RuleOption != nil { + queryParams.Add("ruleOption", string(*args.RuleOption)) + } + body, marshalErr := json.Marshal(*args.GroupEntitlement) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2280bffa-58a2-49da-822e-0764a1bb44f7") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GroupEntitlementOperationReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddGroupEntitlement function +type AddGroupEntitlementArgs struct { + // (required) GroupEntitlement object specifying License Rule, Extensions Rule for the group. Based on the rules the members of the group will be given licenses and extensions. The Group Entitlement can be used to add the group to another project level groups + GroupEntitlement *GroupEntitlement + // (optional) RuleOption [ApplyGroupRule/TestApplyGroupRule] - specifies if the rules defined in group entitlement should be created and applied to it’s members (default option) or just be tested + RuleOption *licensingrule.RuleOption +} + +// [Preview API] Add a member to a Group. +func (client *ClientImpl) AddMemberToGroup(ctx context.Context, args AddMemberToGroupArgs) error { + routeValues := make(map[string]string) + if args.GroupId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = (*args.GroupId).String() + if args.MemberId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.MemberId"} + } + routeValues["memberId"] = (*args.MemberId).String() + + locationId, _ := uuid.Parse("45a36e53-5286-4518-aa72-2d29f7acc5d8") + _, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the AddMemberToGroup function +type AddMemberToGroupArgs struct { + // (required) Id of the Group. + GroupId *uuid.UUID + // (required) Id of the member to add. + MemberId *uuid.UUID +} + +// [Preview API] Add a user, assign license and extensions and make them a member of a project group in an account. +func (client *ClientImpl) AddUserEntitlement(ctx context.Context, args AddUserEntitlementArgs) (*UserEntitlementsPostResponse, error) { + if args.UserEntitlement == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UserEntitlement"} + } + body, marshalErr := json.Marshal(*args.UserEntitlement) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("387f832c-dbf2-4643-88e9-c1aa94dbb737") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue UserEntitlementsPostResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddUserEntitlement function +type AddUserEntitlementArgs struct { + // (required) UserEntitlement object specifying License, Extensions and Project/Team groups the user should be added to. + UserEntitlement *UserEntitlement +} + +// [Preview API] Delete a group entitlement. +func (client *ClientImpl) DeleteGroupEntitlement(ctx context.Context, args DeleteGroupEntitlementArgs) (*GroupEntitlementOperationReference, error) { + routeValues := make(map[string]string) + if args.GroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = (*args.GroupId).String() + + queryParams := url.Values{} + if args.RuleOption != nil { + queryParams.Add("ruleOption", string(*args.RuleOption)) + } + if args.RemoveGroupMembership != nil { + queryParams.Add("removeGroupMembership", strconv.FormatBool(*args.RemoveGroupMembership)) + } + locationId, _ := uuid.Parse("2280bffa-58a2-49da-822e-0764a1bb44f7") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GroupEntitlementOperationReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the DeleteGroupEntitlement function +type DeleteGroupEntitlementArgs struct { + // (required) ID of the group to delete. + GroupId *uuid.UUID + // (optional) RuleOption [ApplyGroupRule/TestApplyGroupRule] - specifies if the rules defined in group entitlement should be deleted and the changes are applied to it’s members (default option) or just be tested + RuleOption *licensingrule.RuleOption + // (optional) Optional parameter that specifies whether the group with the given ID should be removed from all other groups + RemoveGroupMembership *bool +} + +// [Preview API] Delete a user from the account. +func (client *ClientImpl) DeleteUserEntitlement(ctx context.Context, args DeleteUserEntitlementArgs) error { + routeValues := make(map[string]string) + if args.UserId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.UserId"} + } + routeValues["userId"] = (*args.UserId).String() + + locationId, _ := uuid.Parse("8480c6eb-ce60-47e9-88df-eca3c801638b") + _, 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 DeleteUserEntitlement function +type DeleteUserEntitlementArgs struct { + // (required) ID of the user. + UserId *uuid.UUID +} + +// [Preview API] Get a group entitlement. +func (client *ClientImpl) GetGroupEntitlement(ctx context.Context, args GetGroupEntitlementArgs) (*GroupEntitlement, error) { + routeValues := make(map[string]string) + if args.GroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = (*args.GroupId).String() + + locationId, _ := uuid.Parse("2280bffa-58a2-49da-822e-0764a1bb44f7") + 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 GroupEntitlement + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetGroupEntitlement function +type GetGroupEntitlementArgs struct { + // (required) ID of the group. + GroupId *uuid.UUID +} + +// [Preview API] Get the group entitlements for an account. +func (client *ClientImpl) GetGroupEntitlements(ctx context.Context, args GetGroupEntitlementsArgs) (*[]GroupEntitlement, error) { + locationId, _ := uuid.Parse("2280bffa-58a2-49da-822e-0764a1bb44f7") + 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 []GroupEntitlement + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetGroupEntitlements function +type GetGroupEntitlementsArgs struct { +} + +// [Preview API] Get direct members of a Group. +func (client *ClientImpl) GetGroupMembers(ctx context.Context, args GetGroupMembersArgs) (*PagedGraphMemberList, error) { + routeValues := make(map[string]string) + if args.GroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = (*args.GroupId).String() + + queryParams := url.Values{} + if args.MaxResults != nil { + queryParams.Add("maxResults", strconv.Itoa(*args.MaxResults)) + } + if args.PagingToken != nil { + queryParams.Add("pagingToken", *args.PagingToken) + } + locationId, _ := uuid.Parse("45a36e53-5286-4518-aa72-2d29f7acc5d8") + 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 PagedGraphMemberList + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetGroupMembers function +type GetGroupMembersArgs struct { + // (required) Id of the Group. + GroupId *uuid.UUID + // (optional) Maximum number of results to retrieve. + MaxResults *int + // (optional) Paging Token from the previous page fetched. If the 'pagingToken' is null, the results would be fetched from the beginning of the Members List. + PagingToken *string +} + +// [Preview API] Get User Entitlement for a user. +func (client *ClientImpl) GetUserEntitlement(ctx context.Context, args GetUserEntitlementArgs) (*UserEntitlement, error) { + routeValues := make(map[string]string) + if args.UserId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UserId"} + } + routeValues["userId"] = (*args.UserId).String() + + locationId, _ := uuid.Parse("8480c6eb-ce60-47e9-88df-eca3c801638b") + 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 UserEntitlement + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetUserEntitlement function +type GetUserEntitlementArgs struct { + // (required) ID of the user. + UserId *uuid.UUID +} + +// [Preview API] Get a paged set of user entitlements matching the filter criteria. If no filter is is passed, a page from all the account users is returned. +func (client *ClientImpl) GetUserEntitlements(ctx context.Context, args GetUserEntitlementsArgs) (*PagedGraphMemberList, 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)) + } + if args.Filter != nil { + queryParams.Add("filter", *args.Filter) + } + if args.SortOption != nil { + queryParams.Add("sortOption", *args.SortOption) + } + locationId, _ := uuid.Parse("387f832c-dbf2-4643-88e9-c1aa94dbb737") + 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 PagedGraphMemberList + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetUserEntitlements function +type GetUserEntitlementsArgs struct { + // (optional) Maximum number of the user entitlements to return. Max value is 10000. Default value is 100 + Top *int + // (optional) Offset: Number of records to skip. Default value is 0 + Skip *int + // (optional) Comma (",") separated list of properties and their values to filter on. Currently, the API only supports filtering by ExtensionId. An example parameter would be filter=extensionId eq search. + Filter *string + // (optional) PropertyName and Order (separated by a space ( )) to sort on (e.g. LastAccessDate Desc) + SortOption *string +} + +// [Preview API] Get summary of Licenses, Extension, Projects, Groups and their assignments in the collection. +func (client *ClientImpl) GetUsersSummary(ctx context.Context, args GetUsersSummaryArgs) (*UsersSummary, error) { + queryParams := url.Values{} + if args.Select != nil { + queryParams.Add("select", *args.Select) + } + locationId, _ := uuid.Parse("5ae55b13-c9dd-49d1-957e-6e76c152e3d9") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue UsersSummary + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetUsersSummary function +type GetUsersSummaryArgs struct { + // (optional) Comma (",") separated list of properties to select. Supported property names are {AccessLevels, Licenses, Extensions, Projects, Groups}. + Select *string +} + +// [Preview API] Remove a member from a Group. +func (client *ClientImpl) RemoveMemberFromGroup(ctx context.Context, args RemoveMemberFromGroupArgs) error { + routeValues := make(map[string]string) + if args.GroupId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = (*args.GroupId).String() + if args.MemberId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.MemberId"} + } + routeValues["memberId"] = (*args.MemberId).String() + + locationId, _ := uuid.Parse("45a36e53-5286-4518-aa72-2d29f7acc5d8") + _, 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 RemoveMemberFromGroup function +type RemoveMemberFromGroupArgs struct { + // (required) Id of the group. + GroupId *uuid.UUID + // (required) Id of the member to remove. + MemberId *uuid.UUID +} + +// [Preview API] Update entitlements (License Rule, Extensions Rule, Project memberships etc.) for a group. +func (client *ClientImpl) UpdateGroupEntitlement(ctx context.Context, args UpdateGroupEntitlementArgs) (*GroupEntitlementOperationReference, error) { + if args.Document == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Document"} + } + routeValues := make(map[string]string) + if args.GroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = (*args.GroupId).String() + + queryParams := url.Values{} + if args.RuleOption != nil { + queryParams.Add("ruleOption", string(*args.RuleOption)) + } + body, marshalErr := json.Marshal(*args.Document) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2280bffa-58a2-49da-822e-0764a1bb44f7") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json-patch+json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GroupEntitlementOperationReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateGroupEntitlement function +type UpdateGroupEntitlementArgs struct { + // (required) JsonPatchDocument containing the operations to perform on the group. + Document *[]webapi.JsonPatchOperation + // (required) ID of the group. + GroupId *uuid.UUID + // (optional) RuleOption [ApplyGroupRule/TestApplyGroupRule] - specifies if the rules defined in group entitlement should be updated and the changes are applied to it’s members (default option) or just be tested + RuleOption *licensingrule.RuleOption +} + +// [Preview API] Edit the entitlements (License, Extensions, Projects, Teams etc) for a user. +func (client *ClientImpl) UpdateUserEntitlement(ctx context.Context, args UpdateUserEntitlementArgs) (*UserEntitlementsPatchResponse, error) { + if args.Document == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Document"} + } + routeValues := make(map[string]string) + if args.UserId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UserId"} + } + routeValues["userId"] = (*args.UserId).String() + + body, marshalErr := json.Marshal(*args.Document) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("8480c6eb-ce60-47e9-88df-eca3c801638b") + resp, 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 nil, err + } + + var responseValue UserEntitlementsPatchResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateUserEntitlement function +type UpdateUserEntitlementArgs struct { + // (required) JsonPatchDocument containing the operations to perform on the user. + Document *[]webapi.JsonPatchOperation + // (required) ID of the user. + UserId *uuid.UUID +} + +// [Preview API] Edit the entitlements (License, Extensions, Projects, Teams etc) for one or more users. +func (client *ClientImpl) UpdateUserEntitlements(ctx context.Context, args UpdateUserEntitlementsArgs) (*UserEntitlementOperationReference, error) { + if args.Document == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Document"} + } + queryParams := url.Values{} + if args.DoNotSendInviteForNewUsers != nil { + queryParams.Add("doNotSendInviteForNewUsers", strconv.FormatBool(*args.DoNotSendInviteForNewUsers)) + } + body, marshalErr := json.Marshal(*args.Document) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("387f832c-dbf2-4643-88e9-c1aa94dbb737") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", nil, queryParams, bytes.NewReader(body), "application/json-patch+json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue UserEntitlementOperationReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateUserEntitlements function +type UpdateUserEntitlementsArgs struct { + // (required) JsonPatchDocument containing the operations to perform. + Document *[]webapi.JsonPatchOperation + // (optional) Whether to send email invites to new users or not + DoNotSendInviteForNewUsers *bool +} diff --git a/azuredevops/memberentitlementmanagement/models.go b/azuredevops/memberentitlementmanagement/models.go new file mode 100644 index 00000000..6979b55a --- /dev/null +++ b/azuredevops/memberentitlementmanagement/models.go @@ -0,0 +1,439 @@ +// -------------------------------------------------------------------------------------------- +// 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 memberentitlementmanagement + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/commerce" + "github.com/microsoft/azure-devops-go-api/azuredevops/graph" + "github.com/microsoft/azure-devops-go-api/azuredevops/licensing" + "github.com/microsoft/azure-devops-go-api/azuredevops/licensingrule" + "github.com/microsoft/azure-devops-go-api/azuredevops/operations" +) + +type BaseOperationResult struct { + // List of error codes paired with their corresponding error messages + Errors *[]azuredevops.KeyValuePair `json:"errors,omitempty"` + // Success status of the operation + IsSuccess *bool `json:"isSuccess,omitempty"` +} + +// An extension assigned to a user +type Extension struct { + // Assignment source for this extension. I.e. explicitly assigned or from a group rule. + AssignmentSource *licensing.AssignmentSource `json:"assignmentSource,omitempty"` + // Gallery Id of the Extension. + Id *string `json:"id,omitempty"` + // Friendly name of this extension. + Name *string `json:"name,omitempty"` + // Source of this extension assignment. Ex: msdn, account, none, etc. + Source *licensing.LicensingSource `json:"source,omitempty"` +} + +// Summary of Extensions in the organization. +type ExtensionSummaryData struct { + // Count of Licenses already assigned. + Assigned *int `json:"assigned,omitempty"` + // Available Count. + Available *int `json:"available,omitempty"` + // Quantity + IncludedQuantity *int `json:"includedQuantity,omitempty"` + // Total Count. + Total *int `json:"total,omitempty"` + // Count of Extension Licenses assigned to users through msdn. + AssignedThroughSubscription *int `json:"assignedThroughSubscription,omitempty"` + // Gallery Id of the Extension + ExtensionId *string `json:"extensionId,omitempty"` + // Friendly name of this extension + ExtensionName *string `json:"extensionName,omitempty"` + // Whether its a Trial Version. + IsTrialVersion *bool `json:"isTrialVersion,omitempty"` + // Minimum License Required for the Extension. + MinimumLicenseRequired *commerce.MinimumRequiredServiceLevel `json:"minimumLicenseRequired,omitempty"` + // Days remaining for the Trial to expire. + RemainingTrialDays *int `json:"remainingTrialDays,omitempty"` + // Date on which the Trial expires. + TrialExpiryDate *azuredevops.Time `json:"trialExpiryDate,omitempty"` +} + +// Project Group (e.g. Contributor, Reader etc.) +type Group struct { + // Display Name of the Group + DisplayName *string `json:"displayName,omitempty"` + // Group Type + GroupType *GroupType `json:"groupType,omitempty"` +} + +// A group entity with additional properties including its license, extensions, and project membership +type GroupEntitlement struct { + // Extension Rules. + ExtensionRules *[]Extension `json:"extensionRules,omitempty"` + // Member reference. + Group *graph.GraphGroup `json:"group,omitempty"` + // The unique identifier which matches the Id of the GraphMember. + Id *uuid.UUID `json:"id,omitempty"` + // [Readonly] The last time the group licensing rule was executed (regardless of whether any changes were made). + LastExecuted *azuredevops.Time `json:"lastExecuted,omitempty"` + // License Rule. + LicenseRule *licensing.AccessLevel `json:"licenseRule,omitempty"` + // Group members. Only used when creating a new group. + Members *[]UserEntitlement `json:"members,omitempty"` + // Relation between a project and the member's effective permissions in that project. + ProjectEntitlements *[]ProjectEntitlement `json:"projectEntitlements,omitempty"` + // The status of the group rule. + Status *licensingrule.GroupLicensingRuleStatus `json:"status,omitempty"` +} + +type GroupEntitlementOperationReference 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 *operations.OperationStatus `json:"status,omitempty"` + // URL to get the full operation object. + Url *string `json:"url,omitempty"` + // Operation completed with success or failure. + Completed *bool `json:"completed,omitempty"` + // True if all operations were successful. + HaveResultsSucceeded *bool `json:"haveResultsSucceeded,omitempty"` + // List of results for each operation. + Results *[]GroupOperationResult `json:"results,omitempty"` +} + +type GroupOperationResult struct { + // List of error codes paired with their corresponding error messages + Errors *[]azuredevops.KeyValuePair `json:"errors,omitempty"` + // Success status of the operation + IsSuccess *bool `json:"isSuccess,omitempty"` + // Identifier of the Group being acted upon + GroupId *uuid.UUID `json:"groupId,omitempty"` + // Result of the Groupentitlement after the operation + Result *GroupEntitlement `json:"result,omitempty"` +} + +// Group option to add a user to +type GroupOption struct { + // Access Level + AccessLevel *licensing.AccessLevel `json:"accessLevel,omitempty"` + // Group + Group *Group `json:"group,omitempty"` +} + +// Used when adding users to a project. Each GroupType maps to a well-known group. The lowest GroupType should always be ProjectStakeholder +type GroupType string + +type groupTypeValuesType struct { + ProjectStakeholder GroupType + ProjectReader GroupType + ProjectContributor GroupType + ProjectAdministrator GroupType + Custom GroupType +} + +var GroupTypeValues = groupTypeValuesType{ + ProjectStakeholder: "projectStakeholder", + ProjectReader: "projectReader", + ProjectContributor: "projectContributor", + ProjectAdministrator: "projectAdministrator", + Custom: "custom", +} + +// Summary of Licenses in the organization. +type LicenseSummaryData struct { + // Count of Licenses already assigned. + Assigned *int `json:"assigned,omitempty"` + // Available Count. + Available *int `json:"available,omitempty"` + // Quantity + IncludedQuantity *int `json:"includedQuantity,omitempty"` + // Total Count. + Total *int `json:"total,omitempty"` + // Type of Account License. + AccountLicenseType *licensing.AccountLicenseType `json:"accountLicenseType,omitempty"` + // Count of Disabled Licenses. + Disabled *int `json:"disabled,omitempty"` + // Designates if this license quantity can be changed through purchase + IsPurchasable *bool `json:"isPurchasable,omitempty"` + // Name of the License. + LicenseName *string `json:"licenseName,omitempty"` + // Type of MSDN License. + MsdnLicenseType *licensing.MsdnLicenseType `json:"msdnLicenseType,omitempty"` + // Specifies the date when billing will charge for paid licenses + NextBillingDate *azuredevops.Time `json:"nextBillingDate,omitempty"` + // Source of the License. + Source *licensing.LicensingSource `json:"source,omitempty"` + // Total license count after next billing cycle + TotalAfterNextBillingDate *int `json:"totalAfterNextBillingDate,omitempty"` +} + +// Deprecated: Use UserEntitlement instead +type MemberEntitlement struct { + // User's access level denoted by a license. + AccessLevel *licensing.AccessLevel `json:"accessLevel,omitempty"` + // [Readonly] Date the user was added to the collection. + DateCreated *azuredevops.Time `json:"dateCreated,omitempty"` + // User's extensions. + Extensions *[]Extension `json:"extensions,omitempty"` + // [Readonly] GroupEntitlements that this user belongs to. + GroupAssignments *[]GroupEntitlement `json:"groupAssignments,omitempty"` + // The unique identifier which matches the Id of the Identity associated with the GraphMember. + Id *uuid.UUID `json:"id,omitempty"` + // [Readonly] Date the user last accessed the collection. + LastAccessedDate *azuredevops.Time `json:"lastAccessedDate,omitempty"` + // Relation between a project and the user's effective permissions in that project. + ProjectEntitlements *[]ProjectEntitlement `json:"projectEntitlements,omitempty"` + // User reference. + User *graph.GraphUser `json:"user,omitempty"` + // Member reference + Member *graph.GraphMember `json:"member,omitempty"` +} + +type MemberEntitlementOperationReference 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 *operations.OperationStatus `json:"status,omitempty"` + // URL to get the full operation object. + Url *string `json:"url,omitempty"` + // Operation completed with success or failure + Completed *bool `json:"completed,omitempty"` + // True if all operations were successful + HaveResultsSucceeded *bool `json:"haveResultsSucceeded,omitempty"` + // List of results for each operation + Results *[]OperationResult `json:"results,omitempty"` +} + +type MemberEntitlementsPatchResponse struct { + // True if all operations were successful. + IsSuccess *bool `json:"isSuccess,omitempty"` + // Result of the member entitlement after the operations. have been applied + MemberEntitlement *MemberEntitlement `json:"memberEntitlement,omitempty"` + // List of results for each operation + OperationResults *[]OperationResult `json:"operationResults,omitempty"` +} + +type MemberEntitlementsPostResponse struct { + // True if all operations were successful. + IsSuccess *bool `json:"isSuccess,omitempty"` + // Result of the member entitlement after the operations. have been applied + MemberEntitlement *MemberEntitlement `json:"memberEntitlement,omitempty"` + // Operation result + OperationResult *OperationResult `json:"operationResult,omitempty"` +} + +type MemberEntitlementsResponseBase struct { + // True if all operations were successful. + IsSuccess *bool `json:"isSuccess,omitempty"` + // Result of the member entitlement after the operations. have been applied + MemberEntitlement *MemberEntitlement `json:"memberEntitlement,omitempty"` +} + +type OperationResult struct { + // List of error codes paired with their corresponding error messages. + Errors *[]azuredevops.KeyValuePair `json:"errors,omitempty"` + // Success status of the operation. + IsSuccess *bool `json:"isSuccess,omitempty"` + // Identifier of the Member being acted upon. + MemberId *uuid.UUID `json:"memberId,omitempty"` + // Result of the MemberEntitlement after the operation. + Result *MemberEntitlement `json:"result,omitempty"` +} + +// A page of users +type PagedGraphMemberList struct { + Members *[]UserEntitlement `json:"members,omitempty"` +} + +// Relation between a project and the user's effective permissions in that project. +type ProjectEntitlement struct { + // Assignment Source (e.g. Group or Unknown). + AssignmentSource *licensing.AssignmentSource `json:"assignmentSource,omitempty"` + // Project Group (e.g. Contributor, Reader etc.) + Group *Group `json:"group,omitempty"` + // Deprecated: This property is deprecated. Please use ProjectPermissionInherited. + IsProjectPermissionInherited *bool `json:"isProjectPermissionInherited,omitempty"` + // Whether the user is inheriting permissions to a project through a Azure DevOps or AAD group membership. + ProjectPermissionInherited *ProjectPermissionInherited `json:"projectPermissionInherited,omitempty"` + // Project Ref + ProjectRef *ProjectRef `json:"projectRef,omitempty"` + // Team Ref. + TeamRefs *[]TeamRef `json:"teamRefs,omitempty"` +} + +type ProjectPermissionInherited string + +type projectPermissionInheritedValuesType struct { + NotSet ProjectPermissionInherited + NotInherited ProjectPermissionInherited + Inherited ProjectPermissionInherited +} + +var ProjectPermissionInheritedValues = projectPermissionInheritedValuesType{ + NotSet: "notSet", + NotInherited: "notInherited", + Inherited: "inherited", +} + +// A reference to a project +type ProjectRef struct { + // Project ID. + Id *uuid.UUID `json:"id,omitempty"` + // Project Name. + Name *string `json:"name,omitempty"` +} + +type SummaryData struct { + // Count of Licenses already assigned. + Assigned *int `json:"assigned,omitempty"` + // Available Count. + Available *int `json:"available,omitempty"` + // Quantity + IncludedQuantity *int `json:"includedQuantity,omitempty"` + // Total Count. + Total *int `json:"total,omitempty"` +} + +// [Flags] +type SummaryPropertyName string + +type summaryPropertyNameValuesType struct { + AccessLevels SummaryPropertyName + Licenses SummaryPropertyName + Extensions SummaryPropertyName + Projects SummaryPropertyName + Groups SummaryPropertyName + All SummaryPropertyName +} + +var SummaryPropertyNameValues = summaryPropertyNameValuesType{ + AccessLevels: "accessLevels", + Licenses: "licenses", + Extensions: "extensions", + Projects: "projects", + Groups: "groups", + All: "all", +} + +// A reference to a team +type TeamRef struct { + // Team ID + Id *uuid.UUID `json:"id,omitempty"` + // Team Name + Name *string `json:"name,omitempty"` +} + +// A user entity with additional properties including their license, extensions, and project membership +type UserEntitlement struct { + // User's access level denoted by a license. + AccessLevel *licensing.AccessLevel `json:"accessLevel,omitempty"` + // [Readonly] Date the user was added to the collection. + DateCreated *azuredevops.Time `json:"dateCreated,omitempty"` + // User's extensions. + Extensions *[]Extension `json:"extensions,omitempty"` + // [Readonly] GroupEntitlements that this user belongs to. + GroupAssignments *[]GroupEntitlement `json:"groupAssignments,omitempty"` + // The unique identifier which matches the Id of the Identity associated with the GraphMember. + Id *uuid.UUID `json:"id,omitempty"` + // [Readonly] Date the user last accessed the collection. + LastAccessedDate *azuredevops.Time `json:"lastAccessedDate,omitempty"` + // Relation between a project and the user's effective permissions in that project. + ProjectEntitlements *[]ProjectEntitlement `json:"projectEntitlements,omitempty"` + // User reference. + User *graph.GraphUser `json:"user,omitempty"` +} + +type UserEntitlementOperationReference 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 *operations.OperationStatus `json:"status,omitempty"` + // URL to get the full operation object. + Url *string `json:"url,omitempty"` + // Operation completed with success or failure. + Completed *bool `json:"completed,omitempty"` + // True if all operations were successful. + HaveResultsSucceeded *bool `json:"haveResultsSucceeded,omitempty"` + // List of results for each operation. + Results *[]UserEntitlementOperationResult `json:"results,omitempty"` +} + +type UserEntitlementOperationResult struct { + // List of error codes paired with their corresponding error messages. + Errors *[]azuredevops.KeyValuePair `json:"errors,omitempty"` + // Success status of the operation. + IsSuccess *bool `json:"isSuccess,omitempty"` + // Result of the MemberEntitlement after the operation. + Result *UserEntitlement `json:"result,omitempty"` + // Identifier of the Member being acted upon. + UserId *uuid.UUID `json:"userId,omitempty"` +} + +// [Flags] +type UserEntitlementProperty string + +type userEntitlementPropertyValuesType struct { + License UserEntitlementProperty + Extensions UserEntitlementProperty + Projects UserEntitlementProperty + GroupRules UserEntitlementProperty + All UserEntitlementProperty +} + +var UserEntitlementPropertyValues = userEntitlementPropertyValuesType{ + License: "license", + Extensions: "extensions", + Projects: "projects", + GroupRules: "groupRules", + All: "all", +} + +type UserEntitlementsPatchResponse struct { + // True if all operations were successful. + IsSuccess *bool `json:"isSuccess,omitempty"` + // Result of the user entitlement after the operations have been applied. + UserEntitlement *UserEntitlement `json:"userEntitlement,omitempty"` + // List of results for each operation. + OperationResults *[]UserEntitlementOperationResult `json:"operationResults,omitempty"` +} + +type UserEntitlementsPostResponse struct { + // True if all operations were successful. + IsSuccess *bool `json:"isSuccess,omitempty"` + // Result of the user entitlement after the operations have been applied. + UserEntitlement *UserEntitlement `json:"userEntitlement,omitempty"` + // Operation result. + OperationResult *UserEntitlementOperationResult `json:"operationResult,omitempty"` +} + +type UserEntitlementsResponseBase struct { + // True if all operations were successful. + IsSuccess *bool `json:"isSuccess,omitempty"` + // Result of the user entitlement after the operations have been applied. + UserEntitlement *UserEntitlement `json:"userEntitlement,omitempty"` +} + +// Summary of licenses and extensions assigned to users in the organization +type UsersSummary struct { + // Available Access Levels + AvailableAccessLevels *[]licensing.AccessLevel `json:"availableAccessLevels,omitempty"` + // Summary of Extensions in the organization + Extensions *[]ExtensionSummaryData `json:"extensions,omitempty"` + // Group Options + GroupOptions *[]GroupOption `json:"groupOptions,omitempty"` + // Summary of Licenses in the organization + Licenses *[]LicenseSummaryData `json:"licenses,omitempty"` + // Summary of Projects in the organization + ProjectRefs *[]ProjectRef `json:"projectRefs,omitempty"` +} diff --git a/azuredevops/models.go b/azuredevops/models.go new file mode 100644 index 00000000..3fe2ba7b --- /dev/null +++ b/azuredevops/models.go @@ -0,0 +1,144 @@ +// 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) +} + +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/azuredevops/models_test.go b/azuredevops/models_test.go new file mode 100644 index 00000000..79090ce4 --- /dev/null +++ b/azuredevops/models_test.go @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azuredevops + +import ( + "encoding/json" + "github.com/google/uuid" + "testing" + "time" +) + +func TestModels_Unmarshal_Time(t *testing.T) { + text := []byte("{\"id\":\"d221ad31-3a7b-52c0-b71d-b255b1ff63ba\",\"time1\":\"0001-01-01T00:00:00\",\"time2\":\"2019-09-01T00:07:26Z\",\"time3\":\"2020-05-16T20:55:32.0116793\",\"int\":10,\"string\":\"test string\"}") + testModel := TestModel{} + + testModel.Time1 = &Time{} + testModel.Time1.Time = time.Now() // this ensures we test the value is set back to default when issue #17 is hit. + + err := json.Unmarshal(text, &testModel) + if err != nil { + t.Errorf("Error occurred during deserialization: %v", err) + } + if (testModel.Time1.Time != time.Time{}) { + t.Errorf("Expecting deserialized time to equal default time. Actual time: %v", testModel.Time1) + } + + parsedTime, err := time.Parse(time.RFC3339, "2019-09-01T00:07:26Z") + if err != nil { + t.Errorf(err.Error()) + } + if testModel.Time2.Time != parsedTime { + t.Errorf("Expected time: %v Actual time: %v", parsedTime, testModel.Time2.Time) + } + + // Test workaround for issue #59 https://github.com/microsoft/azure-devops-go-api/issues/59 + parsedTime59, err := time.Parse("2006-01-02T15:04:05.999999999", "2020-05-16T20:55:32.0116793") + if testModel.Time3.Time != parsedTime59 { + t.Errorf("Expected time: %v Actual time: %v", parsedTime59, testModel.Time3.Time) + } +} + +func TestModels_Marshal_Unmarshal_Time(t *testing.T) { + testModel1 := TestModel{} + testModel1.Time1 = &Time{} + testModel1.Time1.Time = time.Now() + b, err := json.Marshal(testModel1) + if err != nil { + t.Errorf(err.Error()) + } + + testModel2 := TestModel{} + err = json.Unmarshal(b, &testModel2) + if err != nil { + t.Errorf(err.Error()) + } + + if testModel1.Time1 != testModel1.Time1 { + t.Errorf("Expected time: %v Actual time: %v", testModel1.Time1, testModel1.Time2) + } + + if testModel1.Time1.Time != testModel1.Time1.Time { + t.Errorf("Expected time: %v Actual time: %v", testModel1.Time1.Time, testModel1.Time2.Time) + } +} + +type TestModel struct { + Id *uuid.UUID `json:"id,omitempty"` + Time1 *Time `json:"time1,omitempty"` + Time2 *Time `json:"time2,omitempty"` + Time3 *Time `json:"time3,omitempty"` + Int *uint64 `json:"int,omitempty"` + String *string `json:"string,omitempty"` +} diff --git a/azuredevops/notification/client.go b/azuredevops/notification/client.go new file mode 100644 index 00000000..63f50ece --- /dev/null +++ b/azuredevops/notification/client.go @@ -0,0 +1,545 @@ +// -------------------------------------------------------------------------------------------- +// 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 notification + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strings" +) + +type Client interface { + // Create a new subscription. + CreateSubscription(context.Context, CreateSubscriptionArgs) (*NotificationSubscription, error) + // Delete a subscription. + DeleteSubscription(context.Context, DeleteSubscriptionArgs) error + // Get a specific event type. + GetEventType(context.Context, GetEventTypeArgs) (*NotificationEventType, error) + GetSettings(context.Context, GetSettingsArgs) (*NotificationAdminSettings, error) + // Get delivery preferences of a notifications subscriber. + GetSubscriber(context.Context, GetSubscriberArgs) (*NotificationSubscriber, error) + // Get a notification subscription by its ID. + GetSubscription(context.Context, GetSubscriptionArgs) (*NotificationSubscription, error) + // Get the diagnostics settings for a subscription. + GetSubscriptionDiagnostics(context.Context, GetSubscriptionDiagnosticsArgs) (*SubscriptionDiagnostics, error) + // Get available subscription templates. + GetSubscriptionTemplates(context.Context, GetSubscriptionTemplatesArgs) (*[]NotificationSubscriptionTemplate, error) + // List available event types for this service. Optionally filter by only event types for the specified publisher. + ListEventTypes(context.Context, ListEventTypesArgs) (*[]NotificationEventType, error) + // Get a list of diagnostic logs for this service. + ListLogs(context.Context, ListLogsArgs) (*[]INotificationDiagnosticLog, error) + // Get a list of notification subscriptions, either by subscription IDs or by all subscriptions for a given user or group. + ListSubscriptions(context.Context, ListSubscriptionsArgs) (*[]NotificationSubscription, error) + // Query for subscriptions. A subscription is returned if it matches one or more of the specified conditions. + QuerySubscriptions(context.Context, QuerySubscriptionsArgs) (*[]NotificationSubscription, error) + UpdateSettings(context.Context, UpdateSettingsArgs) (*NotificationAdminSettings, error) + // Update delivery preferences of a notifications subscriber. + UpdateSubscriber(context.Context, UpdateSubscriberArgs) (*NotificationSubscriber, error) + // Update an existing subscription. Depending on the type of subscription and permissions, the caller can update the description, filter settings, channel (delivery) settings and more. + UpdateSubscription(context.Context, UpdateSubscriptionArgs) (*NotificationSubscription, error) + // Update the diagnostics settings for a subscription. + UpdateSubscriptionDiagnostics(context.Context, UpdateSubscriptionDiagnosticsArgs) (*SubscriptionDiagnostics, error) + // Update the specified user's settings for the specified subscription. This API is typically used to opt in or out of a shared subscription. User settings can only be applied to shared subscriptions, like team subscriptions or default subscriptions. + UpdateSubscriptionUserSettings(context.Context, UpdateSubscriptionUserSettingsArgs) (*SubscriptionUserSettings, 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, + } +} + +// Create a new subscription. +func (client *ClientImpl) CreateSubscription(ctx context.Context, args CreateSubscriptionArgs) (*NotificationSubscription, error) { + if args.CreateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CreateParameters"} + } + body, marshalErr := json.Marshal(*args.CreateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("70f911d6-abac-488c-85b3-a206bf57e165") + 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 NotificationSubscription + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateSubscription function +type CreateSubscriptionArgs struct { + // (required) + CreateParameters *NotificationSubscriptionCreateParameters +} + +// Delete a subscription. +func (client *ClientImpl) DeleteSubscription(ctx context.Context, args DeleteSubscriptionArgs) error { + routeValues := make(map[string]string) + if args.SubscriptionId == nil || *args.SubscriptionId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = *args.SubscriptionId + + locationId, _ := uuid.Parse("70f911d6-abac-488c-85b3-a206bf57e165") + _, 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 DeleteSubscription function +type DeleteSubscriptionArgs struct { + // (required) + SubscriptionId *string +} + +// Get a specific event type. +func (client *ClientImpl) GetEventType(ctx context.Context, args GetEventTypeArgs) (*NotificationEventType, error) { + routeValues := make(map[string]string) + if args.EventType == nil || *args.EventType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.EventType"} + } + routeValues["eventType"] = *args.EventType + + locationId, _ := uuid.Parse("cc84fb5f-6247-4c7a-aeae-e5a3c3fddb21") + 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 NotificationEventType + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetEventType function +type GetEventTypeArgs struct { + // (required) The ID of the event type. + EventType *string +} + +func (client *ClientImpl) GetSettings(ctx context.Context, args GetSettingsArgs) (*NotificationAdminSettings, error) { + locationId, _ := uuid.Parse("cbe076d8-2803-45ff-8d8d-44653686ea2a") + 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 NotificationAdminSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSettings function +type GetSettingsArgs struct { +} + +// Get delivery preferences of a notifications subscriber. +func (client *ClientImpl) GetSubscriber(ctx context.Context, args GetSubscriberArgs) (*NotificationSubscriber, error) { + routeValues := make(map[string]string) + if args.SubscriberId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SubscriberId"} + } + routeValues["subscriberId"] = (*args.SubscriberId).String() + + locationId, _ := uuid.Parse("4d5caff1-25ba-430b-b808-7a1f352cc197") + 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 NotificationSubscriber + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSubscriber function +type GetSubscriberArgs struct { + // (required) ID of the user or group. + SubscriberId *uuid.UUID +} + +// Get a notification subscription by its ID. +func (client *ClientImpl) GetSubscription(ctx context.Context, args GetSubscriptionArgs) (*NotificationSubscription, error) { + routeValues := make(map[string]string) + if args.SubscriptionId == nil || *args.SubscriptionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = *args.SubscriptionId + + queryParams := url.Values{} + if args.QueryFlags != nil { + queryParams.Add("queryFlags", string(*args.QueryFlags)) + } + locationId, _ := uuid.Parse("70f911d6-abac-488c-85b3-a206bf57e165") + 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 NotificationSubscription + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSubscription function +type GetSubscriptionArgs struct { + // (required) + SubscriptionId *string + // (optional) + QueryFlags *SubscriptionQueryFlags +} + +// Get the diagnostics settings for a subscription. +func (client *ClientImpl) GetSubscriptionDiagnostics(ctx context.Context, args GetSubscriptionDiagnosticsArgs) (*SubscriptionDiagnostics, error) { + routeValues := make(map[string]string) + if args.SubscriptionId == nil || *args.SubscriptionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = *args.SubscriptionId + + locationId, _ := uuid.Parse("20f1929d-4be7-4c2e-a74e-d47640ff3418") + 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 SubscriptionDiagnostics + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSubscriptionDiagnostics function +type GetSubscriptionDiagnosticsArgs struct { + // (required) The id of the notifications subscription. + SubscriptionId *string +} + +// Get available subscription templates. +func (client *ClientImpl) GetSubscriptionTemplates(ctx context.Context, args GetSubscriptionTemplatesArgs) (*[]NotificationSubscriptionTemplate, error) { + locationId, _ := uuid.Parse("fa5d24ba-7484-4f3d-888d-4ec6b1974082") + 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 []NotificationSubscriptionTemplate + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSubscriptionTemplates function +type GetSubscriptionTemplatesArgs struct { +} + +// List available event types for this service. Optionally filter by only event types for the specified publisher. +func (client *ClientImpl) ListEventTypes(ctx context.Context, args ListEventTypesArgs) (*[]NotificationEventType, error) { + queryParams := url.Values{} + if args.PublisherId != nil { + queryParams.Add("publisherId", *args.PublisherId) + } + locationId, _ := uuid.Parse("cc84fb5f-6247-4c7a-aeae-e5a3c3fddb21") + 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 []NotificationEventType + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListEventTypes function +type ListEventTypesArgs struct { + // (optional) Limit to event types for this publisher + PublisherId *string +} + +// Get a list of diagnostic logs for this service. +func (client *ClientImpl) ListLogs(ctx context.Context, args ListLogsArgs) (*[]INotificationDiagnosticLog, error) { + routeValues := make(map[string]string) + if args.Source == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Source"} + } + routeValues["source"] = (*args.Source).String() + if args.EntryId != nil { + routeValues["entryId"] = (*args.EntryId).String() + } + + queryParams := url.Values{} + if args.StartTime != nil { + queryParams.Add("startTime", (*args.StartTime).String()) + } + if args.EndTime != nil { + queryParams.Add("endTime", (*args.EndTime).String()) + } + locationId, _ := uuid.Parse("991842f3-eb16-4aea-ac81-81353ef2b75c") + 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 []INotificationDiagnosticLog + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListLogs function +type ListLogsArgs struct { + // (required) ID specifying which type of logs to check diagnostics for. + Source *uuid.UUID + // (optional) The ID of the specific log to query for. + EntryId *uuid.UUID + // (optional) Start time for the time range to query in. + StartTime *azuredevops.Time + // (optional) End time for the time range to query in. + EndTime *azuredevops.Time +} + +// Get a list of notification subscriptions, either by subscription IDs or by all subscriptions for a given user or group. +func (client *ClientImpl) ListSubscriptions(ctx context.Context, args ListSubscriptionsArgs) (*[]NotificationSubscription, error) { + queryParams := url.Values{} + if args.TargetId != nil { + queryParams.Add("targetId", (*args.TargetId).String()) + } + if args.Ids != nil { + listAsString := strings.Join((*args.Ids)[:], ",") + queryParams.Add("ids", listAsString) + } + if args.QueryFlags != nil { + queryParams.Add("queryFlags", string(*args.QueryFlags)) + } + locationId, _ := uuid.Parse("70f911d6-abac-488c-85b3-a206bf57e165") + 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 []NotificationSubscription + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListSubscriptions function +type ListSubscriptionsArgs struct { + // (optional) User or Group ID + TargetId *uuid.UUID + // (optional) List of subscription IDs + Ids *[]string + // (optional) + QueryFlags *SubscriptionQueryFlags +} + +// Query for subscriptions. A subscription is returned if it matches one or more of the specified conditions. +func (client *ClientImpl) QuerySubscriptions(ctx context.Context, args QuerySubscriptionsArgs) (*[]NotificationSubscription, error) { + if args.SubscriptionQuery == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SubscriptionQuery"} + } + body, marshalErr := json.Marshal(*args.SubscriptionQuery) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("6864db85-08c0-4006-8e8e-cc1bebe31675") + 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 []NotificationSubscription + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QuerySubscriptions function +type QuerySubscriptionsArgs struct { + // (required) + SubscriptionQuery *SubscriptionQuery +} + +func (client *ClientImpl) UpdateSettings(ctx context.Context, args UpdateSettingsArgs) (*NotificationAdminSettings, error) { + if args.UpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateParameters"} + } + body, marshalErr := json.Marshal(*args.UpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("cbe076d8-2803-45ff-8d8d-44653686ea2a") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue NotificationAdminSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateSettings function +type UpdateSettingsArgs struct { + // (required) + UpdateParameters *NotificationAdminSettingsUpdateParameters +} + +// Update delivery preferences of a notifications subscriber. +func (client *ClientImpl) UpdateSubscriber(ctx context.Context, args UpdateSubscriberArgs) (*NotificationSubscriber, error) { + if args.UpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateParameters"} + } + routeValues := make(map[string]string) + if args.SubscriberId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SubscriberId"} + } + routeValues["subscriberId"] = (*args.SubscriberId).String() + + body, marshalErr := json.Marshal(*args.UpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4d5caff1-25ba-430b-b808-7a1f352cc197") + 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 NotificationSubscriber + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateSubscriber function +type UpdateSubscriberArgs struct { + // (required) + UpdateParameters *NotificationSubscriberUpdateParameters + // (required) ID of the user or group. + SubscriberId *uuid.UUID +} + +// Update an existing subscription. Depending on the type of subscription and permissions, the caller can update the description, filter settings, channel (delivery) settings and more. +func (client *ClientImpl) UpdateSubscription(ctx context.Context, args UpdateSubscriptionArgs) (*NotificationSubscription, error) { + if args.UpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateParameters"} + } + routeValues := make(map[string]string) + if args.SubscriptionId == nil || *args.SubscriptionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = *args.SubscriptionId + + body, marshalErr := json.Marshal(*args.UpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("70f911d6-abac-488c-85b3-a206bf57e165") + 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 NotificationSubscription + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateSubscription function +type UpdateSubscriptionArgs struct { + // (required) + UpdateParameters *NotificationSubscriptionUpdateParameters + // (required) + SubscriptionId *string +} + +// Update the diagnostics settings for a subscription. +func (client *ClientImpl) UpdateSubscriptionDiagnostics(ctx context.Context, args UpdateSubscriptionDiagnosticsArgs) (*SubscriptionDiagnostics, error) { + if args.UpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateParameters"} + } + routeValues := make(map[string]string) + if args.SubscriptionId == nil || *args.SubscriptionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = *args.SubscriptionId + + body, marshalErr := json.Marshal(*args.UpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("20f1929d-4be7-4c2e-a74e-d47640ff3418") + 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 SubscriptionDiagnostics + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateSubscriptionDiagnostics function +type UpdateSubscriptionDiagnosticsArgs struct { + // (required) + UpdateParameters *UpdateSubscripitonDiagnosticsParameters + // (required) The id of the notifications subscription. + SubscriptionId *string +} + +// Update the specified user's settings for the specified subscription. This API is typically used to opt in or out of a shared subscription. User settings can only be applied to shared subscriptions, like team subscriptions or default subscriptions. +func (client *ClientImpl) UpdateSubscriptionUserSettings(ctx context.Context, args UpdateSubscriptionUserSettingsArgs) (*SubscriptionUserSettings, error) { + if args.UserSettings == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UserSettings"} + } + routeValues := make(map[string]string) + if args.SubscriptionId == nil || *args.SubscriptionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = *args.SubscriptionId + if args.UserId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UserId"} + } + routeValues["userId"] = (*args.UserId).String() + + body, marshalErr := json.Marshal(*args.UserSettings) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ed5a3dff-aeb5-41b1-b4f7-89e66e58b62e") + 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 SubscriptionUserSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateSubscriptionUserSettings function +type UpdateSubscriptionUserSettingsArgs struct { + // (required) + UserSettings *SubscriptionUserSettings + // (required) + SubscriptionId *string + // (required) ID of the user + UserId *uuid.UUID +} diff --git a/azuredevops/notification/models.go b/azuredevops/notification/models.go new file mode 100644 index 00000000..02d6a748 --- /dev/null +++ b/azuredevops/notification/models.go @@ -0,0 +1,1353 @@ +// -------------------------------------------------------------------------------------------- +// 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 notification + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/forminput" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type ActorFilter struct { + EventType *string `json:"eventType,omitempty"` + Criteria *ExpressionFilterModel `json:"criteria,omitempty"` + Type *string `json:"type,omitempty"` + Exclusions *[]string `json:"exclusions,omitempty"` + Inclusions *[]string `json:"inclusions,omitempty"` +} + +type ActorNotificationReason struct { + NotificationReasonType *NotificationReasonType `json:"notificationReasonType,omitempty"` + TargetIdentities *[]webapi.IdentityRef `json:"targetIdentities,omitempty"` + MatchedRoles *[]string `json:"matchedRoles,omitempty"` +} + +// Artifact filter options. Used in "follow" subscriptions. +type ArtifactFilter struct { + EventType *string `json:"eventType,omitempty"` + ArtifactId *string `json:"artifactId,omitempty"` + ArtifactType *string `json:"artifactType,omitempty"` + ArtifactUri *string `json:"artifactUri,omitempty"` + Type *string `json:"type,omitempty"` +} + +type BaseSubscriptionFilter struct { + EventType *string `json:"eventType,omitempty"` + Type *string `json:"type,omitempty"` +} + +type BatchNotificationOperation struct { + NotificationOperation *NotificationOperation `json:"notificationOperation,omitempty"` + NotificationQueryConditions *[]NotificationQueryCondition `json:"notificationQueryConditions,omitempty"` +} + +type BlockFilter struct { + EventType *string `json:"eventType,omitempty"` + Criteria *ExpressionFilterModel `json:"criteria,omitempty"` + Type *string `json:"type,omitempty"` + Exclusions *[]string `json:"exclusions,omitempty"` + Inclusions *[]string `json:"inclusions,omitempty"` +} + +type BlockSubscriptionChannel struct { + Type *string `json:"type,omitempty"` +} + +// Default delivery preference for group subscribers. Indicates how the subscriber should be notified. +type DefaultGroupDeliveryPreference string + +type defaultGroupDeliveryPreferenceValuesType struct { + NoDelivery DefaultGroupDeliveryPreference + EachMember DefaultGroupDeliveryPreference +} + +var DefaultGroupDeliveryPreferenceValues = defaultGroupDeliveryPreferenceValuesType{ + NoDelivery: "noDelivery", + EachMember: "eachMember", +} + +type DiagnosticIdentity struct { + DisplayName *string `json:"displayName,omitempty"` + EmailAddress *string `json:"emailAddress,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` +} + +type DiagnosticNotification struct { + EventId *int `json:"eventId,omitempty"` + EventType *string `json:"eventType,omitempty"` + Id *int `json:"id,omitempty"` + Messages *[]NotificationDiagnosticLogMessage `json:"messages,omitempty"` + Recipients *map[uuid.UUID]DiagnosticRecipient `json:"recipients,omitempty"` + Result *string `json:"result,omitempty"` + Stats *map[string]int `json:"stats,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` +} + +type DiagnosticRecipient struct { + Recipient *DiagnosticIdentity `json:"recipient,omitempty"` + Status *string `json:"status,omitempty"` +} + +type EmailHtmlSubscriptionChannel struct { + Address *string `json:"address,omitempty"` + UseCustomAddress *bool `json:"useCustomAddress,omitempty"` + Type *string `json:"type,omitempty"` +} + +type EmailPlaintextSubscriptionChannel struct { + Address *string `json:"address,omitempty"` + UseCustomAddress *bool `json:"useCustomAddress,omitempty"` + Type *string `json:"type,omitempty"` +} + +// Describes the subscription evaluation operation status. +type EvaluationOperationStatus string + +type evaluationOperationStatusValuesType struct { + NotSet EvaluationOperationStatus + Queued EvaluationOperationStatus + InProgress EvaluationOperationStatus + Cancelled EvaluationOperationStatus + Succeeded EvaluationOperationStatus + Failed EvaluationOperationStatus + TimedOut EvaluationOperationStatus + NotFound EvaluationOperationStatus +} + +var EvaluationOperationStatusValues = evaluationOperationStatusValuesType{ + // The operation object does not have the 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", + // The operation timed out. + TimedOut: "timedOut", + // The operation could not be found. + NotFound: "notFound", +} + +type EventBacklogStatus struct { + CaptureTime *azuredevops.Time `json:"captureTime,omitempty"` + JobId *uuid.UUID `json:"jobId,omitempty"` + LastEventBatchStartTime *azuredevops.Time `json:"lastEventBatchStartTime,omitempty"` + LastEventProcessedTime *azuredevops.Time `json:"lastEventProcessedTime,omitempty"` + LastJobBatchStartTime *azuredevops.Time `json:"lastJobBatchStartTime,omitempty"` + LastJobProcessedTime *azuredevops.Time `json:"lastJobProcessedTime,omitempty"` + OldestPendingEventTime *azuredevops.Time `json:"oldestPendingEventTime,omitempty"` + Publisher *string `json:"publisher,omitempty"` + UnprocessedEvents *int `json:"unprocessedEvents,omitempty"` +} + +type EventBatch struct { + EndTime interface{} `json:"endTime,omitempty"` + EventCounts *map[string]int `json:"eventCounts,omitempty"` + EventIds *string `json:"eventIds,omitempty"` + NotificationCounts *map[string]int `json:"notificationCounts,omitempty"` + PreProcessEndTime interface{} `json:"preProcessEndTime,omitempty"` + PreProcessStartTime interface{} `json:"preProcessStartTime,omitempty"` + ProcessEndTime interface{} `json:"processEndTime,omitempty"` + ProcessStartTime interface{} `json:"processStartTime,omitempty"` + StartTime interface{} `json:"startTime,omitempty"` + SubscriptionCounts *map[string]int `json:"subscriptionCounts,omitempty"` +} + +type EventProcessingLog struct { + // Identifier used for correlating to other diagnostics that may have been recorded elsewhere. + ActivityId *uuid.UUID `json:"activityId,omitempty"` + Description *string `json:"description,omitempty"` + EndTime *azuredevops.Time `json:"endTime,omitempty"` + Errors *int `json:"errors,omitempty"` + // Unique instance identifier. + Id *uuid.UUID `json:"id,omitempty"` + LogType *string `json:"logType,omitempty"` + Messages *[]NotificationDiagnosticLogMessage `json:"messages,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + // This identifier depends on the logType. For notification jobs, this will be the job Id. For subscription tracing, this will be a special root Guid with the subscription Id encoded. + Source *uuid.UUID `json:"source,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + Warnings *int `json:"warnings,omitempty"` + Result *string `json:"result,omitempty"` + Stats *map[string]map[string]int `json:"stats,omitempty"` + Batches *[]EventBatch `json:"batches,omitempty"` + MatcherResults *[]MatcherResult `json:"matcherResults,omitempty"` +} + +// [Flags] Set of flags used to determine which set of information is retrieved when querying for event publishers +type EventPublisherQueryFlags string + +type eventPublisherQueryFlagsValuesType struct { + None EventPublisherQueryFlags + IncludeRemoteServices EventPublisherQueryFlags +} + +var EventPublisherQueryFlagsValues = eventPublisherQueryFlagsValuesType{ + None: "none", + // Include event types from the remote services too + IncludeRemoteServices: "includeRemoteServices", +} + +// Encapsulates events result properties. It defines the total number of events used and the number of matched events. +type EventsEvaluationResult struct { + // Count of events evaluated. + Count *int `json:"count,omitempty"` + // Count of matched events. + MatchedCount *int `json:"matchedCount,omitempty"` +} + +// A transform request specify the properties of a notification event to be transformed. +type EventTransformRequest struct { + // Event payload. + EventPayload *string `json:"eventPayload,omitempty"` + // Event type. + EventType *string `json:"eventType,omitempty"` + // System inputs. + SystemInputs *map[string]string `json:"systemInputs,omitempty"` +} + +// Result of transforming a notification event. +type EventTransformResult struct { + // Transformed html content. + Content *string `json:"content,omitempty"` + // Calculated data. + Data interface{} `json:"data,omitempty"` + // Calculated system inputs. + SystemInputs *map[string]string `json:"systemInputs,omitempty"` +} + +// [Flags] Set of flags used to determine which set of information is retrieved when querying for eventtypes +type EventTypeQueryFlags string + +type eventTypeQueryFlagsValuesType struct { + None EventTypeQueryFlags + IncludeFields EventTypeQueryFlags +} + +var EventTypeQueryFlagsValues = eventTypeQueryFlagsValuesType{ + None: "none", + // IncludeFields will include all fields and their types + IncludeFields: "includeFields", +} + +type ExpressionFilter struct { + EventType *string `json:"eventType,omitempty"` + Criteria *ExpressionFilterModel `json:"criteria,omitempty"` + Type *string `json:"type,omitempty"` +} + +// Subscription Filter Clause represents a single clause in a subscription filter e.g. If the subscription has the following criteria "Project Name = [Current Project] AND Assigned To = [Me] it will be represented as two Filter Clauses Clause 1: Index = 1, Logical Operator: NULL , FieldName = 'Project Name', Operator = '=', Value = '[Current Project]' Clause 2: Index = 2, Logical Operator: 'AND' , FieldName = 'Assigned To' , Operator = '=', Value = '[Me]' +type ExpressionFilterClause struct { + FieldName *string `json:"fieldName,omitempty"` + // The order in which this clause appeared in the filter query + Index *int `json:"index,omitempty"` + // Logical Operator 'AND', 'OR' or NULL (only for the first clause in the filter) + LogicalOperator *string `json:"logicalOperator,omitempty"` + Operator *string `json:"operator,omitempty"` + Value *string `json:"value,omitempty"` +} + +// Represents a hierarchy of SubscritionFilterClauses that have been grouped together through either adding a group in the WebUI or using parethesis in the Subscription condition string +type ExpressionFilterGroup struct { + // The index of the last FilterClause in this group + End *int `json:"end,omitempty"` + // Level of the group, since groups can be nested for each nested group the level will increase by 1 + Level *int `json:"level,omitempty"` + // The index of the first FilterClause in this group + Start *int `json:"start,omitempty"` +} + +type ExpressionFilterModel struct { + // Flat list of clauses in this subscription + Clauses *[]ExpressionFilterClause `json:"clauses,omitempty"` + // Grouping of clauses in the subscription + Groups *[]ExpressionFilterGroup `json:"groups,omitempty"` + // Max depth of the Subscription tree + MaxGroupLevel *int `json:"maxGroupLevel,omitempty"` +} + +type FieldInputValues struct { + // The default value to use for this input + DefaultValue *string `json:"defaultValue,omitempty"` + // Errors encountered while computing dynamic values. + Error *forminput.InputValuesError `json:"error,omitempty"` + // The id of the input + InputId *string `json:"inputId,omitempty"` + // Should this input be disabled + IsDisabled *bool `json:"isDisabled,omitempty"` + // Should the value be restricted to one of the values in the PossibleValues (True) or are the values in PossibleValues just a suggestion (False) + IsLimitedToPossibleValues *bool `json:"isLimitedToPossibleValues,omitempty"` + // Should this input be made read-only + IsReadOnly *bool `json:"isReadOnly,omitempty"` + // Possible values that this input can take + PossibleValues *[]forminput.InputValue `json:"possibleValues,omitempty"` + Operators *[]byte `json:"operators,omitempty"` +} + +type FieldValuesQuery struct { + CurrentValues *map[string]string `json:"currentValues,omitempty"` + // Subscription containing information about the publisher/consumer and the current input values + Resource interface{} `json:"resource,omitempty"` + InputValues *[]FieldInputValues `json:"inputValues,omitempty"` + Scope *string `json:"scope,omitempty"` +} + +type GeneratedNotification struct { + Recipients *[]DiagnosticIdentity `json:"recipients,omitempty"` +} + +type GroupSubscriptionChannel struct { + Address *string `json:"address,omitempty"` + UseCustomAddress *bool `json:"useCustomAddress,omitempty"` + Type *string `json:"type,omitempty"` +} + +// Abstraction interface for the diagnostic log. Primarily for deserialization. +type INotificationDiagnosticLog struct { + // Identifier used for correlating to other diagnostics that may have been recorded elsewhere. + ActivityId *uuid.UUID `json:"activityId,omitempty"` + // Description of what subscription or notification job is being logged. + Description *string `json:"description,omitempty"` + // Time the log ended. + EndTime *azuredevops.Time `json:"endTime,omitempty"` + // Unique instance identifier. + Id *uuid.UUID `json:"id,omitempty"` + // Type of information being logged. + LogType *string `json:"logType,omitempty"` + // List of log messages. + Messages *[]NotificationDiagnosticLogMessage `json:"messages,omitempty"` + // Dictionary of log properties and settings for the job. + Properties *map[string]string `json:"properties,omitempty"` + // This identifier depends on the logType. For notification jobs, this will be the job Id. For subscription tracing, this will be a special root Guid with the subscription Id encoded. + Source *uuid.UUID `json:"source,omitempty"` + // Time the log started. + StartTime *azuredevops.Time `json:"startTime,omitempty"` +} + +type ISubscriptionChannel struct { + Type *string `json:"type,omitempty"` +} + +type ISubscriptionFilter struct { + EventType *string `json:"eventType,omitempty"` + Type *string `json:"type,omitempty"` +} + +type MatcherResult struct { + Matcher *string `json:"matcher,omitempty"` + Stats *map[string]map[string]int `json:"stats,omitempty"` +} + +type MessageQueueSubscriptionChannel struct { + Type *string `json:"type,omitempty"` +} + +type NotificationAdminSettings struct { + // The default group delivery preference for groups in this collection + DefaultGroupDeliveryPreference *DefaultGroupDeliveryPreference `json:"defaultGroupDeliveryPreference,omitempty"` +} + +type NotificationAdminSettingsUpdateParameters struct { + DefaultGroupDeliveryPreference *DefaultGroupDeliveryPreference `json:"defaultGroupDeliveryPreference,omitempty"` +} + +type NotificationBacklogStatus struct { + CaptureTime *azuredevops.Time `json:"captureTime,omitempty"` + Channel *string `json:"channel,omitempty"` + JobId *uuid.UUID `json:"jobId,omitempty"` + LastJobBatchStartTime *azuredevops.Time `json:"lastJobBatchStartTime,omitempty"` + LastJobProcessedTime *azuredevops.Time `json:"lastJobProcessedTime,omitempty"` + LastNotificationBatchStartTime *azuredevops.Time `json:"lastNotificationBatchStartTime,omitempty"` + LastNotificationProcessedTime *azuredevops.Time `json:"lastNotificationProcessedTime,omitempty"` + OldestPendingNotificationTime *azuredevops.Time `json:"oldestPendingNotificationTime,omitempty"` + Publisher *string `json:"publisher,omitempty"` + // Null status is unprocessed + Status *string `json:"status,omitempty"` + UnprocessedNotifications *int `json:"unprocessedNotifications,omitempty"` +} + +type NotificationBatch struct { + EndTime interface{} `json:"endTime,omitempty"` + NotificationCount *int `json:"notificationCount,omitempty"` + NotificationIds *string `json:"notificationIds,omitempty"` + ProblematicNotifications *[]DiagnosticNotification `json:"problematicNotifications,omitempty"` + StartTime interface{} `json:"startTime,omitempty"` +} + +type NotificationDeliveryLog struct { + // Identifier used for correlating to other diagnostics that may have been recorded elsewhere. + ActivityId *uuid.UUID `json:"activityId,omitempty"` + Description *string `json:"description,omitempty"` + EndTime *azuredevops.Time `json:"endTime,omitempty"` + Errors *int `json:"errors,omitempty"` + // Unique instance identifier. + Id *uuid.UUID `json:"id,omitempty"` + LogType *string `json:"logType,omitempty"` + Messages *[]NotificationDiagnosticLogMessage `json:"messages,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + // This identifier depends on the logType. For notification jobs, this will be the job Id. For subscription tracing, this will be a special root Guid with the subscription Id encoded. + Source *uuid.UUID `json:"source,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + Warnings *int `json:"warnings,omitempty"` + Result *string `json:"result,omitempty"` + Stats *map[string]map[string]int `json:"stats,omitempty"` + Batches *[]NotificationBatch `json:"batches,omitempty"` +} + +// Abstract base class for all of the diagnostic logs. +type NotificationDiagnosticLog struct { + // Identifier used for correlating to other diagnostics that may have been recorded elsewhere. + ActivityId *uuid.UUID `json:"activityId,omitempty"` + Description *string `json:"description,omitempty"` + EndTime *azuredevops.Time `json:"endTime,omitempty"` + Errors *int `json:"errors,omitempty"` + // Unique instance identifier. + Id *uuid.UUID `json:"id,omitempty"` + LogType *string `json:"logType,omitempty"` + Messages *[]NotificationDiagnosticLogMessage `json:"messages,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + // This identifier depends on the logType. For notification jobs, this will be the job Id. For subscription tracing, this will be a special root Guid with the subscription Id encoded. + Source *uuid.UUID `json:"source,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + Warnings *int `json:"warnings,omitempty"` +} + +type NotificationDiagnosticLogMessage struct { + // Corresponds to .Net TraceLevel enumeration + Level *int `json:"level,omitempty"` + Message *string `json:"message,omitempty"` + Time interface{} `json:"time,omitempty"` +} + +type NotificationEventBacklogStatus struct { + EventBacklogStatus *[]EventBacklogStatus `json:"eventBacklogStatus,omitempty"` + NotificationBacklogStatus *[]NotificationBacklogStatus `json:"notificationBacklogStatus,omitempty"` +} + +// Encapsulates the properties of a filterable field. A filterable field is a field in an event that can used to filter notifications for a certain event type. +type NotificationEventField struct { + // Gets or sets the type of this field. + FieldType *NotificationEventFieldType `json:"fieldType,omitempty"` + // Gets or sets the unique identifier of this field. + Id *string `json:"id,omitempty"` + // Gets or sets the name of this field. + Name *string `json:"name,omitempty"` + // Gets or sets the path to the field in the event object. This path can be either Json Path or XPath, depending on if the event will be serialized into Json or XML + Path *string `json:"path,omitempty"` + // Gets or sets the scopes that this field supports. If not specified then the event type scopes apply. + SupportedScopes *[]string `json:"supportedScopes,omitempty"` +} + +// Encapsulates the properties of a field type. It includes a unique id for the operator and a localized string for display name +type NotificationEventFieldOperator struct { + // Gets or sets the display name of an operator + DisplayName *string `json:"displayName,omitempty"` + // Gets or sets the id of an operator + Id *string `json:"id,omitempty"` +} + +// Encapsulates the properties of a field type. It describes the data type of a field, the operators it support and how to populate it in the UI +type NotificationEventFieldType struct { + // Gets or sets the unique identifier of this field type. + Id *string `json:"id,omitempty"` + OperatorConstraints *[]OperatorConstraint `json:"operatorConstraints,omitempty"` + // Gets or sets the list of operators that this type supports. + Operators *[]NotificationEventFieldOperator `json:"operators,omitempty"` + SubscriptionFieldType *SubscriptionFieldType `json:"subscriptionFieldType,omitempty"` + // Gets or sets the value definition of this field like the getValuesMethod and template to display in the UI + Value *ValueDefinition `json:"value,omitempty"` +} + +// Encapsulates the properties of a notification event publisher. +type NotificationEventPublisher struct { + Id *string `json:"id,omitempty"` + SubscriptionManagementInfo *SubscriptionManagement `json:"subscriptionManagementInfo,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Encapsulates the properties of an event role. An event Role is used for role based subscription for example for a buildCompletedEvent, one role is request by field +type NotificationEventRole struct { + // Gets or sets an Id for that role, this id is used by the event. + Id *string `json:"id,omitempty"` + // Gets or sets the Name for that role, this name is used for UI display. + Name *string `json:"name,omitempty"` + // Gets or sets whether this role can be a group or just an individual user + SupportsGroups *bool `json:"supportsGroups,omitempty"` +} + +// Encapsulates the properties of an event type. It defines the fields, that can be used for filtering, for that event type. +type NotificationEventType struct { + Category *NotificationEventTypeCategory `json:"category,omitempty"` + // Gets or sets the color representing this event type. Example: rgb(128,245,211) or #fafafa + Color *string `json:"color,omitempty"` + CustomSubscriptionsAllowed *bool `json:"customSubscriptionsAllowed,omitempty"` + EventPublisher *NotificationEventPublisher `json:"eventPublisher,omitempty"` + Fields *map[string]NotificationEventField `json:"fields,omitempty"` + HasInitiator *bool `json:"hasInitiator,omitempty"` + // Gets or sets the icon representing this event type. Can be a URL or a CSS class. Example: css://some-css-class + Icon *string `json:"icon,omitempty"` + // Gets or sets the unique identifier of this event definition. + Id *string `json:"id,omitempty"` + // Gets or sets the name of this event definition. + Name *string `json:"name,omitempty"` + Roles *[]NotificationEventRole `json:"roles,omitempty"` + // Gets or sets the scopes that this event type supports + SupportedScopes *[]string `json:"supportedScopes,omitempty"` + // Gets or sets the rest end point to get this event type details (fields, fields types) + Url *string `json:"url,omitempty"` +} + +// Encapsulates the properties of a category. A category will be used by the UI to group event types +type NotificationEventTypeCategory struct { + // Gets or sets the unique identifier of this category. + Id *string `json:"id,omitempty"` + // Gets or sets the friendly name of this category. + Name *string `json:"name,omitempty"` +} + +type NotificationJobDiagnosticLog struct { + // Identifier used for correlating to other diagnostics that may have been recorded elsewhere. + ActivityId *uuid.UUID `json:"activityId,omitempty"` + Description *string `json:"description,omitempty"` + EndTime *azuredevops.Time `json:"endTime,omitempty"` + Errors *int `json:"errors,omitempty"` + // Unique instance identifier. + Id *uuid.UUID `json:"id,omitempty"` + LogType *string `json:"logType,omitempty"` + Messages *[]NotificationDiagnosticLogMessage `json:"messages,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + // This identifier depends on the logType. For notification jobs, this will be the job Id. For subscription tracing, this will be a special root Guid with the subscription Id encoded. + Source *uuid.UUID `json:"source,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + Warnings *int `json:"warnings,omitempty"` + Result *string `json:"result,omitempty"` + Stats *map[string]map[string]int `json:"stats,omitempty"` +} + +type NotificationOperation string + +type notificationOperationValuesType struct { + None NotificationOperation + SuspendUnprocessed NotificationOperation +} + +var NotificationOperationValues = notificationOperationValuesType{ + None: "none", + SuspendUnprocessed: "suspendUnprocessed", +} + +type NotificationQueryCondition struct { + EventInitiator *uuid.UUID `json:"eventInitiator,omitempty"` + EventType *string `json:"eventType,omitempty"` + Subscriber *uuid.UUID `json:"subscriber,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` +} + +type NotificationReason struct { + NotificationReasonType *NotificationReasonType `json:"notificationReasonType,omitempty"` + TargetIdentities *[]webapi.IdentityRef `json:"targetIdentities,omitempty"` +} + +type NotificationReasonType string + +type notificationReasonTypeValuesType struct { + Unknown NotificationReasonType + Follows NotificationReasonType + Personal NotificationReasonType + PersonalAlias NotificationReasonType + DirectMember NotificationReasonType + IndirectMember NotificationReasonType + GroupAlias NotificationReasonType + SubscriptionAlias NotificationReasonType + SingleRole NotificationReasonType + DirectMemberGroupRole NotificationReasonType + InDirectMemberGroupRole NotificationReasonType + AliasMemberGroupRole NotificationReasonType +} + +var NotificationReasonTypeValues = notificationReasonTypeValuesType{ + Unknown: "unknown", + Follows: "follows", + Personal: "personal", + PersonalAlias: "personalAlias", + DirectMember: "directMember", + IndirectMember: "indirectMember", + GroupAlias: "groupAlias", + SubscriptionAlias: "subscriptionAlias", + SingleRole: "singleRole", + DirectMemberGroupRole: "directMemberGroupRole", + InDirectMemberGroupRole: "inDirectMemberGroupRole", + AliasMemberGroupRole: "aliasMemberGroupRole", +} + +// Encapsulates notifications result properties. It defines the number of notifications and the recipients of notifications. +type NotificationsEvaluationResult struct { + // Count of generated notifications + Count *int `json:"count,omitempty"` +} + +type NotificationStatistic struct { + Date *azuredevops.Time `json:"date,omitempty"` + HitCount *int `json:"hitCount,omitempty"` + Path *string `json:"path,omitempty"` + Type *NotificationStatisticType `json:"type,omitempty"` + User *webapi.IdentityRef `json:"user,omitempty"` +} + +type NotificationStatisticsQuery struct { + Conditions *[]NotificationStatisticsQueryConditions `json:"conditions,omitempty"` +} + +type NotificationStatisticsQueryConditions struct { + EndDate *azuredevops.Time `json:"endDate,omitempty"` + HitCountMinimum *int `json:"hitCountMinimum,omitempty"` + Path *string `json:"path,omitempty"` + StartDate *azuredevops.Time `json:"startDate,omitempty"` + Type *NotificationStatisticType `json:"type,omitempty"` + User *webapi.IdentityRef `json:"user,omitempty"` +} + +type NotificationStatisticType string + +type notificationStatisticTypeValuesType struct { + NotificationBySubscription NotificationStatisticType + EventsByEventType NotificationStatisticType + NotificationByEventType NotificationStatisticType + EventsByEventTypePerUser NotificationStatisticType + NotificationByEventTypePerUser NotificationStatisticType + Events NotificationStatisticType + Notifications NotificationStatisticType + NotificationFailureBySubscription NotificationStatisticType + UnprocessedRangeStart NotificationStatisticType + UnprocessedEventsByPublisher NotificationStatisticType + UnprocessedEventDelayByPublisher NotificationStatisticType + UnprocessedNotificationsByChannelByPublisher NotificationStatisticType + UnprocessedNotificationDelayByChannelByPublisher NotificationStatisticType + DelayRangeStart NotificationStatisticType + TotalPipelineTime NotificationStatisticType + NotificationPipelineTime NotificationStatisticType + EventPipelineTime NotificationStatisticType + HourlyRangeStart NotificationStatisticType + HourlyNotificationBySubscription NotificationStatisticType + HourlyEventsByEventTypePerUser NotificationStatisticType + HourlyEvents NotificationStatisticType + HourlyNotifications NotificationStatisticType + HourlyUnprocessedEventsByPublisher NotificationStatisticType + HourlyUnprocessedEventDelayByPublisher NotificationStatisticType + HourlyUnprocessedNotificationsByChannelByPublisher NotificationStatisticType + HourlyUnprocessedNotificationDelayByChannelByPublisher NotificationStatisticType + HourlyTotalPipelineTime NotificationStatisticType + HourlyNotificationPipelineTime NotificationStatisticType + HourlyEventPipelineTime NotificationStatisticType +} + +var NotificationStatisticTypeValues = notificationStatisticTypeValuesType{ + NotificationBySubscription: "notificationBySubscription", + EventsByEventType: "eventsByEventType", + NotificationByEventType: "notificationByEventType", + EventsByEventTypePerUser: "eventsByEventTypePerUser", + NotificationByEventTypePerUser: "notificationByEventTypePerUser", + Events: "events", + Notifications: "notifications", + NotificationFailureBySubscription: "notificationFailureBySubscription", + UnprocessedRangeStart: "unprocessedRangeStart", + UnprocessedEventsByPublisher: "unprocessedEventsByPublisher", + UnprocessedEventDelayByPublisher: "unprocessedEventDelayByPublisher", + UnprocessedNotificationsByChannelByPublisher: "unprocessedNotificationsByChannelByPublisher", + UnprocessedNotificationDelayByChannelByPublisher: "unprocessedNotificationDelayByChannelByPublisher", + DelayRangeStart: "delayRangeStart", + TotalPipelineTime: "totalPipelineTime", + NotificationPipelineTime: "notificationPipelineTime", + EventPipelineTime: "eventPipelineTime", + HourlyRangeStart: "hourlyRangeStart", + HourlyNotificationBySubscription: "hourlyNotificationBySubscription", + HourlyEventsByEventTypePerUser: "hourlyEventsByEventTypePerUser", + HourlyEvents: "hourlyEvents", + HourlyNotifications: "hourlyNotifications", + HourlyUnprocessedEventsByPublisher: "hourlyUnprocessedEventsByPublisher", + HourlyUnprocessedEventDelayByPublisher: "hourlyUnprocessedEventDelayByPublisher", + HourlyUnprocessedNotificationsByChannelByPublisher: "hourlyUnprocessedNotificationsByChannelByPublisher", + HourlyUnprocessedNotificationDelayByChannelByPublisher: "hourlyUnprocessedNotificationDelayByChannelByPublisher", + HourlyTotalPipelineTime: "hourlyTotalPipelineTime", + HourlyNotificationPipelineTime: "hourlyNotificationPipelineTime", + HourlyEventPipelineTime: "hourlyEventPipelineTime", +} + +// A subscriber is a user or group that has the potential to receive notifications. +type NotificationSubscriber struct { + // Indicates how the subscriber should be notified by default. + DeliveryPreference *NotificationSubscriberDeliveryPreference `json:"deliveryPreference,omitempty"` + Flags *SubscriberFlags `json:"flags,omitempty"` + // Identifier of the subscriber. + Id *uuid.UUID `json:"id,omitempty"` + // Preferred email address of the subscriber. A null or empty value indicates no preferred email address has been set. + PreferredEmailAddress *string `json:"preferredEmailAddress,omitempty"` +} + +// Delivery preference for a subscriber. Indicates how the subscriber should be notified. +type NotificationSubscriberDeliveryPreference string + +type notificationSubscriberDeliveryPreferenceValuesType struct { + NoDelivery NotificationSubscriberDeliveryPreference + PreferredEmailAddress NotificationSubscriberDeliveryPreference + EachMember NotificationSubscriberDeliveryPreference + UseDefault NotificationSubscriberDeliveryPreference +} + +var NotificationSubscriberDeliveryPreferenceValues = notificationSubscriberDeliveryPreferenceValuesType{ + // Do not send notifications by default. Note: notifications can still be delivered to this subscriber, for example via a custom subscription. + NoDelivery: "noDelivery", + // Deliver notifications to the subscriber's preferred email address. + PreferredEmailAddress: "preferredEmailAddress", + // Deliver notifications to each member of the group representing the subscriber. Only applicable when the subscriber is a group. + EachMember: "eachMember", + // Use default + UseDefault: "useDefault", +} + +// Updates to a subscriber. Typically used to change (or set) a preferred email address or default delivery preference. +type NotificationSubscriberUpdateParameters struct { + // New delivery preference for the subscriber (indicates how the subscriber should be notified). + DeliveryPreference *NotificationSubscriberDeliveryPreference `json:"deliveryPreference,omitempty"` + // New preferred email address for the subscriber. Specify an empty string to clear the current address. + PreferredEmailAddress *string `json:"preferredEmailAddress,omitempty"` +} + +// A subscription defines criteria for matching events and how the subscription's subscriber should be notified about those events. +type NotificationSubscription struct { + // Links to related resources, APIs, and views for the subscription. + Links interface{} `json:"_links,omitempty"` + // Admin-managed settings for the subscription. Only applies when the subscriber is a group. + AdminSettings *SubscriptionAdminSettings `json:"adminSettings,omitempty"` + // Channel for delivering notifications triggered by the subscription. + Channel *ISubscriptionChannel `json:"channel,omitempty"` + // Description of the subscription. Typically describes filter criteria which helps identity the subscription. + Description *string `json:"description,omitempty"` + // Diagnostics for this subscription. + Diagnostics *SubscriptionDiagnostics `json:"diagnostics,omitempty"` + // Any extra properties like detailed description for different contexts, user/group contexts + ExtendedProperties *map[string]string `json:"extendedProperties,omitempty"` + // Matching criteria for the subscription. ExpressionFilter + Filter *ISubscriptionFilter `json:"filter,omitempty"` + // Read-only indicators that further describe the subscription. + Flags *SubscriptionFlags `json:"flags,omitempty"` + // Subscription identifier. + Id *string `json:"id,omitempty"` + // User that last modified (or created) the subscription. + LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` + // Date when the subscription was last modified. If the subscription has not been updated since it was created, this value will indicate when the subscription was created. + ModifiedDate *azuredevops.Time `json:"modifiedDate,omitempty"` + // The permissions the user have for this subscriptions. + Permissions *SubscriptionPermissions `json:"permissions,omitempty"` + // The container in which events must be published from in order to be matched by the subscription. If empty, the scope is the current host (typically an account or project collection). For example, a subscription scoped to project A will not produce notifications for events published from project B. + Scope *SubscriptionScope `json:"scope,omitempty"` + // Status of the subscription. Typically indicates whether the subscription is enabled or not. + Status *SubscriptionStatus `json:"status,omitempty"` + // Message that provides more details about the status of the subscription. + StatusMessage *string `json:"statusMessage,omitempty"` + // User or group that will receive notifications for events matching the subscription's filter criteria. + Subscriber *webapi.IdentityRef `json:"subscriber,omitempty"` + // REST API URL of the subscriotion. + Url *string `json:"url,omitempty"` + // User-managed settings for the subscription. Only applies when the subscriber is a group. Typically used to indicate whether the calling user is opted in or out of a group subscription. + UserSettings *SubscriptionUserSettings `json:"userSettings,omitempty"` +} + +// Parameters for creating a new subscription. A subscription defines criteria for matching events and how the subscription's subscriber should be notified about those events. +type NotificationSubscriptionCreateParameters struct { + // Channel for delivering notifications triggered by the new subscription. + Channel *ISubscriptionChannel `json:"channel,omitempty"` + // Brief description for the new subscription. Typically describes filter criteria which helps identity the subscription. + Description *string `json:"description,omitempty"` + // Matching criteria for the new subscription. ExpressionFilter + Filter *ISubscriptionFilter `json:"filter,omitempty"` + // The container in which events must be published from in order to be matched by the new subscription. If not specified, defaults to the current host (typically an account or project collection). For example, a subscription scoped to project A will not produce notifications for events published from project B. + Scope *SubscriptionScope `json:"scope,omitempty"` + // User or group that will receive notifications for events matching the subscription's filter criteria. If not specified, defaults to the calling user. + Subscriber *webapi.IdentityRef `json:"subscriber,omitempty"` +} + +type NotificationSubscriptionTemplate struct { + Description *string `json:"description,omitempty"` + Filter *ISubscriptionFilter `json:"filter,omitempty"` + Id *string `json:"id,omitempty"` + NotificationEventInformation *NotificationEventType `json:"notificationEventInformation,omitempty"` + Type *SubscriptionTemplateType `json:"type,omitempty"` +} + +// Parameters for updating an existing subscription. A subscription defines criteria for matching events and how the subscription's subscriber should be notified about those events. Note: only the fields to be updated should be set. +type NotificationSubscriptionUpdateParameters struct { + // Admin-managed settings for the subscription. Only applies to subscriptions where the subscriber is a group. + AdminSettings *SubscriptionAdminSettings `json:"adminSettings,omitempty"` + // Channel for delivering notifications triggered by the subscription. + Channel *ISubscriptionChannel `json:"channel,omitempty"` + // Updated description for the subscription. Typically describes filter criteria which helps identity the subscription. + Description *string `json:"description,omitempty"` + // Matching criteria for the subscription. ExpressionFilter + Filter *ISubscriptionFilter `json:"filter,omitempty"` + // The container in which events must be published from in order to be matched by the new subscription. If not specified, defaults to the current host (typically the current account or project collection). For example, a subscription scoped to project A will not produce notifications for events published from project B. + Scope *SubscriptionScope `json:"scope,omitempty"` + // Updated status for the subscription. Typically used to enable or disable a subscription. + Status *SubscriptionStatus `json:"status,omitempty"` + // Optional message that provides more details about the updated status. + StatusMessage *string `json:"statusMessage,omitempty"` + // User-managed settings for the subscription. Only applies to subscriptions where the subscriber is a group. Typically used to opt-in or opt-out a user from a group subscription. + UserSettings *SubscriptionUserSettings `json:"userSettings,omitempty"` +} + +// Encapsulates the properties of an operator constraint. An operator constraint defines if some operator is available only for specific scope like a project scope. +type OperatorConstraint struct { + Operator *string `json:"operator,omitempty"` + // Gets or sets the list of scopes that this type supports. + SupportedScopes *[]string `json:"supportedScopes,omitempty"` +} + +type ProcessedEvent struct { + // All of the users that were associated with this event and their role. + Actors *[]webapi.EventActor `json:"actors,omitempty"` + AllowedChannels *string `json:"allowedChannels,omitempty"` + ArtifactUri *string `json:"artifactUri,omitempty"` + DeliveryIdentities *ProcessingIdentities `json:"deliveryIdentities,omitempty"` + // Evaluations for each user + Evaluations *map[uuid.UUID]SubscriptionEvaluation `json:"evaluations,omitempty"` + EventId *int `json:"eventId,omitempty"` + // Which members were excluded from evaluation (only applies to ActorMatcher subscriptions) + Exclusions *[]webapi.EventActor `json:"exclusions,omitempty"` + // Which members were included for evaluation (only applies to ActorMatcher subscriptions) + Inclusions *[]webapi.EventActor `json:"inclusions,omitempty"` + Notifications *[]GeneratedNotification `json:"notifications,omitempty"` +} + +type ProcessingDiagnosticIdentity struct { + DisplayName *string `json:"displayName,omitempty"` + EmailAddress *string `json:"emailAddress,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + DeliveryPreference *string `json:"deliveryPreference,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + IsGroup *bool `json:"isGroup,omitempty"` + Message *string `json:"message,omitempty"` +} + +type ProcessingIdentities struct { + ExcludedIdentities *map[uuid.UUID]ProcessingDiagnosticIdentity `json:"excludedIdentities,omitempty"` + IncludedIdentities *map[uuid.UUID]ProcessingDiagnosticIdentity `json:"includedIdentities,omitempty"` + Messages *[]NotificationDiagnosticLogMessage `json:"messages,omitempty"` + MissingIdentities *[]uuid.UUID `json:"missingIdentities,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` +} + +type RoleBasedFilter struct { + EventType *string `json:"eventType,omitempty"` + Criteria *ExpressionFilterModel `json:"criteria,omitempty"` + Type *string `json:"type,omitempty"` + Exclusions *[]string `json:"exclusions,omitempty"` + Inclusions *[]string `json:"inclusions,omitempty"` +} + +type ServiceBusSubscriptionChannel struct { + Type *string `json:"type,omitempty"` +} + +type ServiceHooksSubscriptionChannel struct { + Type *string `json:"type,omitempty"` +} + +type SoapSubscriptionChannel struct { + Address *string `json:"address,omitempty"` + UseCustomAddress *bool `json:"useCustomAddress,omitempty"` + Type *string `json:"type,omitempty"` +} + +// [Flags] +type SubscriberFlags string + +type subscriberFlagsValuesType struct { + None SubscriberFlags + DeliveryPreferencesEditable SubscriberFlags + SupportsPreferredEmailAddressDelivery SubscriberFlags + SupportsEachMemberDelivery SubscriberFlags + SupportsNoDelivery SubscriberFlags + IsUser SubscriberFlags + IsGroup SubscriberFlags + IsTeam SubscriberFlags +} + +var SubscriberFlagsValues = subscriberFlagsValuesType{ + None: "none", + // Subscriber's delivery preferences could be updated + DeliveryPreferencesEditable: "deliveryPreferencesEditable", + // Subscriber's delivery preferences supports email delivery + SupportsPreferredEmailAddressDelivery: "supportsPreferredEmailAddressDelivery", + // Subscriber's delivery preferences supports individual members delivery(group expansion) + SupportsEachMemberDelivery: "supportsEachMemberDelivery", + // Subscriber's delivery preferences supports no delivery + SupportsNoDelivery: "supportsNoDelivery", + // Subscriber is a user + IsUser: "isUser", + // Subscriber is a group + IsGroup: "isGroup", + // Subscriber is a team + IsTeam: "isTeam", +} + +// Admin-managed settings for a group subscription. +type SubscriptionAdminSettings struct { + // If true, members of the group subscribed to the associated subscription cannot opt (choose not to get notified) + BlockUserOptOut *bool `json:"blockUserOptOut,omitempty"` +} + +type SubscriptionChannelWithAddress struct { + Address *string `json:"address,omitempty"` + Type *string `json:"type,omitempty"` + UseCustomAddress *bool `json:"useCustomAddress,omitempty"` +} + +// Contains all the diagnostics settings for a subscription. +type SubscriptionDiagnostics struct { + // Diagnostics settings for retaining delivery results. Used for Service Hooks subscriptions. + DeliveryResults *SubscriptionTracing `json:"deliveryResults,omitempty"` + // Diagnostics settings for troubleshooting notification delivery. + DeliveryTracing *SubscriptionTracing `json:"deliveryTracing,omitempty"` + // Diagnostics settings for troubleshooting event matching. + EvaluationTracing *SubscriptionTracing `json:"evaluationTracing,omitempty"` +} + +type SubscriptionEvaluation struct { + Clauses *[]SubscriptionEvaluationClause `json:"clauses,omitempty"` + User *DiagnosticIdentity `json:"user,omitempty"` +} + +type SubscriptionEvaluationClause struct { + Clause *string `json:"clause,omitempty"` + Order *int `json:"order,omitempty"` + Result *bool `json:"result,omitempty"` +} + +// Encapsulates the properties of a SubscriptionEvaluationRequest. It defines the subscription to be evaluated and time interval for events used in evaluation. +type SubscriptionEvaluationRequest struct { + // The min created date for the events used for matching in UTC. Use all events created since this date + MinEventsCreatedDate *azuredevops.Time `json:"minEventsCreatedDate,omitempty"` + // User or group that will receive notifications for events matching the subscription's filter criteria. If not specified, defaults to the calling user. + SubscriptionCreateParameters *NotificationSubscriptionCreateParameters `json:"subscriptionCreateParameters,omitempty"` +} + +// Encapsulates the subscription evaluation results. It defines the Date Interval that was used, number of events evaluated and events and notifications results +type SubscriptionEvaluationResult struct { + // Subscription evaluation job status + EvaluationJobStatus *EvaluationOperationStatus `json:"evaluationJobStatus,omitempty"` + // Subscription evaluation events results. + Events *EventsEvaluationResult `json:"events,omitempty"` + // The requestId which is the subscription evaluation jobId + Id *uuid.UUID `json:"id,omitempty"` + // Subscription evaluation notification results. + Notifications *NotificationsEvaluationResult `json:"notifications,omitempty"` +} + +// Encapsulates the subscription evaluation settings needed for the UI +type SubscriptionEvaluationSettings struct { + // Indicates whether subscription evaluation before saving is enabled or not + Enabled *bool `json:"enabled,omitempty"` + // Time interval to check on subscription evaluation job in seconds + Interval *int `json:"interval,omitempty"` + // Threshold on the number of notifications for considering a subscription too noisy + Threshold *int `json:"threshold,omitempty"` + // Time out for the subscription evaluation check in seconds + TimeOut *int `json:"timeOut,omitempty"` +} + +type SubscriptionFieldType string + +type subscriptionFieldTypeValuesType struct { + String SubscriptionFieldType + Integer SubscriptionFieldType + DateTime SubscriptionFieldType + PlainText SubscriptionFieldType + Html SubscriptionFieldType + TreePath SubscriptionFieldType + History SubscriptionFieldType + Double SubscriptionFieldType + Guid SubscriptionFieldType + Boolean SubscriptionFieldType + Identity SubscriptionFieldType + PicklistInteger SubscriptionFieldType + PicklistString SubscriptionFieldType + PicklistDouble SubscriptionFieldType + TeamProject SubscriptionFieldType +} + +var SubscriptionFieldTypeValues = subscriptionFieldTypeValuesType{ + String: "string", + Integer: "integer", + DateTime: "dateTime", + PlainText: "plainText", + Html: "html", + TreePath: "treePath", + History: "history", + Double: "double", + Guid: "guid", + Boolean: "boolean", + Identity: "identity", + PicklistInteger: "picklistInteger", + PicklistString: "picklistString", + PicklistDouble: "picklistDouble", + TeamProject: "teamProject", +} + +// [Flags] Read-only indicators that further describe the subscription. +type SubscriptionFlags string + +type subscriptionFlagsValuesType struct { + None SubscriptionFlags + GroupSubscription SubscriptionFlags + ContributedSubscription SubscriptionFlags + CanOptOut SubscriptionFlags + TeamSubscription SubscriptionFlags + OneActorMatches SubscriptionFlags +} + +var SubscriptionFlagsValues = subscriptionFlagsValuesType{ + // None + None: "none", + // Subscription's subscriber is a group, not a user + GroupSubscription: "groupSubscription", + // Subscription is contributed and not persisted. This means certain fields of the subscription, like Filter, are read-only. + ContributedSubscription: "contributedSubscription", + // A user that is member of the subscription's subscriber group can opt in/out of the subscription. + CanOptOut: "canOptOut", + // If the subscriber is a group, is it a team. + TeamSubscription: "teamSubscription", + // For role based subscriptions, there is an expectation that there will always be at least one actor that matches + OneActorMatches: "oneActorMatches", +} + +// Encapsulates the properties needed to manage subscriptions, opt in and out of subscriptions. +type SubscriptionManagement struct { + ServiceInstanceType *uuid.UUID `json:"serviceInstanceType,omitempty"` + Url *string `json:"url,omitempty"` +} + +// [Flags] The permissions that a user has to a certain subscription +type SubscriptionPermissions string + +type subscriptionPermissionsValuesType struct { + None SubscriptionPermissions + View SubscriptionPermissions + Edit SubscriptionPermissions + Delete SubscriptionPermissions +} + +var SubscriptionPermissionsValues = subscriptionPermissionsValuesType{ + // None + None: "none", + // full view of description, filters, etc. Not limited. + View: "view", + // update subscription + Edit: "edit", + // delete subscription + Delete: "delete", +} + +// Notification subscriptions query input. +type SubscriptionQuery struct { + // One or more conditions to query on. If more than 2 conditions are specified, the combined results of each condition is returned (i.e. conditions are logically OR'ed). + Conditions *[]SubscriptionQueryCondition `json:"conditions,omitempty"` + // Flags the refine the types of subscriptions that will be returned from the query. + QueryFlags *SubscriptionQueryFlags `json:"queryFlags,omitempty"` +} + +// Conditions a subscription must match to qualify for the query result set. Not all fields are required. A subscription must match all conditions specified in order to qualify for the result set. +type SubscriptionQueryCondition struct { + // Filter conditions that matching subscriptions must have. Typically only the filter's type and event type are used for matching. + Filter *ISubscriptionFilter `json:"filter,omitempty"` + // Flags to specify the the type subscriptions to query for. + Flags *SubscriptionFlags `json:"flags,omitempty"` + // Scope that matching subscriptions must have. + Scope *string `json:"scope,omitempty"` + // ID of the subscriber (user or group) that matching subscriptions must be subscribed to. + SubscriberId *uuid.UUID `json:"subscriberId,omitempty"` + // ID of the subscription to query for. + SubscriptionId *string `json:"subscriptionId,omitempty"` +} + +// [Flags] Flags that influence the result set of a subscription query. +type SubscriptionQueryFlags string + +type subscriptionQueryFlagsValuesType struct { + None SubscriptionQueryFlags + IncludeInvalidSubscriptions SubscriptionQueryFlags + IncludeDeletedSubscriptions SubscriptionQueryFlags + IncludeFilterDetails SubscriptionQueryFlags + AlwaysReturnBasicInformation SubscriptionQueryFlags + IncludeSystemSubscriptions SubscriptionQueryFlags +} + +var SubscriptionQueryFlagsValues = subscriptionQueryFlagsValuesType{ + None: "none", + // Include subscriptions with invalid subscribers. + IncludeInvalidSubscriptions: "includeInvalidSubscriptions", + // Include subscriptions marked for deletion. + IncludeDeletedSubscriptions: "includeDeletedSubscriptions", + // Include the full filter details with each subscription. + IncludeFilterDetails: "includeFilterDetails", + // For a subscription the caller does not have permission to view, return basic (non-confidential) information. + AlwaysReturnBasicInformation: "alwaysReturnBasicInformation", + // Include system subscriptions. + IncludeSystemSubscriptions: "includeSystemSubscriptions", +} + +// A resource, typically an account or project, in which events are published from. +type SubscriptionScope 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"` +} + +// Subscription status values. A value greater than or equal to zero indicates the subscription is enabled. A negative value indicates the subscription is disabled. +type SubscriptionStatus string + +type subscriptionStatusValuesType struct { + JailedByNotificationsVolume SubscriptionStatus + PendingDeletion SubscriptionStatus + DisabledArgumentException SubscriptionStatus + DisabledProjectInvalid SubscriptionStatus + DisabledMissingPermissions SubscriptionStatus + DisabledFromProbation SubscriptionStatus + DisabledInactiveIdentity SubscriptionStatus + DisabledMessageQueueNotSupported SubscriptionStatus + DisabledMissingIdentity SubscriptionStatus + DisabledInvalidRoleExpression SubscriptionStatus + DisabledInvalidPathClause SubscriptionStatus + DisabledAsDuplicateOfDefault SubscriptionStatus + DisabledByAdmin SubscriptionStatus + Disabled SubscriptionStatus + Enabled SubscriptionStatus + EnabledOnProbation SubscriptionStatus +} + +var SubscriptionStatusValues = subscriptionStatusValuesType{ + // Subscription is disabled because it generated a high volume of notifications. + JailedByNotificationsVolume: "jailedByNotificationsVolume", + // Subscription is disabled and will be deleted. + PendingDeletion: "pendingDeletion", + // Subscription is disabled because of an Argument Exception while processing the subscription + DisabledArgumentException: "disabledArgumentException", + // Subscription is disabled because the project is invalid + DisabledProjectInvalid: "disabledProjectInvalid", + // Subscription is disabled because the identity does not have the appropriate permissions + DisabledMissingPermissions: "disabledMissingPermissions", + // Subscription is disabled service due to failures. + DisabledFromProbation: "disabledFromProbation", + // Subscription is disabled because the identity is no longer active + DisabledInactiveIdentity: "disabledInactiveIdentity", + // Subscription is disabled because message queue is not supported. + DisabledMessageQueueNotSupported: "disabledMessageQueueNotSupported", + // Subscription is disabled because its subscriber is unknown. + DisabledMissingIdentity: "disabledMissingIdentity", + // Subscription is disabled because it has an invalid role expression. + DisabledInvalidRoleExpression: "disabledInvalidRoleExpression", + // Subscription is disabled because it has an invalid filter expression. + DisabledInvalidPathClause: "disabledInvalidPathClause", + // Subscription is disabled because it is a duplicate of a default subscription. + DisabledAsDuplicateOfDefault: "disabledAsDuplicateOfDefault", + // Subscription is disabled by an administrator, not the subscription's subscriber. + DisabledByAdmin: "disabledByAdmin", + // Subscription is disabled, typically by the owner of the subscription, and will not produce any notifications. + Disabled: "disabled", + // Subscription is active. + Enabled: "enabled", + // Subscription is active, but is on probation due to failed deliveries or other issues with the subscription. + EnabledOnProbation: "enabledOnProbation", +} + +// [Flags] Set of flags used to determine which set of templates is retrieved when querying for subscription templates +type SubscriptionTemplateQueryFlags string + +type subscriptionTemplateQueryFlagsValuesType struct { + None SubscriptionTemplateQueryFlags + IncludeUser SubscriptionTemplateQueryFlags + IncludeGroup SubscriptionTemplateQueryFlags + IncludeUserAndGroup SubscriptionTemplateQueryFlags + IncludeEventTypeInformation SubscriptionTemplateQueryFlags +} + +var SubscriptionTemplateQueryFlagsValues = subscriptionTemplateQueryFlagsValuesType{ + None: "none", + // Include user templates + IncludeUser: "includeUser", + // Include group templates + IncludeGroup: "includeGroup", + // Include user and group templates + IncludeUserAndGroup: "includeUserAndGroup", + // Include the event type details like the fields and operators + IncludeEventTypeInformation: "includeEventTypeInformation", +} + +type SubscriptionTemplateType string + +type subscriptionTemplateTypeValuesType struct { + User SubscriptionTemplateType + Team SubscriptionTemplateType + Both SubscriptionTemplateType + None SubscriptionTemplateType +} + +var SubscriptionTemplateTypeValues = subscriptionTemplateTypeValuesType{ + User: "user", + Team: "team", + Both: "both", + None: "none", +} + +type SubscriptionTraceDiagnosticLog struct { + // Identifier used for correlating to other diagnostics that may have been recorded elsewhere. + ActivityId *uuid.UUID `json:"activityId,omitempty"` + Description *string `json:"description,omitempty"` + EndTime *azuredevops.Time `json:"endTime,omitempty"` + Errors *int `json:"errors,omitempty"` + // Unique instance identifier. + Id *uuid.UUID `json:"id,omitempty"` + LogType *string `json:"logType,omitempty"` + Messages *[]NotificationDiagnosticLogMessage `json:"messages,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + // This identifier depends on the logType. For notification jobs, this will be the job Id. For subscription tracing, this will be a special root Guid with the subscription Id encoded. + Source *uuid.UUID `json:"source,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + Warnings *int `json:"warnings,omitempty"` + // Indicates the job Id that processed or delivered this subscription + JobId *uuid.UUID `json:"jobId,omitempty"` + // Indicates unique instance identifier for the job that processed or delivered this subscription + JobInstanceId *uuid.UUID `json:"jobInstanceId,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` +} + +type SubscriptionTraceEventProcessingLog struct { + // Identifier used for correlating to other diagnostics that may have been recorded elsewhere. + ActivityId *uuid.UUID `json:"activityId,omitempty"` + Description *string `json:"description,omitempty"` + EndTime *azuredevops.Time `json:"endTime,omitempty"` + Errors *int `json:"errors,omitempty"` + // Unique instance identifier. + Id *uuid.UUID `json:"id,omitempty"` + LogType *string `json:"logType,omitempty"` + Messages *[]NotificationDiagnosticLogMessage `json:"messages,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + // This identifier depends on the logType. For notification jobs, this will be the job Id. For subscription tracing, this will be a special root Guid with the subscription Id encoded. + Source *uuid.UUID `json:"source,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + Warnings *int `json:"warnings,omitempty"` + // Indicates the job Id that processed or delivered this subscription + JobId *uuid.UUID `json:"jobId,omitempty"` + // Indicates unique instance identifier for the job that processed or delivered this subscription + JobInstanceId *uuid.UUID `json:"jobInstanceId,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + Channel *string `json:"channel,omitempty"` + EvaluationIdentities *ProcessingIdentities `json:"evaluationIdentities,omitempty"` + // Which members opted out from receiving notifications from this subscription + OptedOut *[]DiagnosticIdentity `json:"optedOut,omitempty"` + ProcessedEvents *map[int]ProcessedEvent `json:"processedEvents,omitempty"` +} + +type SubscriptionTraceNotificationDeliveryLog struct { + // Identifier used for correlating to other diagnostics that may have been recorded elsewhere. + ActivityId *uuid.UUID `json:"activityId,omitempty"` + Description *string `json:"description,omitempty"` + EndTime *azuredevops.Time `json:"endTime,omitempty"` + Errors *int `json:"errors,omitempty"` + // Unique instance identifier. + Id *uuid.UUID `json:"id,omitempty"` + LogType *string `json:"logType,omitempty"` + Messages *[]NotificationDiagnosticLogMessage `json:"messages,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + // This identifier depends on the logType. For notification jobs, this will be the job Id. For subscription tracing, this will be a special root Guid with the subscription Id encoded. + Source *uuid.UUID `json:"source,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + Warnings *int `json:"warnings,omitempty"` + // Indicates the job Id that processed or delivered this subscription + JobId *uuid.UUID `json:"jobId,omitempty"` + // Indicates unique instance identifier for the job that processed or delivered this subscription + JobInstanceId *uuid.UUID `json:"jobInstanceId,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + Notifications *[]DiagnosticNotification `json:"notifications,omitempty"` +} + +// Data controlling a single diagnostic setting for a subscription. +type SubscriptionTracing struct { + // Indicates whether the diagnostic tracing is enabled or not. + Enabled *bool `json:"enabled,omitempty"` + // Trace until the specified end date. + EndDate *azuredevops.Time `json:"endDate,omitempty"` + // The maximum number of result details to trace. + MaxTracedEntries *int `json:"maxTracedEntries,omitempty"` + // The date and time tracing started. + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // Trace until remaining count reaches 0. + TracedEntries *int `json:"tracedEntries,omitempty"` +} + +// User-managed settings for a group subscription. +type SubscriptionUserSettings struct { + // Indicates whether the user will receive notifications for the associated group subscription. + OptedOut *bool `json:"optedOut,omitempty"` +} + +type UnsupportedFilter struct { + EventType *string `json:"eventType,omitempty"` + Type *string `json:"type,omitempty"` +} + +type UnsupportedSubscriptionChannel struct { + Type *string `json:"type,omitempty"` +} + +// Parameters to update diagnostics settings for a subscription. +type UpdateSubscripitonDiagnosticsParameters struct { + // Diagnostics settings for retaining delivery results. Used for Service Hooks subscriptions. + DeliveryResults *UpdateSubscripitonTracingParameters `json:"deliveryResults,omitempty"` + // Diagnostics settings for troubleshooting notification delivery. + DeliveryTracing *UpdateSubscripitonTracingParameters `json:"deliveryTracing,omitempty"` + // Diagnostics settings for troubleshooting event matching. + EvaluationTracing *UpdateSubscripitonTracingParameters `json:"evaluationTracing,omitempty"` +} + +// Parameters to update a specific diagnostic setting. +type UpdateSubscripitonTracingParameters struct { + // Indicates whether to enable to disable the diagnostic tracing. + Enabled *bool `json:"enabled,omitempty"` +} + +type UserSubscriptionChannel struct { + Address *string `json:"address,omitempty"` + UseCustomAddress *bool `json:"useCustomAddress,omitempty"` + Type *string `json:"type,omitempty"` +} + +type UserSystemSubscriptionChannel struct { + Address *string `json:"address,omitempty"` + UseCustomAddress *bool `json:"useCustomAddress,omitempty"` + Type *string `json:"type,omitempty"` +} + +// Encapsulates the properties of a field value definition. It has the information needed to retrieve the list of possible values for a certain field and how to handle that field values in the UI. This information includes what type of object this value represents, which property to use for UI display and which property to use for saving the subscription +type ValueDefinition struct { + // Gets or sets the data source. + DataSource *[]forminput.InputValue `json:"dataSource,omitempty"` + // Gets or sets the rest end point. + EndPoint *string `json:"endPoint,omitempty"` + // Gets or sets the result template. + ResultTemplate *string `json:"resultTemplate,omitempty"` +} diff --git a/azuredevops/npm/client.go b/azuredevops/npm/client.go new file mode 100644 index 00000000..d7b0b563 --- /dev/null +++ b/azuredevops/npm/client.go @@ -0,0 +1,764 @@ +// -------------------------------------------------------------------------------------------- +// 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 npm + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "io" + "net/http" +) + +var ResourceAreaId, _ = uuid.Parse("4c83cfc1-f33a-477e-a789-29d38ffca52e") + +type Client interface { + // [Preview API] Delete a package version without an npm scope from the recycle bin. + DeletePackageVersionFromRecycleBin(context.Context, DeletePackageVersionFromRecycleBinArgs) error + // [Preview API] Delete a package version with an npm scope from the recycle bin. + DeleteScopedPackageVersionFromRecycleBin(context.Context, DeleteScopedPackageVersionFromRecycleBinArgs) error + // [Preview API] + GetContentScopedPackage(context.Context, GetContentScopedPackageArgs) (io.ReadCloser, error) + // [Preview API] Get an unscoped npm package. + GetContentUnscopedPackage(context.Context, GetContentUnscopedPackageArgs) (io.ReadCloser, error) + // [Preview API] Get information about an unscoped package version. + GetPackageInfo(context.Context, GetPackageInfoArgs) (*Package, error) + // [Preview API] Get information about an unscoped package version in the recycle bin. + GetPackageVersionMetadataFromRecycleBin(context.Context, GetPackageVersionMetadataFromRecycleBinArgs) (*NpmPackageVersionDeletionState, error) + // [Preview API] Get the Readme for a package version with an npm scope. + GetReadmeScopedPackage(context.Context, GetReadmeScopedPackageArgs) (io.ReadCloser, error) + // [Preview API] Get the Readme for a package version that has no npm scope. + GetReadmeUnscopedPackage(context.Context, GetReadmeUnscopedPackageArgs) (io.ReadCloser, error) + // [Preview API] Get information about a scoped package version (such as @scope/name). + GetScopedPackageInfo(context.Context, GetScopedPackageInfoArgs) (*Package, error) + // [Preview API] Get information about a scoped package version in the recycle bin. + GetScopedPackageVersionMetadataFromRecycleBin(context.Context, GetScopedPackageVersionMetadataFromRecycleBinArgs) (*NpmPackageVersionDeletionState, error) + // [Preview API] Restore a package version without an npm scope from the recycle bin to its feed. + RestorePackageVersionFromRecycleBin(context.Context, RestorePackageVersionFromRecycleBinArgs) error + // [Preview API] Restore a package version with an npm scope from the recycle bin to its feed. + RestoreScopedPackageVersionFromRecycleBin(context.Context, RestoreScopedPackageVersionFromRecycleBinArgs) error + // [Preview API] Unpublish an unscoped package version. + UnpublishPackage(context.Context, UnpublishPackageArgs) (*Package, error) + // [Preview API] Unpublish a scoped package version (such as @scope/name). + UnpublishScopedPackage(context.Context, UnpublishScopedPackageArgs) (*Package, error) + // [Preview API] + UpdatePackage(context.Context, UpdatePackageArgs) (*Package, error) + // [Preview API] Update several packages from a single feed in a single request. The updates to the packages do not happen atomically. + UpdatePackages(context.Context, UpdatePackagesArgs) error + // [Preview API] + UpdateScopedPackage(context.Context, UpdateScopedPackageArgs) (*Package, 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] Delete a package version without an npm scope from the recycle bin. +func (client *ClientImpl) DeletePackageVersionFromRecycleBin(ctx context.Context, args DeletePackageVersionFromRecycleBinArgs) error { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("63a4f31f-e92b-4ee4-bf92-22d485e73bef") + _, 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 DeletePackageVersionFromRecycleBin function +type DeletePackageVersionFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Delete a package version with an npm scope from the recycle bin. +func (client *ClientImpl) DeleteScopedPackageVersionFromRecycleBin(ctx context.Context, args DeleteScopedPackageVersionFromRecycleBinArgs) error { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageScope == nil || *args.PackageScope == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageScope"} + } + routeValues["packageScope"] = *args.PackageScope + if args.UnscopedPackageName == nil || *args.UnscopedPackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UnscopedPackageName"} + } + routeValues["unscopedPackageName"] = *args.UnscopedPackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("220f45eb-94a5-432c-902a-5b8c6372e415") + _, 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 DeleteScopedPackageVersionFromRecycleBin function +type DeleteScopedPackageVersionFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Scope of the package (the 'scope' part of @scope/name). + PackageScope *string + // (required) Name of the package (the 'name' part of @scope/name). + UnscopedPackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] +func (client *ClientImpl) GetContentScopedPackage(ctx context.Context, args GetContentScopedPackageArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageScope == nil || *args.PackageScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageScope"} + } + routeValues["packageScope"] = *args.PackageScope + if args.UnscopedPackageName == nil || *args.UnscopedPackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UnscopedPackageName"} + } + routeValues["unscopedPackageName"] = *args.UnscopedPackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("09a4eafd-123a-495c-979c-0eda7bdb9a14") + 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 GetContentScopedPackage function +type GetContentScopedPackageArgs struct { + // (required) + FeedId *string + // (required) + PackageScope *string + // (required) + UnscopedPackageName *string + // (required) + PackageVersion *string +} + +// [Preview API] Get an unscoped npm package. +func (client *ClientImpl) GetContentUnscopedPackage(ctx context.Context, args GetContentUnscopedPackageArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("75caa482-cb1e-47cd-9f2c-c048a4b7a43e") + 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 GetContentUnscopedPackage function +type GetContentUnscopedPackageArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Get information about an unscoped package version. +func (client *ClientImpl) GetPackageInfo(ctx context.Context, args GetPackageInfoArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("ed579d62-67c9-4271-be66-9b029af5bcf9") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageInfo function +type GetPackageInfoArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Get information about an unscoped package version in the recycle bin. +func (client *ClientImpl) GetPackageVersionMetadataFromRecycleBin(ctx context.Context, args GetPackageVersionMetadataFromRecycleBinArgs) (*NpmPackageVersionDeletionState, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("63a4f31f-e92b-4ee4-bf92-22d485e73bef") + 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 NpmPackageVersionDeletionState + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersionMetadataFromRecycleBin function +type GetPackageVersionMetadataFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Get the Readme for a package version with an npm scope. +func (client *ClientImpl) GetReadmeScopedPackage(ctx context.Context, args GetReadmeScopedPackageArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageScope == nil || *args.PackageScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageScope"} + } + routeValues["packageScope"] = *args.PackageScope + if args.UnscopedPackageName == nil || *args.UnscopedPackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UnscopedPackageName"} + } + routeValues["unscopedPackageName"] = *args.UnscopedPackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("6d4db777-7e4a-43b2-afad-779a1d197301") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "text/plain", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetReadmeScopedPackage function +type GetReadmeScopedPackageArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Scope of the package (the 'scope' part of @scope\name) + PackageScope *string + // (required) Name of the package (the 'name' part of @scope\name) + UnscopedPackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Get the Readme for a package version that has no npm scope. +func (client *ClientImpl) GetReadmeUnscopedPackage(ctx context.Context, args GetReadmeUnscopedPackageArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("1099a396-b310-41d4-a4b6-33d134ce3fcf") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "text/plain", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetReadmeUnscopedPackage function +type GetReadmeUnscopedPackageArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Get information about a scoped package version (such as @scope/name). +func (client *ClientImpl) GetScopedPackageInfo(ctx context.Context, args GetScopedPackageInfoArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageScope == nil || *args.PackageScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageScope"} + } + routeValues["packageScope"] = *args.PackageScope + if args.UnscopedPackageName == nil || *args.UnscopedPackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UnscopedPackageName"} + } + routeValues["unscopedPackageName"] = *args.UnscopedPackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("e93d9ec3-4022-401e-96b0-83ea5d911e09") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetScopedPackageInfo function +type GetScopedPackageInfoArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Scope of the package (the 'scope' part of @scope/name). + PackageScope *string + // (required) Name of the package (the 'name' part of @scope/name). + UnscopedPackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Get information about a scoped package version in the recycle bin. +func (client *ClientImpl) GetScopedPackageVersionMetadataFromRecycleBin(ctx context.Context, args GetScopedPackageVersionMetadataFromRecycleBinArgs) (*NpmPackageVersionDeletionState, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageScope == nil || *args.PackageScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageScope"} + } + routeValues["packageScope"] = *args.PackageScope + if args.UnscopedPackageName == nil || *args.UnscopedPackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UnscopedPackageName"} + } + routeValues["unscopedPackageName"] = *args.UnscopedPackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("220f45eb-94a5-432c-902a-5b8c6372e415") + 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 NpmPackageVersionDeletionState + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetScopedPackageVersionMetadataFromRecycleBin function +type GetScopedPackageVersionMetadataFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Scope of the package (the 'scope' part of @scope/name) + PackageScope *string + // (required) Name of the package (the 'name' part of @scope/name). + UnscopedPackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Restore a package version without an npm scope from the recycle bin to its feed. +func (client *ClientImpl) RestorePackageVersionFromRecycleBin(ctx context.Context, args RestorePackageVersionFromRecycleBinArgs) error { + if args.PackageVersionDetails == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionDetails"} + } + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + body, marshalErr := json.Marshal(*args.PackageVersionDetails) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("63a4f31f-e92b-4ee4-bf92-22d485e73bef") + _, 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 err + } + + return nil +} + +// Arguments for the RestorePackageVersionFromRecycleBin function +type RestorePackageVersionFromRecycleBinArgs struct { + // (required) + PackageVersionDetails *NpmRecycleBinPackageVersionDetails + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Restore a package version with an npm scope from the recycle bin to its feed. +func (client *ClientImpl) RestoreScopedPackageVersionFromRecycleBin(ctx context.Context, args RestoreScopedPackageVersionFromRecycleBinArgs) error { + if args.PackageVersionDetails == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionDetails"} + } + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageScope == nil || *args.PackageScope == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageScope"} + } + routeValues["packageScope"] = *args.PackageScope + if args.UnscopedPackageName == nil || *args.UnscopedPackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UnscopedPackageName"} + } + routeValues["unscopedPackageName"] = *args.UnscopedPackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + body, marshalErr := json.Marshal(*args.PackageVersionDetails) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("220f45eb-94a5-432c-902a-5b8c6372e415") + _, 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 err + } + + return nil +} + +// Arguments for the RestoreScopedPackageVersionFromRecycleBin function +type RestoreScopedPackageVersionFromRecycleBinArgs struct { + // (required) + PackageVersionDetails *NpmRecycleBinPackageVersionDetails + // (required) Name or ID of the feed. + FeedId *string + // (required) Scope of the package (the 'scope' part of @scope/name). + PackageScope *string + // (required) Name of the package (the 'name' part of @scope/name). + UnscopedPackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Unpublish an unscoped package version. +func (client *ClientImpl) UnpublishPackage(ctx context.Context, args UnpublishPackageArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("ed579d62-67c9-4271-be66-9b029af5bcf9") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UnpublishPackage function +type UnpublishPackageArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Unpublish a scoped package version (such as @scope/name). +func (client *ClientImpl) UnpublishScopedPackage(ctx context.Context, args UnpublishScopedPackageArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageScope == nil || *args.PackageScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageScope"} + } + routeValues["packageScope"] = *args.PackageScope + if args.UnscopedPackageName == nil || *args.UnscopedPackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UnscopedPackageName"} + } + routeValues["unscopedPackageName"] = *args.UnscopedPackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("e93d9ec3-4022-401e-96b0-83ea5d911e09") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UnpublishScopedPackage function +type UnpublishScopedPackageArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Scope of the package (the 'scope' part of @scope/name). + PackageScope *string + // (required) Name of the package (the 'name' part of @scope/name). + UnscopedPackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] +func (client *ClientImpl) UpdatePackage(ctx context.Context, args UpdatePackageArgs) (*Package, error) { + if args.PackageVersionDetails == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionDetails"} + } + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + body, marshalErr := json.Marshal(*args.PackageVersionDetails) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ed579d62-67c9-4271-be66-9b029af5bcf9") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdatePackage function +type UpdatePackageArgs struct { + // (required) + PackageVersionDetails *PackageVersionDetails + // (required) + FeedId *string + // (required) + PackageName *string + // (required) + PackageVersion *string +} + +// [Preview API] Update several packages from a single feed in a single request. The updates to the packages do not happen atomically. +func (client *ClientImpl) UpdatePackages(ctx context.Context, args UpdatePackagesArgs) error { + if args.BatchRequest == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.BatchRequest"} + } + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + body, marshalErr := json.Marshal(*args.BatchRequest) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("06f34005-bbb2-41f4-88f5-23e03a99bb12") + _, 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 UpdatePackages function +type UpdatePackagesArgs struct { + // (required) Information about the packages to update, the operation to perform, and its associated data. + BatchRequest *NpmPackagesBatchRequest + // (required) Name or ID of the feed. + FeedId *string +} + +// [Preview API] +func (client *ClientImpl) UpdateScopedPackage(ctx context.Context, args UpdateScopedPackageArgs) (*Package, error) { + if args.PackageVersionDetails == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionDetails"} + } + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageScope == nil || *args.PackageScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageScope"} + } + routeValues["packageScope"] = *args.PackageScope + if args.UnscopedPackageName == nil || *args.UnscopedPackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UnscopedPackageName"} + } + routeValues["unscopedPackageName"] = *args.UnscopedPackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + body, marshalErr := json.Marshal(*args.PackageVersionDetails) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e93d9ec3-4022-401e-96b0-83ea5d911e09") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateScopedPackage function +type UpdateScopedPackageArgs struct { + // (required) + PackageVersionDetails *PackageVersionDetails + // (required) + FeedId *string + // (required) + PackageScope *string + // (required) + UnscopedPackageName *string + // (required) + PackageVersion *string +} diff --git a/azuredevops/npm/models.go b/azuredevops/npm/models.go new file mode 100644 index 00000000..d572f310 --- /dev/null +++ b/azuredevops/npm/models.go @@ -0,0 +1,100 @@ +// -------------------------------------------------------------------------------------------- +// 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 npm + +import ( + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/packagingshared" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +// Data required to deprecate multiple package versions. Pass this while performing NpmBatchOperationTypes.Deprecate batch operation. +type BatchDeprecateData struct { + // Deprecate message that will be added to packages + Message *string `json:"message,omitempty"` +} + +// Describes Npm batch operation types. +type NpmBatchOperationType string + +type npmBatchOperationTypeValuesType struct { + Promote NpmBatchOperationType + Deprecate NpmBatchOperationType + Unpublish NpmBatchOperationType + PermanentDelete NpmBatchOperationType + RestoreToFeed NpmBatchOperationType + Delete NpmBatchOperationType +} + +var NpmBatchOperationTypeValues = npmBatchOperationTypeValuesType{ + // Promote package versions to a release view. If constructing a NpmPackagesBatchRequest object with this type, use BatchPromoteData for its Data property. Not supported in the Recycle Bin. + Promote: "promote", + // Deprecate or undeprecate package versions. Not supported in the Recycle Bin. + Deprecate: "deprecate", + // Unpublish package versions. Npm-specific alias for the Delete operation. Not supported in the Recycle Bin. + Unpublish: "unpublish", + // Permanently delete package versions. Only supported in the Recycle Bin. + PermanentDelete: "permanentDelete", + // Restore unpublished package versions to the feed. Only supported in the Recycle Bin. + RestoreToFeed: "restoreToFeed", + // Delete package versions (equivalent to Unpublish). Not supported in the Recycle Bin. + Delete: "delete", +} + +// A batch of operations to apply to package versions. +type NpmPackagesBatchRequest struct { + // Data required to perform the operation. This is optional based on type of operation. Use BatchPromoteData if performing a promote operation. + Data interface{} `json:"data,omitempty"` + // Type of operation that needs to be performed on packages. + Operation *NpmBatchOperationType `json:"operation,omitempty"` + // The packages onto which the operation will be performed. + Packages *[]packagingshared.MinimalPackageDetails `json:"packages,omitempty"` +} + +// Deletion state of an npm package. +type NpmPackageVersionDeletionState struct { + // Name of the package. + Name *string `json:"name,omitempty"` + // UTC date the package was unpublished. + UnpublishedDate *azuredevops.Time `json:"unpublishedDate,omitempty"` + // Version of the package. + Version *string `json:"version,omitempty"` +} + +type NpmRecycleBinPackageVersionDetails struct { + // Setting to false will undo earlier deletion and restore the package to feed. + Deleted *bool `json:"deleted,omitempty"` +} + +// Package version metadata for an npm package +type Package struct { + // Related REST links. + Links interface{} `json:"_links,omitempty"` + // Deprecated message, if any, for the package. + DeprecateMessage *string `json:"deprecateMessage,omitempty"` + // Package Id. + Id *string `json:"id,omitempty"` + // The display name of the package. + Name *string `json:"name,omitempty"` + // If and when the package was permanently deleted. + PermanentlyDeletedDate *azuredevops.Time `json:"permanentlyDeletedDate,omitempty"` + // The history of upstream sources for this package. The first source in the list is the immediate source from which this package was saved. + SourceChain *[]packagingshared.UpstreamSourceInfo `json:"sourceChain,omitempty"` + // If and when the package was deleted. + UnpublishedDate *azuredevops.Time `json:"unpublishedDate,omitempty"` + // The version of the package. + Version *string `json:"version,omitempty"` +} + +type PackageVersionDetails struct { + // Indicates the deprecate message of a package version + DeprecateMessage *string `json:"deprecateMessage,omitempty"` + // The view to which the package version will be added + Views *webapi.JsonPatchOperation `json:"views,omitempty"` +} diff --git a/azuredevops/nuget/client.go b/azuredevops/nuget/client.go new file mode 100644 index 00000000..59319c30 --- /dev/null +++ b/azuredevops/nuget/client.go @@ -0,0 +1,409 @@ +// -------------------------------------------------------------------------------------------- +// 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 nuget + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "io" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("b3be7473-68ea-4a81-bfc7-9530baaa19ad") + +type Client interface { + // [Preview API] Send a package version from the feed to its paired recycle bin. + DeletePackageVersion(context.Context, DeletePackageVersionArgs) (*Package, error) + // [Preview API] Delete a package version from a feed's recycle bin. + DeletePackageVersionFromRecycleBin(context.Context, DeletePackageVersionFromRecycleBinArgs) error + // [Preview API] Download a package version directly. This API is intended for manual UI download options, not for programmatic access and scripting. You may be heavily throttled if accessing this api for scripting purposes. + DownloadPackage(context.Context, DownloadPackageArgs) (io.ReadCloser, error) + // [Preview API] Get information about a package version. + GetPackageVersion(context.Context, GetPackageVersionArgs) (*Package, error) + // [Preview API] View a package version's deletion/recycled status + GetPackageVersionMetadataFromRecycleBin(context.Context, GetPackageVersionMetadataFromRecycleBinArgs) (*NuGetPackageVersionDeletionState, error) + // [Preview API] Restore a package version from a feed's recycle bin back into the active feed. + RestorePackageVersionFromRecycleBin(context.Context, RestorePackageVersionFromRecycleBinArgs) error + // [Preview API] Set mutable state on a package version. + UpdatePackageVersion(context.Context, UpdatePackageVersionArgs) error + // [Preview API] Update several packages from a single feed in a single request. The updates to the packages do not happen atomically. + UpdatePackageVersions(context.Context, UpdatePackageVersionsArgs) 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] Send a package version from the feed to its paired recycle bin. +func (client *ClientImpl) DeletePackageVersion(ctx context.Context, args DeletePackageVersionArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("36c9353b-e250-4c57-b040-513c186c3905") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the DeletePackageVersion function +type DeletePackageVersionArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package to delete. + PackageName *string + // (required) Version of the package to delete. + PackageVersion *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Delete a package version from a feed's recycle bin. +func (client *ClientImpl) DeletePackageVersionFromRecycleBin(ctx context.Context, args DeletePackageVersionFromRecycleBinArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("07e88775-e3cb-4408-bbe1-628e036fac8c") + _, 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 DeletePackageVersionFromRecycleBin function +type DeletePackageVersionFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Download a package version directly. This API is intended for manual UI download options, not for programmatic access and scripting. You may be heavily throttled if accessing this api for scripting purposes. +func (client *ClientImpl) DownloadPackage(ctx context.Context, args DownloadPackageArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + queryParams := url.Values{} + if args.SourceProtocolVersion != nil { + queryParams.Add("sourceProtocolVersion", *args.SourceProtocolVersion) + } + locationId, _ := uuid.Parse("6ea81b8c-7386-490b-a71f-6cf23c80b388") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/octet-stream", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the DownloadPackage function +type DownloadPackageArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) Project ID or project name + Project *string + // (optional) Unused + SourceProtocolVersion *string +} + +// [Preview API] Get information about a package version. +func (client *ClientImpl) GetPackageVersion(ctx context.Context, args GetPackageVersionArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + queryParams := url.Values{} + if args.ShowDeleted != nil { + queryParams.Add("showDeleted", strconv.FormatBool(*args.ShowDeleted)) + } + locationId, _ := uuid.Parse("36c9353b-e250-4c57-b040-513c186c3905") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersion function +type GetPackageVersionArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) Project ID or project name + Project *string + // (optional) True to include deleted packages in the response. + ShowDeleted *bool +} + +// [Preview API] View a package version's deletion/recycled status +func (client *ClientImpl) GetPackageVersionMetadataFromRecycleBin(ctx context.Context, args GetPackageVersionMetadataFromRecycleBinArgs) (*NuGetPackageVersionDeletionState, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("07e88775-e3cb-4408-bbe1-628e036fac8c") + 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 NuGetPackageVersionDeletionState + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersionMetadataFromRecycleBin function +type GetPackageVersionMetadataFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Restore a package version from a feed's recycle bin back into the active feed. +func (client *ClientImpl) RestorePackageVersionFromRecycleBin(ctx context.Context, args RestorePackageVersionFromRecycleBinArgs) error { + if args.PackageVersionDetails == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionDetails"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + body, marshalErr := json.Marshal(*args.PackageVersionDetails) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("07e88775-e3cb-4408-bbe1-628e036fac8c") + _, 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 err + } + + return nil +} + +// Arguments for the RestorePackageVersionFromRecycleBin function +type RestorePackageVersionFromRecycleBinArgs struct { + // (required) Set the 'Deleted' member to 'false' to apply the restore operation + PackageVersionDetails *NuGetRecycleBinPackageVersionDetails + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Set mutable state on a package version. +func (client *ClientImpl) UpdatePackageVersion(ctx context.Context, args UpdatePackageVersionArgs) error { + if args.PackageVersionDetails == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionDetails"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + body, marshalErr := json.Marshal(*args.PackageVersionDetails) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("36c9353b-e250-4c57-b040-513c186c3905") + _, 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 err + } + + return nil +} + +// Arguments for the UpdatePackageVersion function +type UpdatePackageVersionArgs struct { + // (required) New state to apply to the referenced package. + PackageVersionDetails *PackageVersionDetails + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package to update. + PackageName *string + // (required) Version of the package to update. + PackageVersion *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Update several packages from a single feed in a single request. The updates to the packages do not happen atomically. +func (client *ClientImpl) UpdatePackageVersions(ctx context.Context, args UpdatePackageVersionsArgs) error { + if args.BatchRequest == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.BatchRequest"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + + body, marshalErr := json.Marshal(*args.BatchRequest) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("00c58ea7-d55f-49de-b59f-983533ae11dc") + _, 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 UpdatePackageVersions function +type UpdatePackageVersionsArgs struct { + // (required) Information about the packages to update, the operation to perform, and its associated data. + BatchRequest *NuGetPackagesBatchRequest + // (required) Name or ID of the feed. + FeedId *string + // (optional) Project ID or project name + Project *string +} diff --git a/azuredevops/nuget/models.go b/azuredevops/nuget/models.go new file mode 100644 index 00000000..dec607d3 --- /dev/null +++ b/azuredevops/nuget/models.go @@ -0,0 +1,95 @@ +// -------------------------------------------------------------------------------------------- +// 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 nuget + +import ( + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/packagingshared" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +// Data required to unlist or relist multiple package versions. Pass this while performing NuGetBatchOperationTypes.List batch operation. +type BatchListData struct { + // The desired listed status for the package versions. + Listed *bool `json:"listed,omitempty"` +} + +// Describes NuGet batch operation types. +type NuGetBatchOperationType string + +type nuGetBatchOperationTypeValuesType struct { + Promote NuGetBatchOperationType + List NuGetBatchOperationType + Delete NuGetBatchOperationType + PermanentDelete NuGetBatchOperationType + RestoreToFeed NuGetBatchOperationType +} + +var NuGetBatchOperationTypeValues = nuGetBatchOperationTypeValuesType{ + // Promote package versions to a release view. If constructing a NuGetPackagesBatchRequest object with this type, use BatchPromoteData for its Data property. Not supported in the Recycle Bin. + Promote: "promote", + // Unlist or relist package versions. Not supported in the Recycle Bin. + List: "list", + // Move package versions to the feed's Recycle Bin. Not supported in the Recycle Bin. + Delete: "delete", + // Permanently delete package versions. Only supported in the Recycle Bin. + PermanentDelete: "permanentDelete", + // Restore deleted package versions to the feed. Only supported in the Recycle Bin. + RestoreToFeed: "restoreToFeed", +} + +// A batch of operations to apply to package versions. +type NuGetPackagesBatchRequest struct { + // Data required to perform the operation. This is optional based on the type of the operation. Use BatchPromoteData if performing a promote operation. + Data interface{} `json:"data,omitempty"` + // Type of operation that needs to be performed on packages. + Operation *NuGetBatchOperationType `json:"operation,omitempty"` + // The packages onto which the operation will be performed. + Packages *[]packagingshared.MinimalPackageDetails `json:"packages,omitempty"` +} + +// Deletion state of a NuGet package. +type NuGetPackageVersionDeletionState struct { + // Utc date the package was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Name of the package. + Name *string `json:"name,omitempty"` + // Version of the package. + Version *string `json:"version,omitempty"` +} + +type NuGetRecycleBinPackageVersionDetails struct { + // Setting to false will undo earlier deletion and restore the package to feed. + Deleted *bool `json:"deleted,omitempty"` +} + +// Package version metadata for a NuGet package +type Package struct { + // Related REST links. + Links interface{} `json:"_links,omitempty"` + // If and when the package was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Package Id. + Id *string `json:"id,omitempty"` + // The display name of the package. + Name *string `json:"name,omitempty"` + // If and when the package was permanently deleted. + PermanentlyDeletedDate *azuredevops.Time `json:"permanentlyDeletedDate,omitempty"` + // The history of upstream sources for this package. The first source in the list is the immediate source from which this package was saved. + SourceChain *[]packagingshared.UpstreamSourceInfo `json:"sourceChain,omitempty"` + // The version of the package. + Version *string `json:"version,omitempty"` +} + +type PackageVersionDetails struct { + // Indicates the listing state of a package + Listed *bool `json:"listed,omitempty"` + // The view to which the package version will be added + Views *webapi.JsonPatchOperation `json:"views,omitempty"` +} diff --git a/azuredevops/operations/client.go b/azuredevops/operations/client.go new file mode 100644 index 00000000..f6939dc8 --- /dev/null +++ b/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/azuredevops/operations/models.go b/azuredevops/operations/models.go new file mode 100644 index 00000000..49abd0b0 --- /dev/null +++ b/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/azuredevops/packagingshared/models.go b/azuredevops/packagingshared/models.go new file mode 100644 index 00000000..835dcff2 --- /dev/null +++ b/azuredevops/packagingshared/models.go @@ -0,0 +1,56 @@ +// -------------------------------------------------------------------------------------------- +// 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 packagingshared + +import ( + "github.com/google/uuid" +) + +// Data required for promoting multiple package versions. Pass this while performing {protocol}BatchOperationTypes.Promote batch operation. +type BatchPromoteData struct { + // Id or Name of the view, packages need to be promoted to. + ViewId *string `json:"viewId,omitempty"` +} + +// Minimal package details required to identify a package within a protocol. +type MinimalPackageDetails struct { + // Package name. + Id *string `json:"id,omitempty"` + // Package version. + Version *string `json:"version,omitempty"` +} + +// Type of an upstream source, such as Public or Internal. +type PackagingSourceType string + +type packagingSourceTypeValuesType struct { + Public PackagingSourceType + Internal PackagingSourceType +} + +var PackagingSourceTypeValues = packagingSourceTypeValuesType{ + // Publicly available source. + Public: "public", + // Azure DevOps upstream source. + Internal: "internal", +} + +// Upstream source definition, including its Identity, package type, and other associated information. +type UpstreamSourceInfo struct { + // Locator for connecting to the upstream source in a user friendly format, that may potentially change over time + DisplayLocation *string `json:"displayLocation,omitempty"` + // Identity of the upstream source. + Id *uuid.UUID `json:"id,omitempty"` + // Locator for connecting to the upstream source + Location *string `json:"location,omitempty"` + // Display name. + Name *string `json:"name,omitempty"` + // Source type, such as Public or Internal. + SourceType *PackagingSourceType `json:"sourceType,omitempty"` +} diff --git a/azuredevops/pipelines/client.go b/azuredevops/pipelines/client.go new file mode 100644 index 00000000..948ec8df --- /dev/null +++ b/azuredevops/pipelines/client.go @@ -0,0 +1,376 @@ +// -------------------------------------------------------------------------------------------- +// 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 pipelines + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" +) + +type Client interface { + // [Preview API] + CreatePipeline(context.Context, CreatePipelineArgs) (*Pipeline, error) + // [Preview API] + GetLog(context.Context, GetLogArgs) (*Log, error) + // [Preview API] Gets a pipeline, optionally at the specified version + GetPipeline(context.Context, GetPipelineArgs) (*Pipeline, error) + // [Preview API] Gets a run for a particular pipeline. + GetRun(context.Context, GetRunArgs) (*Run, error) + // [Preview API] + ListLogs(context.Context, ListLogsArgs) (*LogCollection, error) + // [Preview API] Gets a list of pipelines. + ListPipelines(context.Context, ListPipelinesArgs) (*ListPipelinesResponseValue, error) + // [Preview API] Gets top 10000 runs for a particular pipeline. + ListRuns(context.Context, ListRunsArgs) (*[]Run, error) + // [Preview API] Runs a pipeline. + RunPipeline(context.Context, RunPipelineArgs) (*Run, 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, + } +} + +// [Preview API] +func (client *ClientImpl) CreatePipeline(ctx context.Context, args CreatePipelineArgs) (*Pipeline, error) { + if args.InputParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.InputParameters"} + } + 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.InputParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("28e1305e-2afe-47bf-abaf-cbb0e6a91988") + 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 Pipeline + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreatePipeline function +type CreatePipelineArgs struct { + // (required) + InputParameters *CreatePipelineParameters + // (required) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) GetLog(ctx context.Context, args GetLogArgs) (*Log, 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.PipelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PipelineId"} + } + routeValues["pipelineId"] = strconv.Itoa(*args.PipelineId) + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.LogId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.LogId"} + } + routeValues["logId"] = strconv.Itoa(*args.LogId) + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("fb1b6d27-3957-43d5-a14b-a2d70403e545") + 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 Log + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetLog function +type GetLogArgs struct { + // (required) Project ID or project name + Project *string + // (required) + PipelineId *int + // (required) + RunId *int + // (required) + LogId *int + // (optional) + Expand *GetLogExpandOptions +} + +// [Preview API] Gets a pipeline, optionally at the specified version +func (client *ClientImpl) GetPipeline(ctx context.Context, args GetPipelineArgs) (*Pipeline, 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.PipelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PipelineId"} + } + routeValues["pipelineId"] = strconv.Itoa(*args.PipelineId) + + queryParams := url.Values{} + if args.PipelineVersion != nil { + queryParams.Add("pipelineVersion", strconv.Itoa(*args.PipelineVersion)) + } + locationId, _ := uuid.Parse("28e1305e-2afe-47bf-abaf-cbb0e6a91988") + 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 Pipeline + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPipeline function +type GetPipelineArgs struct { + // (required) Project ID or project name + Project *string + // (required) The pipeline id + PipelineId *int + // (optional) The pipeline version + PipelineVersion *int +} + +// [Preview API] Gets a run for a particular pipeline. +func (client *ClientImpl) GetRun(ctx context.Context, args GetRunArgs) (*Run, 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.PipelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PipelineId"} + } + routeValues["pipelineId"] = strconv.Itoa(*args.PipelineId) + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + locationId, _ := uuid.Parse("7859261e-d2e9-4a68-b820-a5d84cc5bb3d") + 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 Run + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRun function +type GetRunArgs struct { + // (required) Project ID or project name + Project *string + // (required) The pipeline id + PipelineId *int + // (required) The run id + RunId *int +} + +// [Preview API] +func (client *ClientImpl) ListLogs(ctx context.Context, args ListLogsArgs) (*LogCollection, 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.PipelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PipelineId"} + } + routeValues["pipelineId"] = strconv.Itoa(*args.PipelineId) + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("fb1b6d27-3957-43d5-a14b-a2d70403e545") + 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 LogCollection + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListLogs function +type ListLogsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + PipelineId *int + // (required) + RunId *int + // (optional) + Expand *GetLogExpandOptions +} + +// [Preview API] Gets a list of pipelines. +func (client *ClientImpl) ListPipelines(ctx context.Context, args ListPipelinesArgs) (*ListPipelinesResponseValue, 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.OrderBy != nil { + queryParams.Add("orderBy", *args.OrderBy) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("28e1305e-2afe-47bf-abaf-cbb0e6a91988") + 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 ListPipelinesResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the ListPipelines function +type ListPipelinesArgs struct { + // (required) Project ID or project name + Project *string + // (optional) A sort expression. Defaults to "name asc" + OrderBy *string + // (optional) The maximum number of pipelines to return + Top *int + // (optional) A continuation token from a previous request, to retrieve the next page of results + ContinuationToken *string +} + +// Return type for the ListPipelines function +type ListPipelinesResponseValue struct { + Value []Pipeline + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Gets top 10000 runs for a particular pipeline. +func (client *ClientImpl) ListRuns(ctx context.Context, args ListRunsArgs) (*[]Run, 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.PipelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PipelineId"} + } + routeValues["pipelineId"] = strconv.Itoa(*args.PipelineId) + + locationId, _ := uuid.Parse("7859261e-d2e9-4a68-b820-a5d84cc5bb3d") + 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 []Run + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListRuns function +type ListRunsArgs struct { + // (required) Project ID or project name + Project *string + // (required) The pipeline id + PipelineId *int +} + +// [Preview API] Runs a pipeline. +func (client *ClientImpl) RunPipeline(ctx context.Context, args RunPipelineArgs) (*Run, error) { + if args.RunParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunParameters"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PipelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PipelineId"} + } + routeValues["pipelineId"] = strconv.Itoa(*args.PipelineId) + + queryParams := url.Values{} + if args.PipelineVersion != nil { + queryParams.Add("pipelineVersion", strconv.Itoa(*args.PipelineVersion)) + } + body, marshalErr := json.Marshal(*args.RunParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("7859261e-d2e9-4a68-b820-a5d84cc5bb3d") + 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 Run + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the RunPipeline function +type RunPipelineArgs struct { + // (required) Optional. + RunParameters *RunPipelineParameters + // (required) Project ID or project name + Project *string + // (required) The pipeline id + PipelineId *int + // (optional) The pipeline version + PipelineVersion *int +} diff --git a/azuredevops/pipelines/models.go b/azuredevops/pipelines/models.go new file mode 100644 index 00000000..6977c892 --- /dev/null +++ b/azuredevops/pipelines/models.go @@ -0,0 +1,212 @@ +// -------------------------------------------------------------------------------------------- +// 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 pipelines + +import ( + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type ConfigurationType string + +type configurationTypeValuesType struct { + Unknown ConfigurationType + Yaml ConfigurationType + DesignerJson ConfigurationType + JustInTime ConfigurationType + DesignerHyphenJson ConfigurationType +} + +var ConfigurationTypeValues = configurationTypeValuesType{ + Unknown: "unknown", + Yaml: "yaml", + DesignerJson: "designerJson", + JustInTime: "justInTime", + DesignerHyphenJson: "designerHyphenJson", +} + +type CreatePipelineConfigurationParameters struct { + Type *ConfigurationType `json:"type,omitempty"` +} + +type CreatePipelineParameters struct { + Configuration *CreatePipelineConfigurationParameters `json:"configuration,omitempty"` + Folder *string `json:"folder,omitempty"` + Name *string `json:"name,omitempty"` +} + +// [Flags] $expand options for GetLog and ListLogs. +type GetLogExpandOptions string + +type getLogExpandOptionsValuesType struct { + None GetLogExpandOptions + SignedContent GetLogExpandOptions +} + +var GetLogExpandOptionsValues = getLogExpandOptionsValuesType{ + None: "none", + SignedContent: "signedContent", +} + +type Log struct { + // The date and time the log was created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // The ID of the log. + Id *int `json:"id,omitempty"` + // The date and time the log was last changed. + LastChangedOn *azuredevops.Time `json:"lastChangedOn,omitempty"` + // The number of lines in the log. + LineCount *uint64 `json:"lineCount,omitempty"` + SignedContent *webapi.SignedUrl `json:"signedContent,omitempty"` + Url *string `json:"url,omitempty"` +} + +type LogCollection struct { + Logs *[]Log `json:"logs,omitempty"` + SignedContent *webapi.SignedUrl `json:"signedContent,omitempty"` + Url *string `json:"url,omitempty"` +} + +type Pipeline struct { + Folder *string `json:"folder,omitempty"` + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Revision *int `json:"revision,omitempty"` + Links interface{} `json:"_links,omitempty"` + Configuration *PipelineConfiguration `json:"configuration,omitempty"` + Url *string `json:"url,omitempty"` +} + +type PipelineBase struct { + Folder *string `json:"folder,omitempty"` + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Revision *int `json:"revision,omitempty"` +} + +type PipelineConfiguration struct { + Type *ConfigurationType `json:"type,omitempty"` +} + +// A reference to a Pipeline. +type PipelineReference struct { + Folder *string `json:"folder,omitempty"` + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Revision *int `json:"revision,omitempty"` + Url *string `json:"url,omitempty"` +} + +type Repository struct { + Type *RepositoryType `json:"type,omitempty"` +} + +type RepositoryResource struct { + RefName *string `json:"refName,omitempty"` + Repository *Repository `json:"repository,omitempty"` + Version *string `json:"version,omitempty"` +} + +type RepositoryResourceParameters struct { + RefName *string `json:"refName,omitempty"` + // This is the security token to use when connecting to the repository. + Token *string `json:"token,omitempty"` + // Optional. This is the type of the token given. If not provided, a type of "Bearer" is assumed. Note: Use "Basic" for a PAT token. + TokenType *string `json:"tokenType,omitempty"` + Version *string `json:"version,omitempty"` +} + +type RepositoryType string + +type repositoryTypeValuesType struct { + Unknown RepositoryType + GitHub RepositoryType + AzureReposGit RepositoryType + AzureReposGitHyphenated RepositoryType +} + +var RepositoryTypeValues = repositoryTypeValuesType{ + Unknown: "unknown", + GitHub: "gitHub", + AzureReposGit: "azureReposGit", + AzureReposGitHyphenated: "azureReposGitHyphenated", +} + +type Run struct { + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Links interface{} `json:"_links,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + FinishedDate *azuredevops.Time `json:"finishedDate,omitempty"` + Pipeline *PipelineReference `json:"pipeline,omitempty"` + Resources *RunResources `json:"resources,omitempty"` + Result *RunResult `json:"result,omitempty"` + State *RunState `json:"state,omitempty"` + Url *string `json:"url,omitempty"` + Variables *map[string]Variable `json:"variables,omitempty"` +} + +type RunPipelineParameters struct { + // Deprecated: Use Context instead + Resources *RunResourcesParameters `json:"resources,omitempty"` + Secrets *map[string]string `json:"secrets,omitempty"` + Variables *map[string]Variable `json:"variables,omitempty"` +} + +type RunReference struct { + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type RunResources struct { + Repositories *map[string]RepositoryResource `json:"repositories,omitempty"` +} + +type RunResourcesParameters struct { + Repositories *map[string]RepositoryResourceParameters `json:"repositories,omitempty"` +} + +// This is not a Flags enum because we don't want to set multiple results on a build. However, when adding values, please stick to powers of 2 as if it were a Flags enum. This will make it easier to query multiple results. +type RunResult string + +type runResultValuesType struct { + Unknown RunResult + Succeeded RunResult + Failed RunResult + Canceled RunResult +} + +var RunResultValues = runResultValuesType{ + Unknown: "unknown", + Succeeded: "succeeded", + Failed: "failed", + Canceled: "canceled", +} + +// This is not a Flags enum because we don't want to set multiple states on a build. However, when adding values, please stick to powers of 2 as if it were a Flags enum. This will make it easier to query multiple states. +type RunState string + +type runStateValuesType struct { + Unknown RunState + InProgress RunState + Canceling RunState + Completed RunState +} + +var RunStateValues = runStateValuesType{ + Unknown: "unknown", + InProgress: "inProgress", + Canceling: "canceling", + Completed: "completed", +} + +type Variable struct { + IsSecret *bool `json:"isSecret,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/azuredevops/policy/client.go b/azuredevops/policy/client.go new file mode 100644 index 00000000..985639fa --- /dev/null +++ b/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/azuredevops/policy/models.go b/azuredevops/policy/models.go new file mode 100644 index 00000000..c0c405c3 --- /dev/null +++ b/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/azuredevops/profile/client.go b/azuredevops/profile/client.go new file mode 100644 index 00000000..2684d548 --- /dev/null +++ b/azuredevops/profile/client.go @@ -0,0 +1,90 @@ +// -------------------------------------------------------------------------------------------- +// 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 profile + +import ( + "context" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("8ccfef3d-2b87-4e99-8ccb-66e343d2daa8") + +type Client interface { + // Gets a user profile. + GetProfile(context.Context, GetProfileArgs) (*Profile, 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 +} + +// Gets a user profile. +func (client *ClientImpl) GetProfile(ctx context.Context, args GetProfileArgs) (*Profile, error) { + routeValues := make(map[string]string) + if args.Id == nil || *args.Id == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Id"} + } + routeValues["id"] = *args.Id + + queryParams := url.Values{} + if args.Details != nil { + queryParams.Add("details", strconv.FormatBool(*args.Details)) + } + if args.WithAttributes != nil { + queryParams.Add("withAttributes", strconv.FormatBool(*args.WithAttributes)) + } + if args.Partition != nil { + queryParams.Add("partition", *args.Partition) + } + if args.CoreAttributes != nil { + queryParams.Add("coreAttributes", *args.CoreAttributes) + } + if args.ForceRefresh != nil { + queryParams.Add("forceRefresh", strconv.FormatBool(*args.ForceRefresh)) + } + locationId, _ := uuid.Parse("f83735dc-483f-4238-a291-d45f6080a9af") + 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 Profile + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProfile function +type GetProfileArgs struct { + // (required) The ID of the target user profile within the same organization, or 'me' to get the profile of the current authenticated user. + Id *string + // (optional) Return public profile information such as display name, email address, country, etc. If false, the withAttributes parameter is ignored. + Details *bool + // (optional) If true, gets the attributes (named key-value pairs of arbitrary data) associated with the profile. The partition parameter must also have a value. + WithAttributes *bool + // (optional) The partition (named group) of attributes to return. + Partition *string + // (optional) A comma-delimited list of core profile attributes to return. Valid values are Email, Avatar, DisplayName, and ContactWithOffers. + CoreAttributes *string + // (optional) Not used in this version of the API. + ForceRefresh *bool +} diff --git a/azuredevops/profile/models.go b/azuredevops/profile/models.go new file mode 100644 index 00000000..b248e3c1 --- /dev/null +++ b/azuredevops/profile/models.go @@ -0,0 +1,144 @@ +// -------------------------------------------------------------------------------------------- +// 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 profile + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" +) + +// Identifies an attribute with a name and a container. +type AttributeDescriptor struct { + // The name of the attribute. + AttributeName *string `json:"attributeName,omitempty"` + // The container the attribute resides in. + ContainerName *string `json:"containerName,omitempty"` +} + +// Stores a set of named profile attributes. +type AttributesContainer struct { + // The attributes stored by the container. + Attributes *map[string]ProfileAttribute `json:"attributes,omitempty"` + // The name of the container. + ContainerName *string `json:"containerName,omitempty"` + // The maximum revision number of any attribute within the container. + Revision *int `json:"revision,omitempty"` +} + +type Avatar struct { + IsAutoGenerated *bool `json:"isAutoGenerated,omitempty"` + Size *AvatarSize `json:"size,omitempty"` + TimeStamp *azuredevops.Time `json:"timeStamp,omitempty"` + Value *[]byte `json:"value,omitempty"` +} + +// Small = 34 x 34 pixels; Medium = 44 x 44 pixels; Large = 220 x 220 pixels +type AvatarSize string + +type avatarSizeValuesType struct { + Small AvatarSize + Medium AvatarSize + Large AvatarSize +} + +var AvatarSizeValues = avatarSizeValuesType{ + Small: "small", + Medium: "medium", + Large: "large", +} + +// A profile attribute which always has a value for each profile. +type CoreProfileAttribute struct { +} + +type CreateProfileContext struct { + CiData *map[string]interface{} `json:"ciData,omitempty"` + ContactWithOffers *bool `json:"contactWithOffers,omitempty"` + CountryName *string `json:"countryName,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + EmailAddress *string `json:"emailAddress,omitempty"` + HasAccount *bool `json:"hasAccount,omitempty"` + Language *string `json:"language,omitempty"` + PhoneNumber *string `json:"phoneNumber,omitempty"` + // The current state of the profile. + ProfileState *ProfileState `json:"profileState,omitempty"` +} + +type GeoRegion struct { + RegionCode *string `json:"regionCode,omitempty"` +} + +// A user profile. +type Profile struct { + // The attributes of this profile. + ApplicationContainer *AttributesContainer `json:"applicationContainer,omitempty"` + // The core attributes of this profile. + CoreAttributes *map[string]CoreProfileAttribute `json:"coreAttributes,omitempty"` + // The maximum revision number of any attribute. + CoreRevision *int `json:"coreRevision,omitempty"` + // The unique identifier of the profile. + Id *uuid.UUID `json:"id,omitempty"` + // The current state of the profile. + ProfileState *ProfileState `json:"profileState,omitempty"` + // The maximum revision number of any attribute. + Revision *int `json:"revision,omitempty"` + // The time at which this profile was last changed. + TimeStamp *azuredevops.Time `json:"timeStamp,omitempty"` +} + +// A named object associated with a profile. +type ProfileAttribute struct { +} + +type ProfileAttributeBase struct { + // The descriptor of the attribute. + Descriptor *AttributeDescriptor `json:"descriptor,omitempty"` + // The revision number of the attribute. + Revision *int `json:"revision,omitempty"` + // The time the attribute was last changed. + TimeStamp *azuredevops.Time `json:"timeStamp,omitempty"` + // The value of the attribute. + Value interface{} `json:"value,omitempty"` +} + +// Country/region information +type ProfileRegion struct { + // The two-letter code defined in ISO 3166 for the country/region. + Code *string `json:"code,omitempty"` + // Localized country/region name + Name *string `json:"name,omitempty"` +} + +// Container of country/region information +type ProfileRegions struct { + // List of country/region code with contact consent requirement type of notice + NoticeContactConsentRequirementRegions *[]string `json:"noticeContactConsentRequirementRegions,omitempty"` + // List of country/region code with contact consent requirement type of opt-out + OptOutContactConsentRequirementRegions *[]string `json:"optOutContactConsentRequirementRegions,omitempty"` + // List of country/regions + Regions *[]ProfileRegion `json:"regions,omitempty"` +} + +// The state of a profile. +type ProfileState string + +type profileStateValuesType struct { + Custom ProfileState + CustomReadOnly ProfileState + ReadOnly ProfileState +} + +var ProfileStateValues = profileStateValuesType{ + // The profile is in use. + Custom: "custom", + // The profile is in use, but can only be read. + CustomReadOnly: "customReadOnly", + // The profile may only be read. + ReadOnly: "readOnly", +} diff --git a/azuredevops/profileregions/client.go b/azuredevops/profileregions/client.go new file mode 100644 index 00000000..36c6d904 --- /dev/null +++ b/azuredevops/profileregions/client.go @@ -0,0 +1,81 @@ +// -------------------------------------------------------------------------------------------- +// 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 profileregions + +import ( + "context" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" +) + +var ResourceAreaId, _ = uuid.Parse("8ccfef3d-2b87-4e99-8ccb-66e343d2daa8") + +type Client interface { + // [Preview API] Lookup up country/region based on provided IPv4, null if using the remote IPv4 address. + GetGeoRegion(context.Context, GetGeoRegionArgs) (*GeoRegion, error) + // [Preview API] + GetRegions(context.Context, GetRegionsArgs) (*ProfileRegions, 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] Lookup up country/region based on provided IPv4, null if using the remote IPv4 address. +func (client *ClientImpl) GetGeoRegion(ctx context.Context, args GetGeoRegionArgs) (*GeoRegion, error) { + queryParams := url.Values{} + if args.Ip == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "ip"} + } + queryParams.Add("ip", *args.Ip) + locationId, _ := uuid.Parse("35b3ff1d-ab4c-4d1c-98bb-f6ea21d86bd9") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GeoRegion + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetGeoRegion function +type GetGeoRegionArgs struct { + // (required) + Ip *string +} + +// [Preview API] +func (client *ClientImpl) GetRegions(ctx context.Context, args GetRegionsArgs) (*ProfileRegions, error) { + locationId, _ := uuid.Parse("b129ca90-999d-47bb-ab37-0dcf784ee633") + 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 ProfileRegions + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRegions function +type GetRegionsArgs struct { +} diff --git a/azuredevops/profileregions/models.go b/azuredevops/profileregions/models.go new file mode 100644 index 00000000..da133450 --- /dev/null +++ b/azuredevops/profileregions/models.go @@ -0,0 +1,31 @@ +// -------------------------------------------------------------------------------------------- +// 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 profileregions + +type GeoRegion struct { + RegionCode *string `json:"regionCode,omitempty"` +} + +// Country/region information +type ProfileRegion struct { + // The two-letter code defined in ISO 3166 for the country/region. + Code *string `json:"code,omitempty"` + // Localized country/region name + Name *string `json:"name,omitempty"` +} + +// Container of country/region information +type ProfileRegions struct { + // List of country/region code with contact consent requirement type of notice + NoticeContactConsentRequirementRegions *[]string `json:"noticeContactConsentRequirementRegions,omitempty"` + // List of country/region code with contact consent requirement type of opt-out + OptOutContactConsentRequirementRegions *[]string `json:"optOutContactConsentRequirementRegions,omitempty"` + // List of country/regions + Regions *[]ProfileRegion `json:"regions,omitempty"` +} diff --git a/azuredevops/projectanalysis/client.go b/azuredevops/projectanalysis/client.go new file mode 100644 index 00000000..19769d57 --- /dev/null +++ b/azuredevops/projectanalysis/client.go @@ -0,0 +1,202 @@ +// -------------------------------------------------------------------------------------------- +// 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 projectanalysis + +import ( + "context" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("7658fa33-b1bf-4580-990f-fac5896773d3") + +type Client interface { + // [Preview API] Retrieves git activity metrics for repositories matching a specified criteria. + GetGitRepositoriesActivityMetrics(context.Context, GetGitRepositoriesActivityMetricsArgs) (*[]RepositoryActivityMetrics, error) + // [Preview API] + GetProjectActivityMetrics(context.Context, GetProjectActivityMetricsArgs) (*ProjectActivityMetrics, error) + // [Preview API] + GetProjectLanguageAnalytics(context.Context, GetProjectLanguageAnalyticsArgs) (*ProjectLanguageAnalytics, error) + // [Preview API] + GetRepositoryActivityMetrics(context.Context, GetRepositoryActivityMetricsArgs) (*RepositoryActivityMetrics, 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] Retrieves git activity metrics for repositories matching a specified criteria. +func (client *ClientImpl) GetGitRepositoriesActivityMetrics(ctx context.Context, args GetGitRepositoriesActivityMetricsArgs) (*[]RepositoryActivityMetrics, 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.FromDate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "fromDate"} + } + queryParams.Add("fromDate", (*args.FromDate).String()) + if args.AggregationType == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "aggregationType"} + } + queryParams.Add("aggregationType", string(*args.AggregationType)) + if args.Skip == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "skip"} + } + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + if args.Top == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "top"} + } + queryParams.Add("$top", strconv.Itoa(*args.Top)) + locationId, _ := uuid.Parse("df7fbbca-630a-40e3-8aa3-7a3faf66947e") + 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 []RepositoryActivityMetrics + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetGitRepositoriesActivityMetrics function +type GetGitRepositoriesActivityMetricsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Date from which, the trends are to be fetched. + FromDate *azuredevops.Time + // (required) Bucket size on which, trends are to be aggregated. + AggregationType *AggregationType + // (required) The number of repositories to ignore. + Skip *int + // (required) The number of repositories for which activity metrics are to be retrieved. + Top *int +} + +// [Preview API] +func (client *ClientImpl) GetProjectActivityMetrics(ctx context.Context, args GetProjectActivityMetricsArgs) (*ProjectActivityMetrics, 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.FromDate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "fromDate"} + } + queryParams.Add("fromDate", (*args.FromDate).String()) + if args.AggregationType == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "aggregationType"} + } + queryParams.Add("aggregationType", string(*args.AggregationType)) + locationId, _ := uuid.Parse("e40ae584-9ea6-4f06-a7c7-6284651b466b") + 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 ProjectActivityMetrics + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProjectActivityMetrics function +type GetProjectActivityMetricsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + FromDate *azuredevops.Time + // (required) + AggregationType *AggregationType +} + +// [Preview API] +func (client *ClientImpl) GetProjectLanguageAnalytics(ctx context.Context, args GetProjectLanguageAnalyticsArgs) (*ProjectLanguageAnalytics, 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("5b02a779-1867-433f-90b7-d23ed5e33e57") + 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 ProjectLanguageAnalytics + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProjectLanguageAnalytics function +type GetProjectLanguageAnalyticsArgs struct { + // (required) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) GetRepositoryActivityMetrics(ctx context.Context, args GetRepositoryActivityMetricsArgs) (*RepositoryActivityMetrics, 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 { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RepositoryId"} + } + routeValues["repositoryId"] = (*args.RepositoryId).String() + + queryParams := url.Values{} + if args.FromDate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "fromDate"} + } + queryParams.Add("fromDate", (*args.FromDate).String()) + if args.AggregationType == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "aggregationType"} + } + queryParams.Add("aggregationType", string(*args.AggregationType)) + locationId, _ := uuid.Parse("df7fbbca-630a-40e3-8aa3-7a3faf66947e") + 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 RepositoryActivityMetrics + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRepositoryActivityMetrics function +type GetRepositoryActivityMetricsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RepositoryId *uuid.UUID + // (required) + FromDate *azuredevops.Time + // (required) + AggregationType *AggregationType +} diff --git a/azuredevops/projectanalysis/models.go b/azuredevops/projectanalysis/models.go new file mode 100644 index 00000000..68214ea3 --- /dev/null +++ b/azuredevops/projectanalysis/models.go @@ -0,0 +1,106 @@ +// -------------------------------------------------------------------------------------------- +// 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 projectanalysis + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" +) + +type AggregationType string + +type aggregationTypeValuesType struct { + Hourly AggregationType + Daily AggregationType +} + +var AggregationTypeValues = aggregationTypeValuesType{ + Hourly: "hourly", + Daily: "daily", +} + +type AnalyzerDescriptor struct { + Description *string `json:"description,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + MajorVersion *int `json:"majorVersion,omitempty"` + MinorVersion *int `json:"minorVersion,omitempty"` + Name *string `json:"name,omitempty"` + PatchVersion *int `json:"patchVersion,omitempty"` +} + +type CodeChangeTrendItem struct { + Time *azuredevops.Time `json:"time,omitempty"` + Value *int `json:"value,omitempty"` +} + +type LanguageMetricsSecuredObject struct { + NamespaceId *uuid.UUID `json:"namespaceId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + RequiredPermissions *int `json:"requiredPermissions,omitempty"` +} + +type LanguageStatistics struct { + NamespaceId *uuid.UUID `json:"namespaceId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + RequiredPermissions *int `json:"requiredPermissions,omitempty"` + Bytes *uint64 `json:"bytes,omitempty"` + Files *int `json:"files,omitempty"` + FilesPercentage *float64 `json:"filesPercentage,omitempty"` + LanguagePercentage *float64 `json:"languagePercentage,omitempty"` + Name *string `json:"name,omitempty"` +} + +type ProjectActivityMetrics struct { + AuthorsCount *int `json:"authorsCount,omitempty"` + CodeChangesCount *int `json:"codeChangesCount,omitempty"` + CodeChangesTrend *[]CodeChangeTrendItem `json:"codeChangesTrend,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + PullRequestsCompletedCount *int `json:"pullRequestsCompletedCount,omitempty"` + PullRequestsCreatedCount *int `json:"pullRequestsCreatedCount,omitempty"` +} + +type ProjectLanguageAnalytics struct { + NamespaceId *uuid.UUID `json:"namespaceId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + RequiredPermissions *int `json:"requiredPermissions,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + LanguageBreakdown *[]LanguageStatistics `json:"languageBreakdown,omitempty"` + RepositoryLanguageAnalytics *[]RepositoryLanguageAnalytics `json:"repositoryLanguageAnalytics,omitempty"` + ResultPhase *ResultPhase `json:"resultPhase,omitempty"` + Url *string `json:"url,omitempty"` +} + +type RepositoryActivityMetrics struct { + CodeChangesCount *int `json:"codeChangesCount,omitempty"` + CodeChangesTrend *[]CodeChangeTrendItem `json:"codeChangesTrend,omitempty"` + RepositoryId *uuid.UUID `json:"repositoryId,omitempty"` +} + +type RepositoryLanguageAnalytics struct { + NamespaceId *uuid.UUID `json:"namespaceId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + RequiredPermissions *int `json:"requiredPermissions,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + LanguageBreakdown *[]LanguageStatistics `json:"languageBreakdown,omitempty"` + Name *string `json:"name,omitempty"` + ResultPhase *ResultPhase `json:"resultPhase,omitempty"` + UpdatedTime *azuredevops.Time `json:"updatedTime,omitempty"` +} + +type ResultPhase string + +type resultPhaseValuesType struct { + Preliminary ResultPhase + Full ResultPhase +} + +var ResultPhaseValues = resultPhaseValuesType{ + Preliminary: "preliminary", + Full: "full", +} diff --git a/azuredevops/provenance/client.go b/azuredevops/provenance/client.go new file mode 100644 index 00000000..ac1af61f --- /dev/null +++ b/azuredevops/provenance/client.go @@ -0,0 +1,78 @@ +// -------------------------------------------------------------------------------------------- +// 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 provenance + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" +) + +var ResourceAreaId, _ = uuid.Parse("b40c1171-807a-493a-8f3f-5c26d5e2f5aa") + +type Client interface { + // [Preview API] Creates a session, a wrapper around a feed that can store additional metadata on the packages published to it. + CreateSession(context.Context, CreateSessionArgs) (*SessionResponse, 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] Creates a session, a wrapper around a feed that can store additional metadata on the packages published to it. +func (client *ClientImpl) CreateSession(ctx context.Context, args CreateSessionArgs) (*SessionResponse, error) { + if args.SessionRequest == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SessionRequest"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Protocol == nil || *args.Protocol == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Protocol"} + } + routeValues["protocol"] = *args.Protocol + + body, marshalErr := json.Marshal(*args.SessionRequest) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("503b4e54-ebf4-4d04-8eee-21c00823c2ac") + 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 SessionResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateSession function +type CreateSessionArgs struct { + // (required) The feed and metadata for the session + SessionRequest *SessionRequest + // (required) The protocol that the session will target + Protocol *string + // (optional) Project ID or project name + Project *string +} diff --git a/azuredevops/provenance/models.go b/azuredevops/provenance/models.go new file mode 100644 index 00000000..e79893de --- /dev/null +++ b/azuredevops/provenance/models.go @@ -0,0 +1,25 @@ +// -------------------------------------------------------------------------------------------- +// 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 provenance + +type SessionRequest struct { + // Generic property bag to store data about the session + Data *map[string]string `json:"data,omitempty"` + // The feed name or id for the session + Feed *string `json:"feed,omitempty"` + // The type of session If a known value is provided, the Data dictionary will be validated for the presence of properties required by that type + Source *string `json:"source,omitempty"` +} + +type SessionResponse struct { + // The unique identifier for the session + SessionId *string `json:"sessionId,omitempty"` + // The name for the session + SessionName *string `json:"sessionName,omitempty"` +} diff --git a/azuredevops/pypiapi/client.go b/azuredevops/pypiapi/client.go new file mode 100644 index 00000000..d1286aed --- /dev/null +++ b/azuredevops/pypiapi/client.go @@ -0,0 +1,371 @@ +// -------------------------------------------------------------------------------------------- +// 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 pypiapi + +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("92f0314b-06c5-46e0-abe7-15fd9d13276a") + +type Client interface { + // [Preview API] Delete a package version, moving it to the recycle bin. + DeletePackageVersion(context.Context, DeletePackageVersionArgs) (*Package, error) + // [Preview API] Delete a package version from the feed, moving it to the recycle bin. + DeletePackageVersionFromRecycleBin(context.Context, DeletePackageVersionFromRecycleBinArgs) error + // [Preview API] Download a python package file directly. This API is intended for manual UI download options, not for programmatic access and scripting. + DownloadPackage(context.Context, DownloadPackageArgs) (interface{}, error) + // [Preview API] Get information about a package version. + GetPackageVersion(context.Context, GetPackageVersionArgs) (*Package, error) + // [Preview API] Get information about a package version in the recycle bin. + GetPackageVersionMetadataFromRecycleBin(context.Context, GetPackageVersionMetadataFromRecycleBinArgs) (*PyPiPackageVersionDeletionState, error) + // [Preview API] Restore a package version from the recycle bin to its associated feed. + RestorePackageVersionFromRecycleBin(context.Context, RestorePackageVersionFromRecycleBinArgs) error + // [Preview API] Update state for a package version. + UpdatePackageVersion(context.Context, UpdatePackageVersionArgs) 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] Delete a package version, moving it to the recycle bin. +func (client *ClientImpl) DeletePackageVersion(ctx context.Context, args DeletePackageVersionArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("d146ac7e-9e3f-4448-b956-f9bb3bdf9b2e") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the DeletePackageVersion function +type DeletePackageVersionArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Delete a package version from the feed, moving it to the recycle bin. +func (client *ClientImpl) DeletePackageVersionFromRecycleBin(ctx context.Context, args DeletePackageVersionFromRecycleBinArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("07143752-3d94-45fd-86c2-0c77ed87847b") + _, 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 DeletePackageVersionFromRecycleBin function +type DeletePackageVersionFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Download a python package file directly. This API is intended for manual UI download options, not for programmatic access and scripting. +func (client *ClientImpl) DownloadPackage(ctx context.Context, args DownloadPackageArgs) (interface{}, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + if args.FileName == nil || *args.FileName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FileName"} + } + routeValues["fileName"] = *args.FileName + + locationId, _ := uuid.Parse("97218bae-a64d-4381-9257-b5b7951f0b98") + 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 DownloadPackage function +type DownloadPackageArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (required) Name of the file in the package + FileName *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get information about a package version. +func (client *ClientImpl) GetPackageVersion(ctx context.Context, args GetPackageVersionArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + queryParams := url.Values{} + if args.ShowDeleted != nil { + queryParams.Add("showDeleted", strconv.FormatBool(*args.ShowDeleted)) + } + locationId, _ := uuid.Parse("d146ac7e-9e3f-4448-b956-f9bb3bdf9b2e") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersion function +type GetPackageVersionArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) Project ID or project name + Project *string + // (optional) True to show information for deleted package versions. + ShowDeleted *bool +} + +// [Preview API] Get information about a package version in the recycle bin. +func (client *ClientImpl) GetPackageVersionMetadataFromRecycleBin(ctx context.Context, args GetPackageVersionMetadataFromRecycleBinArgs) (*PyPiPackageVersionDeletionState, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("07143752-3d94-45fd-86c2-0c77ed87847b") + 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 PyPiPackageVersionDeletionState + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersionMetadataFromRecycleBin function +type GetPackageVersionMetadataFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Restore a package version from the recycle bin to its associated feed. +func (client *ClientImpl) RestorePackageVersionFromRecycleBin(ctx context.Context, args RestorePackageVersionFromRecycleBinArgs) error { + if args.PackageVersionDetails == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionDetails"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + body, marshalErr := json.Marshal(*args.PackageVersionDetails) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("07143752-3d94-45fd-86c2-0c77ed87847b") + _, 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 err + } + + return nil +} + +// Arguments for the RestorePackageVersionFromRecycleBin function +type RestorePackageVersionFromRecycleBinArgs struct { + // (required) Set the 'Deleted' state to 'false' to restore the package to its feed. + PackageVersionDetails *PyPiRecycleBinPackageVersionDetails + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Update state for a package version. +func (client *ClientImpl) UpdatePackageVersion(ctx context.Context, args UpdatePackageVersionArgs) error { + if args.PackageVersionDetails == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionDetails"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + body, marshalErr := json.Marshal(*args.PackageVersionDetails) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("d146ac7e-9e3f-4448-b956-f9bb3bdf9b2e") + _, 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 err + } + + return nil +} + +// Arguments for the UpdatePackageVersion function +type UpdatePackageVersionArgs struct { + // (required) Details to be updated. + PackageVersionDetails *PackageVersionDetails + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) Project ID or project name + Project *string +} diff --git a/azuredevops/pypiapi/models.go b/azuredevops/pypiapi/models.go new file mode 100644 index 00000000..03165acb --- /dev/null +++ b/azuredevops/pypiapi/models.go @@ -0,0 +1,84 @@ +// -------------------------------------------------------------------------------------------- +// 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 pypiapi + +import ( + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/packagingshared" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +// Package version metadata for a Python package +type Package struct { + // Related REST links. + Links interface{} `json:"_links,omitempty"` + // If and when the package was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Package Id. + Id *string `json:"id,omitempty"` + // The display name of the package. + Name *string `json:"name,omitempty"` + // If and when the package was permanently deleted. + PermanentlyDeletedDate *azuredevops.Time `json:"permanentlyDeletedDate,omitempty"` + // The history of upstream sources for this package. The first source in the list is the immediate source from which this package was saved. + SourceChain *[]packagingshared.UpstreamSourceInfo `json:"sourceChain,omitempty"` + // The version of the package. + Version *string `json:"version,omitempty"` +} + +type PackageVersionDetails struct { + // The view to which the package version will be added + Views *webapi.JsonPatchOperation `json:"views,omitempty"` +} + +// Describes PyPi batch operation types. +type PyPiBatchOperationType string + +type pyPiBatchOperationTypeValuesType struct { + Promote PyPiBatchOperationType + Delete PyPiBatchOperationType + PermanentDelete PyPiBatchOperationType + RestoreToFeed PyPiBatchOperationType +} + +var PyPiBatchOperationTypeValues = pyPiBatchOperationTypeValuesType{ + // Promote package versions to a release view. If constructing a PyPiPackagesBatchRequest object with this type, use BatchPromoteData for its Data property. Not supported in the Recycle Bin. + Promote: "promote", + // Move package versions to the feed's Recycle Bin. Not supported in the Recycle Bin. + Delete: "delete", + // Permanently delete package versions. Only supported in the Recycle Bin. + PermanentDelete: "permanentDelete", + // Restore deleted package versions to the feed. Only supported in the Recycle Bin. + RestoreToFeed: "restoreToFeed", +} + +// A batch of operations to apply to package versions. +type PyPiPackagesBatchRequest struct { + // Data required to perform the operation. This is optional based on the type of the operation. Use BatchPromoteData if performing a promote operation. + Data interface{} `json:"data,omitempty"` + // Type of operation that needs to be performed on packages. + Operation *PyPiBatchOperationType `json:"operation,omitempty"` + // The packages onto which the operation will be performed. + Packages *[]packagingshared.MinimalPackageDetails `json:"packages,omitempty"` +} + +// Deletion state of a Python package. +type PyPiPackageVersionDeletionState struct { + // UTC date the package was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Name of the package. + Name *string `json:"name,omitempty"` + // Version of the package. + Version *string `json:"version,omitempty"` +} + +type PyPiRecycleBinPackageVersionDetails struct { + // Setting to false will undo earlier deletion and restore the package to feed. + Deleted *bool `json:"deleted,omitempty"` +} diff --git a/azuredevops/release/client.go b/azuredevops/release/client.go new file mode 100644 index 00000000..a753315d --- /dev/null +++ b/azuredevops/release/client.go @@ -0,0 +1,1583 @@ +// -------------------------------------------------------------------------------------------- +// 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 release + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "io" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("efc2f575-36ef-48e9-b672-0c6fb4a48ac5") + +type Client interface { + // [Preview API] Creates a new folder. + CreateFolder(context.Context, CreateFolderArgs) (*Folder, error) + // Create a release. + CreateRelease(context.Context, CreateReleaseArgs) (*Release, error) + // Create a release definition + CreateReleaseDefinition(context.Context, CreateReleaseDefinitionArgs) (*ReleaseDefinition, error) + // [Preview API] Deletes a definition folder for given folder name and path and all it's existing definitions. + DeleteFolder(context.Context, DeleteFolderArgs) error + // Delete a release definition. + DeleteReleaseDefinition(context.Context, DeleteReleaseDefinitionArgs) error + // Get a list of approvals + GetApprovals(context.Context, GetApprovalsArgs) (*GetApprovalsResponseValue, error) + // [Preview API] Get release definition for a given definitionId and revision + GetDefinitionRevision(context.Context, GetDefinitionRevisionArgs) (io.ReadCloser, error) + GetDeployments(context.Context, GetDeploymentsArgs) (*GetDeploymentsResponseValue, error) + // [Preview API] Gets folders. + GetFolders(context.Context, GetFoldersArgs) (*[]Folder, error) + // [Preview API] Get logs for a release Id. + GetLogs(context.Context, GetLogsArgs) (io.ReadCloser, error) + // Get manual intervention for a given release and manual intervention id. + GetManualIntervention(context.Context, GetManualInterventionArgs) (*ManualIntervention, error) + // List all manual interventions for a given release. + GetManualInterventions(context.Context, GetManualInterventionsArgs) (*[]ManualIntervention, error) + // Get a Release + GetRelease(context.Context, GetReleaseArgs) (*Release, error) + // Get a release definition. + GetReleaseDefinition(context.Context, GetReleaseDefinitionArgs) (*ReleaseDefinition, error) + // [Preview API] Get revision history for a release definition + GetReleaseDefinitionHistory(context.Context, GetReleaseDefinitionHistoryArgs) (*[]ReleaseDefinitionRevision, error) + // Get a list of release definitions. + GetReleaseDefinitions(context.Context, GetReleaseDefinitionsArgs) (*GetReleaseDefinitionsResponseValue, error) + // [Preview API] Get a release environment. + GetReleaseEnvironment(context.Context, GetReleaseEnvironmentArgs) (*ReleaseEnvironment, error) + // Get release for a given revision number. + GetReleaseRevision(context.Context, GetReleaseRevisionArgs) (io.ReadCloser, error) + // Get a list of releases + GetReleases(context.Context, GetReleasesArgs) (*GetReleasesResponseValue, error) + // [Preview API] Get a release task attachment. + GetReleaseTaskAttachmentContent(context.Context, GetReleaseTaskAttachmentContentArgs) (io.ReadCloser, error) + // [Preview API] Get the release task attachments. + GetReleaseTaskAttachments(context.Context, GetReleaseTaskAttachmentsArgs) (*[]ReleaseTaskAttachment, error) + // [Preview API] Gets the task log of a release as a plain text file. + GetTaskLog(context.Context, GetTaskLogArgs) (io.ReadCloser, error) + // [Preview API] Updates an existing folder at given existing path. + UpdateFolder(context.Context, UpdateFolderArgs) (*Folder, error) + // [Preview API] Updates the gate for a deployment. + UpdateGates(context.Context, UpdateGatesArgs) (*ReleaseGates, error) + // Update manual intervention. + UpdateManualIntervention(context.Context, UpdateManualInterventionArgs) (*ManualIntervention, error) + // Update a complete release object. + UpdateRelease(context.Context, UpdateReleaseArgs) (*Release, error) + // Update status of an approval + UpdateReleaseApproval(context.Context, UpdateReleaseApprovalArgs) (*ReleaseApproval, error) + // Update a release definition. + UpdateReleaseDefinition(context.Context, UpdateReleaseDefinitionArgs) (*ReleaseDefinition, error) + // [Preview API] Update the status of a release environment + UpdateReleaseEnvironment(context.Context, UpdateReleaseEnvironmentArgs) (*ReleaseEnvironment, error) + // Update few properties of a release. + UpdateReleaseResource(context.Context, UpdateReleaseResourceArgs) (*Release, 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] Creates a new folder. +func (client *ClientImpl) CreateFolder(ctx context.Context, args CreateFolderArgs) (*Folder, error) { + if args.Folder == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Folder"} + } + 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.Folder) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Folder + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateFolder function +type CreateFolderArgs struct { + // (required) Folder to create. + Folder *Folder + // (required) Project ID or project name + Project *string +} + +// Create a release. +func (client *ClientImpl) CreateRelease(ctx context.Context, args CreateReleaseArgs) (*Release, error) { + if args.ReleaseStartMetadata == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseStartMetadata"} + } + 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.ReleaseStartMetadata) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + 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 Release + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateRelease function +type CreateReleaseArgs struct { + // (required) Metadata to create a release. + ReleaseStartMetadata *ReleaseStartMetadata + // (required) Project ID or project name + Project *string +} + +// Create a release definition +func (client *ClientImpl) CreateReleaseDefinition(ctx context.Context, args CreateReleaseDefinitionArgs) (*ReleaseDefinition, error) { + if args.ReleaseDefinition == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseDefinition"} + } + 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.ReleaseDefinition) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") + 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 ReleaseDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateReleaseDefinition function +type CreateReleaseDefinitionArgs struct { + // (required) release definition object to create. + ReleaseDefinition *ReleaseDefinition + // (required) Project ID or project name + Project *string +} + +// [Preview API] Deletes a definition folder for given folder name and path and all it's existing definitions. +func (client *ClientImpl) DeleteFolder(ctx context.Context, args DeleteFolderArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Path == nil || *args.Path == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Path"} + } + routeValues["path"] = *args.Path + + locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") + _, 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 DeleteFolder function +type DeleteFolderArgs struct { + // (required) Project ID or project name + Project *string + // (required) Path of the folder to delete. + Path *string +} + +// Delete a release definition. +func (client *ClientImpl) DeleteReleaseDefinition(ctx context.Context, args DeleteReleaseDefinitionArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DefinitionId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + queryParams := url.Values{} + if args.Comment != nil { + queryParams.Add("comment", *args.Comment) + } + if args.ForceDelete != nil { + queryParams.Add("forceDelete", strconv.FormatBool(*args.ForceDelete)) + } + locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteReleaseDefinition function +type DeleteReleaseDefinitionArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release definition. + DefinitionId *int + // (optional) Comment for deleting a release definition. + Comment *string + // (optional) 'true' to automatically cancel any in-progress release deployments and proceed with release definition deletion . Default is 'false'. + ForceDelete *bool +} + +// Get a list of approvals +func (client *ClientImpl) GetApprovals(ctx context.Context, args GetApprovalsArgs) (*GetApprovalsResponseValue, 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.AssignedToFilter != nil { + queryParams.Add("assignedToFilter", *args.AssignedToFilter) + } + if args.StatusFilter != nil { + queryParams.Add("statusFilter", string(*args.StatusFilter)) + } + if args.ReleaseIdsFilter != nil { + var stringList []string + for _, item := range *args.ReleaseIdsFilter { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseIdsFilter", listAsString) + } + if args.TypeFilter != nil { + queryParams.Add("typeFilter", string(*args.TypeFilter)) + } + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken)) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + if args.IncludeMyGroupApprovals != nil { + queryParams.Add("includeMyGroupApprovals", strconv.FormatBool(*args.IncludeMyGroupApprovals)) + } + locationId, _ := uuid.Parse("b47c6458-e73b-47cb-a770-4df1e8813a91") + 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 GetApprovalsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetApprovals function +type GetApprovalsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Approvals assigned to this user. + AssignedToFilter *string + // (optional) Approvals with this status. Default is 'pending'. + StatusFilter *ApprovalStatus + // (optional) Approvals for release id(s) mentioned in the filter. Multiple releases can be mentioned by separating them with ',' e.g. releaseIdsFilter=1,2,3,4. + ReleaseIdsFilter *[]int + // (optional) Approval with this type. + TypeFilter *ApprovalType + // (optional) Number of approvals to get. Default is 50. + Top *int + // (optional) Gets the approvals after the continuation token provided. + ContinuationToken *int + // (optional) Gets the results in the defined order of created approvals. Default is 'descending'. + QueryOrder *ReleaseQueryOrder + // (optional) 'true' to include my group approvals. Default is 'false'. + IncludeMyGroupApprovals *bool +} + +// Return type for the GetApprovals function +type GetApprovalsResponseValue struct { + Value []ReleaseApproval + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get release definition for a given definitionId and revision +func (client *ClientImpl) GetDefinitionRevision(ctx context.Context, args GetDefinitionRevisionArgs) (io.ReadCloser, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + if args.Revision == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Revision"} + } + routeValues["revision"] = strconv.Itoa(*args.Revision) + + locationId, _ := uuid.Parse("258b82e0-9d41-43f3-86d6-fef14ddd44bc") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "text/plain", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetDefinitionRevision function +type GetDefinitionRevisionArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the definition. + DefinitionId *int + // (required) Id of the revision. + Revision *int +} + +func (client *ClientImpl) GetDeployments(ctx context.Context, args GetDeploymentsArgs) (*GetDeploymentsResponseValue, 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.DefinitionId != nil { + queryParams.Add("definitionId", strconv.Itoa(*args.DefinitionId)) + } + if args.DefinitionEnvironmentId != nil { + queryParams.Add("definitionEnvironmentId", strconv.Itoa(*args.DefinitionEnvironmentId)) + } + if args.CreatedBy != nil { + queryParams.Add("createdBy", *args.CreatedBy) + } + if args.MinModifiedTime != nil { + queryParams.Add("minModifiedTime", (*args.MinModifiedTime).String()) + } + if args.MaxModifiedTime != nil { + queryParams.Add("maxModifiedTime", (*args.MaxModifiedTime).String()) + } + if args.DeploymentStatus != nil { + queryParams.Add("deploymentStatus", string(*args.DeploymentStatus)) + } + if args.OperationStatus != nil { + queryParams.Add("operationStatus", string(*args.OperationStatus)) + } + if args.LatestAttemptsOnly != nil { + queryParams.Add("latestAttemptsOnly", strconv.FormatBool(*args.LatestAttemptsOnly)) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken)) + } + if args.CreatedFor != nil { + queryParams.Add("createdFor", *args.CreatedFor) + } + if args.MinStartedTime != nil { + queryParams.Add("minStartedTime", (*args.MinStartedTime).String()) + } + if args.MaxStartedTime != nil { + queryParams.Add("maxStartedTime", (*args.MaxStartedTime).String()) + } + if args.SourceBranch != nil { + queryParams.Add("sourceBranch", *args.SourceBranch) + } + locationId, _ := uuid.Parse("b005ef73-cddc-448e-9ba2-5193bf36b19f") + 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 GetDeploymentsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetDeployments function +type GetDeploymentsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) + DefinitionId *int + // (optional) + DefinitionEnvironmentId *int + // (optional) + CreatedBy *string + // (optional) + MinModifiedTime *azuredevops.Time + // (optional) + MaxModifiedTime *azuredevops.Time + // (optional) + DeploymentStatus *DeploymentStatus + // (optional) + OperationStatus *DeploymentOperationStatus + // (optional) + LatestAttemptsOnly *bool + // (optional) + QueryOrder *ReleaseQueryOrder + // (optional) + Top *int + // (optional) + ContinuationToken *int + // (optional) + CreatedFor *string + // (optional) + MinStartedTime *azuredevops.Time + // (optional) + MaxStartedTime *azuredevops.Time + // (optional) + SourceBranch *string +} + +// Return type for the GetDeployments function +type GetDeploymentsResponseValue struct { + Value []Deployment + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Gets folders. +func (client *ClientImpl) GetFolders(ctx context.Context, args GetFoldersArgs) (*[]Folder, 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.Path != nil && *args.Path != "" { + routeValues["path"] = *args.Path + } + + queryParams := url.Values{} + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Folder + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFolders function +type GetFoldersArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Path of the folder. + Path *string + // (optional) Gets the results in the defined order. Default is 'None'. + QueryOrder *FolderPathQueryOrder +} + +// [Preview API] Get logs for a release Id. +func (client *ClientImpl) GetLogs(ctx context.Context, args GetLogsArgs) (io.ReadCloser, 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.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + locationId, _ := uuid.Parse("c37fbab5-214b-48e4-a55b-cb6b4f6e4038") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetLogs function +type GetLogsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int +} + +// Get manual intervention for a given release and manual intervention id. +func (client *ClientImpl) GetManualIntervention(ctx context.Context, args GetManualInterventionArgs) (*ManualIntervention, 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.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.ManualInterventionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ManualInterventionId"} + } + routeValues["manualInterventionId"] = strconv.Itoa(*args.ManualInterventionId) + + locationId, _ := uuid.Parse("616c46e4-f370-4456-adaa-fbaf79c7b79e") + 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 ManualIntervention + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetManualIntervention function +type GetManualInterventionArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of the manual intervention. + ManualInterventionId *int +} + +// List all manual interventions for a given release. +func (client *ClientImpl) GetManualInterventions(ctx context.Context, args GetManualInterventionsArgs) (*[]ManualIntervention, 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.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + locationId, _ := uuid.Parse("616c46e4-f370-4456-adaa-fbaf79c7b79e") + 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 []ManualIntervention + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetManualInterventions function +type GetManualInterventionsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int +} + +// Get a Release +func (client *ClientImpl) GetRelease(ctx context.Context, args GetReleaseArgs) (*Release, 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.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + queryParams := url.Values{} + if args.ApprovalFilters != nil { + queryParams.Add("approvalFilters", string(*args.ApprovalFilters)) + } + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.TopGateRecords != nil { + queryParams.Add("$topGateRecords", strconv.Itoa(*args.TopGateRecords)) + } + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + 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 Release + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRelease function +type GetReleaseArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (optional) A filter which would allow fetching approval steps selectively based on whether it is automated, or manual. This would also decide whether we should fetch pre and post approval snapshots. Assumes All by default + ApprovalFilters *ApprovalFilters + // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release will contain values for the specified property Ids (if they exist). If not set, properties will not be included. + PropertyFilters *[]string + // (optional) A property that should be expanded in the release. + Expand *SingleReleaseExpands + // (optional) Number of release gate records to get. Default is 5. + TopGateRecords *int +} + +// Get a release definition. +func (client *ClientImpl) GetReleaseDefinition(ctx context.Context, args GetReleaseDefinitionArgs) (*ReleaseDefinition, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + queryParams := url.Values{} + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") + 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 ReleaseDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetReleaseDefinition function +type GetReleaseDefinitionArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release definition. + DefinitionId *int + // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release Definition will contain values for the specified property Ids (if they exist). If not set, properties will not be included. + PropertyFilters *[]string +} + +// [Preview API] Get revision history for a release definition +func (client *ClientImpl) GetReleaseDefinitionHistory(ctx context.Context, args GetReleaseDefinitionHistoryArgs) (*[]ReleaseDefinitionRevision, 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.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + locationId, _ := uuid.Parse("258b82e0-9d41-43f3-86d6-fef14ddd44bc") + 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 []ReleaseDefinitionRevision + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetReleaseDefinitionHistory function +type GetReleaseDefinitionHistoryArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the definition. + DefinitionId *int +} + +// Get a list of release definitions. +func (client *ClientImpl) GetReleaseDefinitions(ctx context.Context, args GetReleaseDefinitionsArgs) (*GetReleaseDefinitionsResponseValue, 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.SearchText != nil { + queryParams.Add("searchText", *args.SearchText) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.ArtifactType != nil { + queryParams.Add("artifactType", *args.ArtifactType) + } + if args.ArtifactSourceId != nil { + queryParams.Add("artifactSourceId", *args.ArtifactSourceId) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + if args.Path != nil { + queryParams.Add("path", *args.Path) + } + if args.IsExactNameMatch != nil { + queryParams.Add("isExactNameMatch", strconv.FormatBool(*args.IsExactNameMatch)) + } + if args.TagFilter != nil { + listAsString := strings.Join((*args.TagFilter)[:], ",") + queryParams.Add("tagFilter", listAsString) + } + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + if args.DefinitionIdFilter != nil { + listAsString := strings.Join((*args.DefinitionIdFilter)[:], ",") + queryParams.Add("definitionIdFilter", listAsString) + } + if args.IsDeleted != nil { + queryParams.Add("isDeleted", strconv.FormatBool(*args.IsDeleted)) + } + if args.SearchTextContainsFolderName != nil { + queryParams.Add("searchTextContainsFolderName", strconv.FormatBool(*args.SearchTextContainsFolderName)) + } + locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") + 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 GetReleaseDefinitionsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetReleaseDefinitions function +type GetReleaseDefinitionsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Get release definitions with names containing searchText. + SearchText *string + // (optional) The properties that should be expanded in the list of Release definitions. + Expand *ReleaseDefinitionExpands + // (optional) Release definitions with given artifactType will be returned. Values can be Build, Jenkins, GitHub, Nuget, Team Build (external), ExternalTFSBuild, Git, TFVC, ExternalTfsXamlBuild. + ArtifactType *string + // (optional) Release definitions with given artifactSourceId will be returned. e.g. For build it would be {projectGuid}:{BuildDefinitionId}, for Jenkins it would be {JenkinsConnectionId}:{JenkinsDefinitionId}, for TfsOnPrem it would be {TfsOnPremConnectionId}:{ProjectName}:{TfsOnPremDefinitionId}. For third-party artifacts e.g. TeamCity, BitBucket you may refer 'uniqueSourceIdentifier' inside vss-extension.json at https://github.com/Microsoft/vsts-rm-extensions/blob/master/Extensions. + ArtifactSourceId *string + // (optional) Number of release definitions to get. + Top *int + // (optional) Gets the release definitions after the continuation token provided. + ContinuationToken *string + // (optional) Gets the results in the defined order. Default is 'IdAscending'. + QueryOrder *ReleaseDefinitionQueryOrder + // (optional) Gets the release definitions under the specified path. + Path *string + // (optional) 'true'to gets the release definitions with exact match as specified in searchText. Default is 'false'. + IsExactNameMatch *bool + // (optional) A comma-delimited list of tags. Only release definitions with these tags will be returned. + TagFilter *[]string + // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release Definitions will contain values for the specified property Ids (if they exist). If not set, properties will not be included. Note that this will not filter out any Release Definition from results irrespective of whether it has property set or not. + PropertyFilters *[]string + // (optional) A comma-delimited list of release definitions to retrieve. + DefinitionIdFilter *[]string + // (optional) 'true' to get release definitions that has been deleted. Default is 'false' + IsDeleted *bool + // (optional) 'true' to get the release definitions under the folder with name as specified in searchText. Default is 'false'. + SearchTextContainsFolderName *bool +} + +// Return type for the GetReleaseDefinitions function +type GetReleaseDefinitionsResponseValue struct { + Value []ReleaseDefinition + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get a release environment. +func (client *ClientImpl) GetReleaseEnvironment(ctx context.Context, args GetReleaseEnvironmentArgs) (*ReleaseEnvironment, 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.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.EnvironmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} + } + routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) + + locationId, _ := uuid.Parse("a7e426b1-03dc-48af-9dfe-c98bac612dcb") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.6", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ReleaseEnvironment + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetReleaseEnvironment function +type GetReleaseEnvironmentArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of the release environment. + EnvironmentId *int +} + +// Get release for a given revision number. +func (client *ClientImpl) GetReleaseRevision(ctx context.Context, args GetReleaseRevisionArgs) (io.ReadCloser, 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.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + queryParams := url.Values{} + if args.DefinitionSnapshotRevision == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "definitionSnapshotRevision"} + } + queryParams.Add("definitionSnapshotRevision", strconv.Itoa(*args.DefinitionSnapshotRevision)) + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + 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 GetReleaseRevision function +type GetReleaseRevisionArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Definition snapshot revision number. + DefinitionSnapshotRevision *int +} + +// Get a list of releases +func (client *ClientImpl) GetReleases(ctx context.Context, args GetReleasesArgs) (*GetReleasesResponseValue, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.DefinitionId != nil { + queryParams.Add("definitionId", strconv.Itoa(*args.DefinitionId)) + } + if args.DefinitionEnvironmentId != nil { + queryParams.Add("definitionEnvironmentId", strconv.Itoa(*args.DefinitionEnvironmentId)) + } + if args.SearchText != nil { + queryParams.Add("searchText", *args.SearchText) + } + if args.CreatedBy != nil { + queryParams.Add("createdBy", *args.CreatedBy) + } + if args.StatusFilter != nil { + queryParams.Add("statusFilter", string(*args.StatusFilter)) + } + if args.EnvironmentStatusFilter != nil { + queryParams.Add("environmentStatusFilter", strconv.Itoa(*args.EnvironmentStatusFilter)) + } + if args.MinCreatedTime != nil { + queryParams.Add("minCreatedTime", (*args.MinCreatedTime).String()) + } + if args.MaxCreatedTime != nil { + queryParams.Add("maxCreatedTime", (*args.MaxCreatedTime).String()) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.ArtifactTypeId != nil { + queryParams.Add("artifactTypeId", *args.ArtifactTypeId) + } + if args.SourceId != nil { + queryParams.Add("sourceId", *args.SourceId) + } + if args.ArtifactVersionId != nil { + queryParams.Add("artifactVersionId", *args.ArtifactVersionId) + } + if args.SourceBranchFilter != nil { + queryParams.Add("sourceBranchFilter", *args.SourceBranchFilter) + } + if args.IsDeleted != nil { + queryParams.Add("isDeleted", strconv.FormatBool(*args.IsDeleted)) + } + if args.TagFilter != nil { + listAsString := strings.Join((*args.TagFilter)[:], ",") + queryParams.Add("tagFilter", listAsString) + } + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + if args.ReleaseIdFilter != nil { + var stringList []string + for _, item := range *args.ReleaseIdFilter { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseIdFilter", listAsString) + } + if args.Path != nil { + queryParams.Add("path", *args.Path) + } + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + 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 GetReleasesResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetReleases function +type GetReleasesArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) Releases from this release definition Id. + DefinitionId *int + // (optional) + DefinitionEnvironmentId *int + // (optional) Releases with names containing searchText. + SearchText *string + // (optional) Releases created by this user. + CreatedBy *string + // (optional) Releases that have this status. + StatusFilter *ReleaseStatus + // (optional) + EnvironmentStatusFilter *int + // (optional) Releases that were created after this time. + MinCreatedTime *azuredevops.Time + // (optional) Releases that were created before this time. + MaxCreatedTime *azuredevops.Time + // (optional) Gets the results in the defined order of created date for releases. Default is descending. + QueryOrder *ReleaseQueryOrder + // (optional) Number of releases to get. Default is 50. + Top *int + // (optional) Gets the releases after the continuation token provided. + ContinuationToken *int + // (optional) The property that should be expanded in the list of releases. + Expand *ReleaseExpands + // (optional) Releases with given artifactTypeId will be returned. Values can be Build, Jenkins, GitHub, Nuget, Team Build (external), ExternalTFSBuild, Git, TFVC, ExternalTfsXamlBuild. + ArtifactTypeId *string + // (optional) Unique identifier of the artifact used. e.g. For build it would be {projectGuid}:{BuildDefinitionId}, for Jenkins it would be {JenkinsConnectionId}:{JenkinsDefinitionId}, for TfsOnPrem it would be {TfsOnPremConnectionId}:{ProjectName}:{TfsOnPremDefinitionId}. For third-party artifacts e.g. TeamCity, BitBucket you may refer 'uniqueSourceIdentifier' inside vss-extension.json https://github.com/Microsoft/vsts-rm-extensions/blob/master/Extensions. + SourceId *string + // (optional) Releases with given artifactVersionId will be returned. E.g. in case of Build artifactType, it is buildId. + ArtifactVersionId *string + // (optional) Releases with given sourceBranchFilter will be returned. + SourceBranchFilter *string + // (optional) Gets the soft deleted releases, if true. + IsDeleted *bool + // (optional) A comma-delimited list of tags. Only releases with these tags will be returned. + TagFilter *[]string + // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Releases will contain values for the specified property Ids (if they exist). If not set, properties will not be included. Note that this will not filter out any Release from results irrespective of whether it has property set or not. + PropertyFilters *[]string + // (optional) A comma-delimited list of releases Ids. Only releases with these Ids will be returned. + ReleaseIdFilter *[]int + // (optional) Releases under this folder path will be returned + Path *string +} + +// Return type for the GetReleases function +type GetReleasesResponseValue struct { + Value []Release + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get a release task attachment. +func (client *ClientImpl) GetReleaseTaskAttachmentContent(ctx context.Context, args GetReleaseTaskAttachmentContentArgs) (io.ReadCloser, 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.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.EnvironmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} + } + routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) + if args.AttemptId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttemptId"} + } + routeValues["attemptId"] = strconv.Itoa(*args.AttemptId) + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.TimelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} + } + routeValues["timelineId"] = (*args.TimelineId).String() + if args.RecordId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RecordId"} + } + routeValues["recordId"] = (*args.RecordId).String() + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + locationId, _ := uuid.Parse("60b86efb-7b8c-4853-8f9f-aa142b77b479") + 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 GetReleaseTaskAttachmentContent function +type GetReleaseTaskAttachmentContentArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of the release environment. + EnvironmentId *int + // (required) Attempt number of deployment. + AttemptId *int + // (required) Plan Id of the deploy phase. + PlanId *uuid.UUID + // (required) Timeline Id of the task. + TimelineId *uuid.UUID + // (required) Record Id of attachment. + RecordId *uuid.UUID + // (required) Type of the attachment. + Type *string + // (required) Name of the attachment. + Name *string +} + +// [Preview API] Get the release task attachments. +func (client *ClientImpl) GetReleaseTaskAttachments(ctx context.Context, args GetReleaseTaskAttachmentsArgs) (*[]ReleaseTaskAttachment, 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.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.EnvironmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} + } + routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) + if args.AttemptId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttemptId"} + } + routeValues["attemptId"] = strconv.Itoa(*args.AttemptId) + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + + locationId, _ := uuid.Parse("a4d06688-0dfa-4895-82a5-f43ec9452306") + 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 []ReleaseTaskAttachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetReleaseTaskAttachments function +type GetReleaseTaskAttachmentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of the release environment. + EnvironmentId *int + // (required) Attempt number of deployment. + AttemptId *int + // (required) Plan Id of the deploy phase. + PlanId *uuid.UUID + // (required) Type of the attachment. + Type *string +} + +// [Preview API] Gets the task log of a release as a plain text file. +func (client *ClientImpl) GetTaskLog(ctx context.Context, args GetTaskLogArgs) (io.ReadCloser, 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.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.EnvironmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} + } + routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) + if args.ReleaseDeployPhaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseDeployPhaseId"} + } + routeValues["releaseDeployPhaseId"] = strconv.Itoa(*args.ReleaseDeployPhaseId) + if args.TaskId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TaskId"} + } + routeValues["taskId"] = strconv.Itoa(*args.TaskId) + + queryParams := url.Values{} + if args.StartLine != nil { + queryParams.Add("startLine", strconv.FormatUint(*args.StartLine, 10)) + } + if args.EndLine != nil { + queryParams.Add("endLine", strconv.FormatUint(*args.EndLine, 10)) + } + locationId, _ := uuid.Parse("17c91af7-09fd-4256-bff1-c24ee4f73bc0") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "text/plain", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetTaskLog function +type GetTaskLogArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of release environment. + EnvironmentId *int + // (required) Release deploy phase Id. + ReleaseDeployPhaseId *int + // (required) ReleaseTask Id for the log. + TaskId *int + // (optional) Starting line number for logs + StartLine *uint64 + // (optional) Ending line number for logs + EndLine *uint64 +} + +// [Preview API] Updates an existing folder at given existing path. +func (client *ClientImpl) UpdateFolder(ctx context.Context, args UpdateFolderArgs) (*Folder, error) { + if args.Folder == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Folder"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Path == nil || *args.Path == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Path"} + } + routeValues["path"] = *args.Path + + body, marshalErr := json.Marshal(*args.Folder) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Folder + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateFolder function +type UpdateFolderArgs struct { + // (required) folder. + Folder *Folder + // (required) Project ID or project name + Project *string + // (required) Path of the folder to update. + Path *string +} + +// [Preview API] Updates the gate for a deployment. +func (client *ClientImpl) UpdateGates(ctx context.Context, args UpdateGatesArgs) (*ReleaseGates, error) { + if args.GateUpdateMetadata == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GateUpdateMetadata"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.GateStepId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GateStepId"} + } + routeValues["gateStepId"] = strconv.Itoa(*args.GateStepId) + + body, marshalErr := json.Marshal(*args.GateUpdateMetadata) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2666a539-2001-4f80-bcc7-0379956749d4") + 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 ReleaseGates + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateGates function +type UpdateGatesArgs struct { + // (required) Metadata to patch the Release Gates. + GateUpdateMetadata *GateUpdateMetadata + // (required) Project ID or project name + Project *string + // (required) Gate step Id. + GateStepId *int +} + +// Update manual intervention. +func (client *ClientImpl) UpdateManualIntervention(ctx context.Context, args UpdateManualInterventionArgs) (*ManualIntervention, error) { + if args.ManualInterventionUpdateMetadata == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ManualInterventionUpdateMetadata"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.ManualInterventionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ManualInterventionId"} + } + routeValues["manualInterventionId"] = strconv.Itoa(*args.ManualInterventionId) + + body, marshalErr := json.Marshal(*args.ManualInterventionUpdateMetadata) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("616c46e4-f370-4456-adaa-fbaf79c7b79e") + 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 ManualIntervention + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateManualIntervention function +type UpdateManualInterventionArgs struct { + // (required) Meta data to update manual intervention. + ManualInterventionUpdateMetadata *ManualInterventionUpdateMetadata + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of the manual intervention. + ManualInterventionId *int +} + +// Update a complete release object. +func (client *ClientImpl) UpdateRelease(ctx context.Context, args UpdateReleaseArgs) (*Release, error) { + if args.Release == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Release"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + body, marshalErr := json.Marshal(*args.Release) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + 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 Release + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateRelease function +type UpdateReleaseArgs struct { + // (required) Release object for update. + Release *Release + // (required) Project ID or project name + Project *string + // (required) Id of the release to update. + ReleaseId *int +} + +// Update status of an approval +func (client *ClientImpl) UpdateReleaseApproval(ctx context.Context, args UpdateReleaseApprovalArgs) (*ReleaseApproval, error) { + if args.Approval == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Approval"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ApprovalId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ApprovalId"} + } + routeValues["approvalId"] = strconv.Itoa(*args.ApprovalId) + + body, marshalErr := json.Marshal(*args.Approval) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("9328e074-59fb-465a-89d9-b09c82ee5109") + 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 ReleaseApproval + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateReleaseApproval function +type UpdateReleaseApprovalArgs struct { + // (required) ReleaseApproval object having status, approver and comments. + Approval *ReleaseApproval + // (required) Project ID or project name + Project *string + // (required) Id of the approval. + ApprovalId *int +} + +// Update a release definition. +func (client *ClientImpl) UpdateReleaseDefinition(ctx context.Context, args UpdateReleaseDefinitionArgs) (*ReleaseDefinition, error) { + if args.ReleaseDefinition == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseDefinition"} + } + 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.ReleaseDefinition) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") + 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 ReleaseDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateReleaseDefinition function +type UpdateReleaseDefinitionArgs struct { + // (required) Release definition object to update. + ReleaseDefinition *ReleaseDefinition + // (required) Project ID or project name + Project *string +} + +// [Preview API] Update the status of a release environment +func (client *ClientImpl) UpdateReleaseEnvironment(ctx context.Context, args UpdateReleaseEnvironmentArgs) (*ReleaseEnvironment, error) { + if args.EnvironmentUpdateData == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentUpdateData"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.EnvironmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} + } + routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) + + body, marshalErr := json.Marshal(*args.EnvironmentUpdateData) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a7e426b1-03dc-48af-9dfe-c98bac612dcb") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.6", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ReleaseEnvironment + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateReleaseEnvironment function +type UpdateReleaseEnvironmentArgs struct { + // (required) Environment update meta data. + EnvironmentUpdateData *ReleaseEnvironmentUpdateMetadata + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of release environment. + EnvironmentId *int +} + +// Update few properties of a release. +func (client *ClientImpl) UpdateReleaseResource(ctx context.Context, args UpdateReleaseResourceArgs) (*Release, error) { + if args.ReleaseUpdateMetadata == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseUpdateMetadata"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + body, marshalErr := json.Marshal(*args.ReleaseUpdateMetadata) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + 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 Release + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateReleaseResource function +type UpdateReleaseResourceArgs struct { + // (required) Properties of release to update. + ReleaseUpdateMetadata *ReleaseUpdateMetadata + // (required) Project ID or project name + Project *string + // (required) Id of the release to update. + ReleaseId *int +} diff --git a/azuredevops/release/models.go b/azuredevops/release/models.go new file mode 100644 index 00000000..a10416ad --- /dev/null +++ b/azuredevops/release/models.go @@ -0,0 +1,3064 @@ +// -------------------------------------------------------------------------------------------- +// 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 release + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/distributedtaskcommon" + "github.com/microsoft/azure-devops-go-api/azuredevops/forminput" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type AgentArtifactDefinition struct { + // Gets or sets the artifact definition alias. + Alias *string `json:"alias,omitempty"` + // Gets or sets the artifact type. + ArtifactType *AgentArtifactType `json:"artifactType,omitempty"` + // Gets or sets the artifact definition details. + Details *string `json:"details,omitempty"` + // Gets or sets the name of artifact definition. + Name *string `json:"name,omitempty"` + // Gets or sets the version of artifact definition. + Version *string `json:"version,omitempty"` +} + +type AgentArtifactType string + +type agentArtifactTypeValuesType struct { + XamlBuild AgentArtifactType + Build AgentArtifactType + Jenkins AgentArtifactType + FileShare AgentArtifactType + Nuget AgentArtifactType + TfsOnPrem AgentArtifactType + GitHub AgentArtifactType + TfGit AgentArtifactType + ExternalTfsBuild AgentArtifactType + Custom AgentArtifactType + Tfvc AgentArtifactType +} + +var AgentArtifactTypeValues = agentArtifactTypeValuesType{ + // Indicates XamlBuild artifact + XamlBuild: "xamlBuild", + // Indicates Build artifact + Build: "build", + // Indicates Jenkins artifact + Jenkins: "jenkins", + // Indicates FileShare artifact + FileShare: "fileShare", + // Indicates Nuget artifact + Nuget: "nuget", + // Indicates TfsOnPrem artifact + TfsOnPrem: "tfsOnPrem", + // Indicates GitHub artifact + GitHub: "gitHub", + // Indicates TFGit artifact + TfGit: "tfGit", + // Indicates ExternalTfsBuild artifact + ExternalTfsBuild: "externalTfsBuild", + // Indicates Custom artifact + Custom: "custom", + // Indicates Tfvc artifact + Tfvc: "tfvc", +} + +type AgentBasedDeployPhase struct { + // Gets and sets the name of deploy phase. + Name *string `json:"name,omitempty"` + // Indicates the deploy phase type. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Gets and sets the rank of deploy phase. + Rank *int `json:"rank,omitempty"` + // Gets and sets the reference name of deploy phase. + RefName *string `json:"refName,omitempty"` + // Gets and sets the workflow tasks for the deploy phase. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` + // Gets and sets the agent job deployment input + DeploymentInput *AgentDeploymentInput `json:"deploymentInput,omitempty"` +} + +type AgentDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Artifacts that downloaded during job execution. + ArtifactsDownloadInput *ArtifactsDownloadInput `json:"artifactsDownloadInput,omitempty"` + // List demands that needs to meet to execute the job. + Demands *[]interface{} `json:"demands,omitempty"` + // Indicates whether to include access token in deployment job or not. + EnableAccessToken *bool `json:"enableAccessToken,omitempty"` + // Id of the pool on which job get executed. + QueueId *int `json:"queueId,omitempty"` + // Indicates whether artifacts downloaded while job execution or not. + SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` + // Specification for an agent on which a job gets executed. + AgentSpecification *AgentSpecification `json:"agentSpecification,omitempty"` + // Gets or sets the image ID. + ImageId *int `json:"imageId,omitempty"` + // Gets or sets the parallel execution input. + ParallelExecution *ExecutionInput `json:"parallelExecution,omitempty"` +} + +// Specification of the agent defined by the pool provider. +type AgentSpecification struct { + // Agent specification unique identifier. + Identifier *string `json:"identifier,omitempty"` +} + +// [Flags] +type ApprovalExecutionOrder string + +type approvalExecutionOrderValuesType struct { + BeforeGates ApprovalExecutionOrder + AfterSuccessfulGates ApprovalExecutionOrder + AfterGatesAlways ApprovalExecutionOrder +} + +var ApprovalExecutionOrderValues = approvalExecutionOrderValuesType{ + // Approvals shown before gates. + BeforeGates: "beforeGates", + // Approvals shown after successful execution of gates. + AfterSuccessfulGates: "afterSuccessfulGates", + // Approvals shown always after execution of gates. + AfterGatesAlways: "afterGatesAlways", +} + +// [Flags] +type ApprovalFilters string + +type approvalFiltersValuesType struct { + None ApprovalFilters + ManualApprovals ApprovalFilters + AutomatedApprovals ApprovalFilters + ApprovalSnapshots ApprovalFilters + All ApprovalFilters +} + +var ApprovalFiltersValues = approvalFiltersValuesType{ + // No approvals or approval snapshots. + None: "none", + // Manual approval steps but no approval snapshots (Use with ApprovalSnapshots for snapshots). + ManualApprovals: "manualApprovals", + // Automated approval steps but no approval snapshots (Use with ApprovalSnapshots for snapshots). + AutomatedApprovals: "automatedApprovals", + // No approval steps, but approval snapshots (Use with either ManualApprovals or AutomatedApprovals for approval steps). + ApprovalSnapshots: "approvalSnapshots", + // All approval steps and approval snapshots. + All: "all", +} + +type ApprovalOptions struct { + // Specify whether the approval can be skipped if the same approver approved the previous stage. + AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped *bool `json:"autoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped,omitempty"` + // Specify whether revalidate identity of approver before completing the approval. + EnforceIdentityRevalidation *bool `json:"enforceIdentityRevalidation,omitempty"` + // Approvals execution order. + ExecutionOrder *ApprovalExecutionOrder `json:"executionOrder,omitempty"` + // Specify whether the user requesting a release or deployment should allow to approver. + ReleaseCreatorCanBeApprover *bool `json:"releaseCreatorCanBeApprover,omitempty"` + // The number of approvals required to move release forward. '0' means all approvals required. + RequiredApproverCount *int `json:"requiredApproverCount,omitempty"` + // Approval timeout. Approval default timeout is 30 days. Maximum allowed timeout is 365 days. '0' means default timeout i.e 30 days. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` +} + +type ApprovalStatus string + +type approvalStatusValuesType struct { + Undefined ApprovalStatus + Pending ApprovalStatus + Approved ApprovalStatus + Rejected ApprovalStatus + Reassigned ApprovalStatus + Canceled ApprovalStatus + Skipped ApprovalStatus +} + +var ApprovalStatusValues = approvalStatusValuesType{ + // Indicates the approval does not have the status set. + Undefined: "undefined", + // Indicates the approval is pending. + Pending: "pending", + // Indicates the approval is approved. + Approved: "approved", + // Indicates the approval is rejected. + Rejected: "rejected", + // Indicates the approval is reassigned. + Reassigned: "reassigned", + // Indicates the approval is canceled. + Canceled: "canceled", + // Indicates the approval is skipped. + Skipped: "skipped", +} + +type ApprovalType string + +type approvalTypeValuesType struct { + Undefined ApprovalType + PreDeploy ApprovalType + PostDeploy ApprovalType + All ApprovalType +} + +var ApprovalTypeValues = approvalTypeValuesType{ + // Indicates the approval type does not set. + Undefined: "undefined", + // Indicates the approvals which executed before deployment. + PreDeploy: "preDeploy", + // Indicates the approvals which executed after deployment. + PostDeploy: "postDeploy", + // Indicates all approvals. + All: "all", +} + +type Artifact struct { + // Gets or sets alias. + Alias *string `json:"alias,omitempty"` + // Gets or sets definition reference. e.g. {"project":{"id":"fed755ea-49c5-4399-acea-fd5b5aa90a6c","name":"myProject"},"definition":{"id":"1","name":"mybuildDefinition"},"connection":{"id":"1","name":"myConnection"}}. + DefinitionReference *map[string]ArtifactSourceReference `json:"definitionReference,omitempty"` + // Indicates whether artifact is primary or not. + IsPrimary *bool `json:"isPrimary,omitempty"` + // Indicates whether artifact is retained by release or not. + IsRetained *bool `json:"isRetained,omitempty"` + // Deprecated: This property is deprecated use Alias instead and remove all its references + SourceId *string `json:"sourceId,omitempty"` + // Gets or sets type. It can have value as 'Build', 'Jenkins', 'GitHub', 'Nuget', 'Team Build (external)', 'ExternalTFSBuild', 'Git', 'TFVC', 'ExternalTfsXamlBuild'. + Type *string `json:"type,omitempty"` +} + +type ArtifactContributionDefinition struct { + ArtifactTriggerConfiguration *ArtifactTriggerConfiguration `json:"artifactTriggerConfiguration,omitempty"` + ArtifactType *string `json:"artifactType,omitempty"` + ArtifactTypeStreamMapping *map[string]string `json:"artifactTypeStreamMapping,omitempty"` + BrowsableArtifactTypeMapping *map[string]string `json:"browsableArtifactTypeMapping,omitempty"` + DataSourceBindings *[]DataSourceBinding `json:"dataSourceBindings,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + DownloadTaskId *string `json:"downloadTaskId,omitempty"` + EndpointTypeId *string `json:"endpointTypeId,omitempty"` + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + IsCommitsTraceabilitySupported *bool `json:"isCommitsTraceabilitySupported,omitempty"` + IsWorkitemsTraceabilitySupported *bool `json:"isWorkitemsTraceabilitySupported,omitempty"` + Name *string `json:"name,omitempty"` + TaskInputMapping *map[string]string `json:"taskInputMapping,omitempty"` + UniqueSourceIdentifier *string `json:"uniqueSourceIdentifier,omitempty"` +} + +type ArtifactDownloadInputBase struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type ArtifactFilter struct { + // Gets or sets whether a release should be created on build tagging. + CreateReleaseOnBuildTagging *bool `json:"createReleaseOnBuildTagging,omitempty"` + // Gets or sets the branch for the filter. + SourceBranch *string `json:"sourceBranch,omitempty"` + // Gets or sets the list of tags for the filter. + Tags *[]string `json:"tags,omitempty"` + // Gets or sets whether filter should default to build definition branch. + UseBuildDefinitionBranch *bool `json:"useBuildDefinitionBranch,omitempty"` +} + +type ArtifactInstanceData struct { + AccountName *string `json:"accountName,omitempty"` + AuthenticationToken *string `json:"authenticationToken,omitempty"` + TfsUrl *string `json:"tfsUrl,omitempty"` + Version *string `json:"version,omitempty"` +} + +type ArtifactMetadata struct { + // Sets alias of artifact. + Alias *string `json:"alias,omitempty"` + // Sets instance reference of artifact. e.g. for build artifact it is build number. + InstanceReference *BuildVersion `json:"instanceReference,omitempty"` +} + +type ArtifactProvider struct { + // Gets or sets the id of artifact provider. + Id *int `json:"id,omitempty"` + // Gets or sets the name of artifact provider. + Name *string `json:"name,omitempty"` + // Gets or sets the link of artifact provider. + SourceUri *string `json:"sourceUri,omitempty"` + // Gets or sets the version of artifact provider. + Version *string `json:"version,omitempty"` +} + +type ArtifactsDownloadInput struct { + DownloadInputs *[]ArtifactDownloadInputBase `json:"downloadInputs,omitempty"` +} + +type ArtifactSourceId struct { + // Gets or sets the artifact type of artifact source. + ArtifactTypeId *string `json:"artifactTypeId,omitempty"` + // Gets or sets the list of sourceIdInput of artifact source. + SourceIdInputs *[]SourceIdInput `json:"sourceIdInputs,omitempty"` +} + +type ArtifactSourceIdsQueryResult struct { + // Gets or sets the list of artifactsourceIds. + ArtifactSourceIds *[]ArtifactSourceId `json:"artifactSourceIds,omitempty"` +} + +type ArtifactSourceReference struct { + // ID of the artifact source. + Id *string `json:"id,omitempty"` + // Name of the artifact source. + Name *string `json:"name,omitempty"` +} + +type ArtifactSourceTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Artifact source alias for Artifact Source trigger type + ArtifactAlias *string `json:"artifactAlias,omitempty"` + TriggerConditions *[]ArtifactFilter `json:"triggerConditions,omitempty"` +} + +type ArtifactTriggerConfiguration struct { + // Gets or sets the whether trigger is supported or not. + IsTriggerSupported *bool `json:"isTriggerSupported,omitempty"` + // Gets or sets the whether trigger is supported only on hosted environment. + IsTriggerSupportedOnlyInHosted *bool `json:"isTriggerSupportedOnlyInHosted,omitempty"` + // Gets or sets the whether webhook is supported at server level. + IsWebhookSupportedAtServerLevel *bool `json:"isWebhookSupportedAtServerLevel,omitempty"` + // Gets or sets the payload hash header name for the artifact trigger configuration. + PayloadHashHeaderName *string `json:"payloadHashHeaderName,omitempty"` + // Gets or sets the resources for artifact trigger configuration. + Resources *map[string]string `json:"resources,omitempty"` + // Gets or sets the webhook payload mapping for artifact trigger configuration. + WebhookPayloadMapping *map[string]string `json:"webhookPayloadMapping,omitempty"` +} + +type ArtifactTypeDefinition struct { + // Gets or sets the artifact trigger configuration of artifact type definition. + ArtifactTriggerConfiguration *ArtifactTriggerConfiguration `json:"artifactTriggerConfiguration,omitempty"` + // Gets or sets the artifact type of artifact type definition. Valid values are 'Build', 'Package', 'Source' or 'ContainerImage'. + ArtifactType *string `json:"artifactType,omitempty"` + // Gets or sets the display name of artifact type definition. + DisplayName *string `json:"displayName,omitempty"` + // Gets or sets the endpoint type id of artifact type definition. + EndpointTypeId *string `json:"endpointTypeId,omitempty"` + // Gets or sets the input descriptors of artifact type definition. + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + // Gets or sets the name of artifact type definition. + Name *string `json:"name,omitempty"` + // Gets or sets the unique source identifier of artifact type definition. + UniqueSourceIdentifier *string `json:"uniqueSourceIdentifier,omitempty"` +} + +type ArtifactVersion struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the default version of artifact. + DefaultVersion *BuildVersion `json:"defaultVersion,omitempty"` + // Gets or sets the error message encountered during querying of versions for artifact. + ErrorMessage *string `json:"errorMessage,omitempty"` + // Deprecated: This property is deprecated use Alias instead and remove all its references + SourceId *string `json:"sourceId,omitempty"` + // Gets or sets the list of build versions of artifact. + Versions *[]BuildVersion `json:"versions,omitempty"` +} + +type ArtifactVersionQueryResult struct { + // Gets or sets the list for artifact versions of artifact version query result. + ArtifactVersions *[]ArtifactVersion `json:"artifactVersions,omitempty"` +} + +type AuditAction string + +type auditActionValuesType struct { + Add AuditAction + Update AuditAction + Delete AuditAction + Undelete AuditAction +} + +var AuditActionValues = auditActionValuesType{ + // Indicates the audit add. + Add: "add", + // Indicates the audit update. + Update: "update", + // Indicates the audit delete. + Delete: "delete", + // Indicates the audit undelete. + Undelete: "undelete", +} + +type AuthorizationHeaderFor string + +type authorizationHeaderForValuesType struct { + RevalidateApproverIdentity AuthorizationHeaderFor + OnBehalfOf AuthorizationHeaderFor +} + +var AuthorizationHeaderForValues = authorizationHeaderForValuesType{ + RevalidateApproverIdentity: "revalidateApproverIdentity", + OnBehalfOf: "onBehalfOf", +} + +type AutoTriggerIssue struct { + Issue *Issue `json:"issue,omitempty"` + IssueSource *IssueSource `json:"issueSource,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + ReleaseDefinitionReference *ReleaseDefinitionShallowReference `json:"releaseDefinitionReference,omitempty"` + ReleaseTriggerType *ReleaseTriggerType `json:"releaseTriggerType,omitempty"` +} + +type AzureKeyVaultVariableGroupProviderData struct { + // Gets or sets last refreshed time. + LastRefreshedOn *azuredevops.Time `json:"lastRefreshedOn,omitempty"` + // Gets or sets the service endpoint ID. + ServiceEndpointId *uuid.UUID `json:"serviceEndpointId,omitempty"` + // Gets or sets the vault name. + Vault *string `json:"vault,omitempty"` +} + +type AzureKeyVaultVariableValue struct { + // Gets or sets as the variable is secret or not. + IsSecret *bool `json:"isSecret,omitempty"` + // Gets or sets the value. + Value *string `json:"value,omitempty"` + // Gets or sets the content type of key vault variable value. + ContentType *string `json:"contentType,omitempty"` + // Indicates the vault variable value enabled or not. + Enabled *bool `json:"enabled,omitempty"` + // Gets or sets the expire time of key vault variable value. + Expires *azuredevops.Time `json:"expires,omitempty"` +} + +type BaseDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` +} + +type BuildArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type BuildVersion struct { + // Gets or sets the commit message for the artifact. + CommitMessage *string `json:"commitMessage,omitempty"` + // Gets or sets the definition id. + DefinitionId *string `json:"definitionId,omitempty"` + // Gets or sets the definition name. + DefinitionName *string `json:"definitionName,omitempty"` + // Gets or sets the build id. + Id *string `json:"id,omitempty"` + // Gets or sets if the artifact supports multiple definitions. + IsMultiDefinitionType *bool `json:"isMultiDefinitionType,omitempty"` + // Gets or sets the build number. + Name *string `json:"name,omitempty"` + // Gets or sets the source branch for the artifact. + SourceBranch *string `json:"sourceBranch,omitempty"` + // Gets or sets the source pull request version for the artifact. + SourcePullRequestVersion *SourcePullRequestVersion `json:"sourcePullRequestVersion,omitempty"` + // Gets or sets the repository id for the artifact. + SourceRepositoryId *string `json:"sourceRepositoryId,omitempty"` + // Gets or sets the repository type for the artifact. + SourceRepositoryType *string `json:"sourceRepositoryType,omitempty"` + // Gets or sets the source version for the artifact. + SourceVersion *string `json:"sourceVersion,omitempty"` +} + +// Represents a change associated with a build. +type Change struct { + // The author of the change. + Author *webapi.IdentityRef `json:"author,omitempty"` + // The type of source. "TfsVersionControl", "TfsGit", etc. + ChangeType *string `json:"changeType,omitempty"` + // The location of a user-friendly representation of the resource. + DisplayUri *string `json:"displayUri,omitempty"` + // Something that identifies the change. For a commit, this would be the SHA1. For a TFVC changeset, this would be the changeset id. + Id *string `json:"id,omitempty"` + // The location of the full representation of the resource. + Location *string `json:"location,omitempty"` + // A description of the change. This might be a commit message or changeset description. + Message *string `json:"message,omitempty"` + // The person or process that pushed the change. + PushedBy *webapi.IdentityRef `json:"pushedBy,omitempty"` + // Deprecated: Use PushedBy instead + Pusher *string `json:"pusher,omitempty"` + // A timestamp for the change. + Timestamp *azuredevops.Time `json:"timestamp,omitempty"` +} + +type CodeRepositoryReference struct { + // Gets and sets the repository references. + RepositoryReference *map[string]ReleaseManagementInputValue `json:"repositoryReference,omitempty"` + // It can have value as ‘GitHub’, ‘Vsts’. + SystemType *PullRequestSystemType `json:"systemType,omitempty"` +} + +type ComplianceSettings struct { + // Scan the release definition for secrets + CheckForCredentialsAndOtherSecrets *bool `json:"checkForCredentialsAndOtherSecrets,omitempty"` +} + +type Condition struct { + // Gets or sets the condition type. + ConditionType *ConditionType `json:"conditionType,omitempty"` + // Gets or sets the name of the condition. e.g. 'ReleaseStarted'. + Name *string `json:"name,omitempty"` + // Gets or set value of the condition. + Value *string `json:"value,omitempty"` +} + +type ConditionType string + +type conditionTypeValuesType struct { + Undefined ConditionType + Event ConditionType + EnvironmentState ConditionType + Artifact ConditionType +} + +var ConditionTypeValues = conditionTypeValuesType{ + // The condition type is undefined. + Undefined: "undefined", + // The condition type is event. + Event: "event", + // The condition type is environment state. + EnvironmentState: "environmentState", + // The condition type is artifact. + Artifact: "artifact", +} + +type ConfigurationVariableValue struct { + // Gets and sets if a variable can be overridden at deployment time or not. + AllowOverride *bool `json:"allowOverride,omitempty"` + // Gets or sets as variable is secret or not. + IsSecret *bool `json:"isSecret,omitempty"` + // Gets and sets value of the configuration variable. + Value *string `json:"value,omitempty"` +} + +type Consumer struct { + // ID of the consumer. + ConsumerId *int `json:"consumerId,omitempty"` + // Name of the consumer. + ConsumerName *string `json:"consumerName,omitempty"` +} + +type ContainerImageTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Alias of the trigger. + Alias *string `json:"alias,omitempty"` + // List tag filters applied while trigger. + TagFilters *[]TagFilter `json:"tagFilters,omitempty"` +} + +type ContinuousDeploymentTriggerIssue struct { + Issue *Issue `json:"issue,omitempty"` + IssueSource *IssueSource `json:"issueSource,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + ReleaseDefinitionReference *ReleaseDefinitionShallowReference `json:"releaseDefinitionReference,omitempty"` + ReleaseTriggerType *ReleaseTriggerType `json:"releaseTriggerType,omitempty"` + // Artifact type. + ArtifactType *string `json:"artifactType,omitempty"` + // ArtifactVersion ID. + ArtifactVersionId *string `json:"artifactVersionId,omitempty"` + // Artifact source ID. + SourceId *string `json:"sourceId,omitempty"` +} + +type ControlOptions struct { + // Always run the job. + AlwaysRun *bool `json:"alwaysRun,omitempty"` + // Indicates whether to continue job on error or not. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // Indicates the job enabled or not. + Enabled *bool `json:"enabled,omitempty"` +} + +type CustomArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type DataSourceBinding struct { + // Pagination format supported by this data source(ContinuationToken/SkipTop). + CallbackContextTemplate *string `json:"callbackContextTemplate,omitempty"` + // Subsequent calls needed? + CallBackRequiredTemplate *string `json:"callBackRequiredTemplate,omitempty"` + // Name of the datasource. + DataSourceName *string `json:"dataSourceName,omitempty"` + // Endpoint ID of the datasource. + EndpointId *string `json:"endpointId,omitempty"` + // Endpoint URL of the datasource. + EndpointUrl *string `json:"endpointUrl,omitempty"` + // Defines the initial value of the query params + InitialContextTemplate *string `json:"initialContextTemplate,omitempty"` + // Parameters of the datasource. + Parameters *map[string]string `json:"parameters,omitempty"` + // Gets or sets http request body + RequestContent *string `json:"requestContent,omitempty"` + // Gets or sets http request verb + RequestVerb *string `json:"requestVerb,omitempty"` + // Result selector applied on output of datasource result, for example jsonpath:$.value[?(@.properties.isEnabled == true)]. + ResultSelector *string `json:"resultSelector,omitempty"` + // Format of the return results, for example. { "Value" : "{{{id}}}", "DisplayValue" : "{{{name}}}" }. + ResultTemplate *string `json:"resultTemplate,omitempty"` + // Target of the datasource. + Target *string `json:"target,omitempty"` +} + +type DefinitionEnvironmentReference struct { + // Definition environment ID. + DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` + // Definition environment name. + DefinitionEnvironmentName *string `json:"definitionEnvironmentName,omitempty"` + // ReleaseDefinition ID. + ReleaseDefinitionId *int `json:"releaseDefinitionId,omitempty"` + // ReleaseDefinition name. + ReleaseDefinitionName *string `json:"releaseDefinitionName,omitempty"` +} + +type Demand struct { + // Gets and sets the name of demand. + Name *string `json:"name,omitempty"` + // Gets and sets the value of demand. + Value *string `json:"value,omitempty"` +} + +type Deployment struct { + // Deprecated: Use ReleaseReference instead. + Links interface{} `json:"_links,omitempty"` + // Gets attempt number. + Attempt *int `json:"attempt,omitempty"` + // Gets the date on which deployment is complete. + CompletedOn *azuredevops.Time `json:"completedOn,omitempty"` + // Gets the list of condition associated with deployment. + Conditions *[]Condition `json:"conditions,omitempty"` + // Gets release definition environment id. + DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` + // Gets status of the deployment. + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + // Gets the unique identifier for deployment. + Id *int `json:"id,omitempty"` + // Gets the identity who last modified the deployment. + LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` + // Gets the date on which deployment is last modified. + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + // Gets operation status of deployment. + OperationStatus *DeploymentOperationStatus `json:"operationStatus,omitempty"` + // Gets list of PostDeployApprovals. + PostDeployApprovals *[]ReleaseApproval `json:"postDeployApprovals,omitempty"` + // Gets list of PreDeployApprovals. + PreDeployApprovals *[]ReleaseApproval `json:"preDeployApprovals,omitempty"` + // Gets or sets project reference. + ProjectReference *ProjectReference `json:"projectReference,omitempty"` + // Gets the date on which deployment is queued. + QueuedOn *azuredevops.Time `json:"queuedOn,omitempty"` + // Gets reason of deployment. + Reason *DeploymentReason `json:"reason,omitempty"` + // Gets the reference of release. + Release *ReleaseReference `json:"release,omitempty"` + // Gets releaseDefinitionReference which specifies the reference of the release definition to which the deployment is associated. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Gets releaseEnvironmentReference which specifies the reference of the release environment to which the deployment is associated. + ReleaseEnvironment *ReleaseEnvironmentShallowReference `json:"releaseEnvironment,omitempty"` + // Gets the identity who requested. + RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` + // Gets the identity for whom deployment is requested. + RequestedFor *webapi.IdentityRef `json:"requestedFor,omitempty"` + // Gets the date on which deployment is scheduled. + ScheduledDeploymentTime *azuredevops.Time `json:"scheduledDeploymentTime,omitempty"` + // Gets the date on which deployment is started. + StartedOn *azuredevops.Time `json:"startedOn,omitempty"` +} + +type DeploymentApprovalCompletedEvent struct { + Approval *ReleaseApproval `json:"approval,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +type DeploymentApprovalPendingEvent struct { + Approval *ReleaseApproval `json:"approval,omitempty"` + ApprovalOptions *ApprovalOptions `json:"approvalOptions,omitempty"` + CompletedApprovals *[]ReleaseApproval `json:"completedApprovals,omitempty"` + Data *map[string]interface{} `json:"data,omitempty"` + Deployment *Deployment `json:"deployment,omitempty"` + IsMultipleRankApproval *bool `json:"isMultipleRankApproval,omitempty"` + PendingApprovals *[]ReleaseApproval `json:"pendingApprovals,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +type DeploymentAttempt struct { + // Deployment attempt. + Attempt *int `json:"attempt,omitempty"` + // ID of the deployment. + DeploymentId *int `json:"deploymentId,omitempty"` + // Deprecated: Instead use Issues which contains both errors and warnings related to deployment + ErrorLog *string `json:"errorLog,omitempty"` + // Specifies whether deployment has started or not. + HasStarted *bool `json:"hasStarted,omitempty"` + // ID of deployment. + Id *int `json:"id,omitempty"` + // All the issues related to the deployment. + Issues *[]Issue `json:"issues,omitempty"` + // Deprecated: Use ReleaseDeployPhase.DeploymentJobs.Job instead. + Job *ReleaseTask `json:"job,omitempty"` + // Identity who last modified this deployment. + LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` + // Time when this deployment last modified. + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + // Deployment operation status. + OperationStatus *DeploymentOperationStatus `json:"operationStatus,omitempty"` + // Post deployment gates that executed in this deployment. + PostDeploymentGates *ReleaseGates `json:"postDeploymentGates,omitempty"` + // Pre deployment gates that executed in this deployment. + PreDeploymentGates *ReleaseGates `json:"preDeploymentGates,omitempty"` + // When this deployment queued on. + QueuedOn *azuredevops.Time `json:"queuedOn,omitempty"` + // Reason for the deployment. + Reason *DeploymentReason `json:"reason,omitempty"` + // List of release deployphases executed in this deployment. + ReleaseDeployPhases *[]ReleaseDeployPhase `json:"releaseDeployPhases,omitempty"` + // Identity who requested this deployment. + RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` + // Identity for this deployment requested. + RequestedFor *webapi.IdentityRef `json:"requestedFor,omitempty"` + // Deprecated: Use ReleaseDeployPhase.RunPlanId instead. + RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` + // status of the deployment. + Status *DeploymentStatus `json:"status,omitempty"` + // Deprecated: Use ReleaseDeployPhase.DeploymentJobs.Tasks instead. + Tasks *[]ReleaseTask `json:"tasks,omitempty"` +} + +type DeploymentAuthorizationInfo struct { + // Authorization header type, typically either RevalidateApproverIdentity or OnBehalfOf. + AuthorizationHeaderFor *AuthorizationHeaderFor `json:"authorizationHeaderFor,omitempty"` + // List of resources. + Resources *[]string `json:"resources,omitempty"` + // ID of the tenant. + TenantId *string `json:"tenantId,omitempty"` + // Access token key. + VstsAccessTokenKey *string `json:"vstsAccessTokenKey,omitempty"` +} + +type DeploymentAuthorizationOwner string + +type deploymentAuthorizationOwnerValuesType struct { + Automatic DeploymentAuthorizationOwner + DeploymentSubmitter DeploymentAuthorizationOwner + FirstPreDeploymentApprover DeploymentAuthorizationOwner +} + +var DeploymentAuthorizationOwnerValues = deploymentAuthorizationOwnerValuesType{ + Automatic: "automatic", + DeploymentSubmitter: "deploymentSubmitter", + FirstPreDeploymentApprover: "firstPreDeploymentApprover", +} + +type DeploymentCompletedEvent struct { + Comment *string `json:"comment,omitempty"` + Data *map[string]interface{} `json:"data,omitempty"` + Deployment *Deployment `json:"deployment,omitempty"` + Environment *ReleaseEnvironment `json:"environment,omitempty"` + Project *ProjectReference `json:"project,omitempty"` +} + +// [Flags] +type DeploymentExpands string + +type deploymentExpandsValuesType struct { + All DeploymentExpands + DeploymentOnly DeploymentExpands + Approvals DeploymentExpands + Artifacts DeploymentExpands +} + +var DeploymentExpandsValues = deploymentExpandsValuesType{ + All: "all", + DeploymentOnly: "deploymentOnly", + Approvals: "approvals", + Artifacts: "artifacts", +} + +type DeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Artifacts that downloaded during job execution. + ArtifactsDownloadInput *ArtifactsDownloadInput `json:"artifactsDownloadInput,omitempty"` + // List demands that needs to meet to execute the job. + Demands *[]interface{} `json:"demands,omitempty"` + // Indicates whether to include access token in deployment job or not. + EnableAccessToken *bool `json:"enableAccessToken,omitempty"` + // Id of the pool on which job get executed. + QueueId *int `json:"queueId,omitempty"` + // Indicates whether artifacts downloaded while job execution or not. + SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` +} + +type DeploymentJob struct { + // Parent task of all executed tasks. + Job *ReleaseTask `json:"job,omitempty"` + // List of executed tasks with in job. + Tasks *[]ReleaseTask `json:"tasks,omitempty"` +} + +type DeploymentManualInterventionPendingEvent struct { + Deployment *Deployment `json:"deployment,omitempty"` + EmailRecipients *[]uuid.UUID `json:"emailRecipients,omitempty"` + EnvironmentOwner *webapi.IdentityRef `json:"environmentOwner,omitempty"` + ManualIntervention *ManualIntervention `json:"manualIntervention,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +// [Flags] +type DeploymentOperationStatus string + +type deploymentOperationStatusValuesType struct { + Undefined DeploymentOperationStatus + Queued DeploymentOperationStatus + Scheduled DeploymentOperationStatus + Pending DeploymentOperationStatus + Approved DeploymentOperationStatus + Rejected DeploymentOperationStatus + Deferred DeploymentOperationStatus + QueuedForAgent DeploymentOperationStatus + PhaseInProgress DeploymentOperationStatus + PhaseSucceeded DeploymentOperationStatus + PhasePartiallySucceeded DeploymentOperationStatus + PhaseFailed DeploymentOperationStatus + Canceled DeploymentOperationStatus + PhaseCanceled DeploymentOperationStatus + ManualInterventionPending DeploymentOperationStatus + QueuedForPipeline DeploymentOperationStatus + Cancelling DeploymentOperationStatus + EvaluatingGates DeploymentOperationStatus + GateFailed DeploymentOperationStatus + All DeploymentOperationStatus +} + +var DeploymentOperationStatusValues = deploymentOperationStatusValuesType{ + // The deployment operation status is undefined. + Undefined: "undefined", + // The deployment operation status is queued. + Queued: "queued", + // The deployment operation status is scheduled. + Scheduled: "scheduled", + // The deployment operation status is pending. + Pending: "pending", + // The deployment operation status is approved. + Approved: "approved", + // The deployment operation status is rejected. + Rejected: "rejected", + // The deployment operation status is deferred. + Deferred: "deferred", + // The deployment operation status is queued for agent. + QueuedForAgent: "queuedForAgent", + // The deployment operation status is phase in progress. + PhaseInProgress: "phaseInProgress", + // The deployment operation status is phase succeeded. + PhaseSucceeded: "phaseSucceeded", + // The deployment operation status is phase partially succeeded. + PhasePartiallySucceeded: "phasePartiallySucceeded", + // The deployment operation status is phase failed. + PhaseFailed: "phaseFailed", + // The deployment operation status is canceled. + Canceled: "canceled", + // The deployment operation status is phase canceled. + PhaseCanceled: "phaseCanceled", + // The deployment operation status is manualintervention pending. + ManualInterventionPending: "manualInterventionPending", + // The deployment operation status is queued for pipeline. + QueuedForPipeline: "queuedForPipeline", + // The deployment operation status is cancelling. + Cancelling: "cancelling", + // The deployment operation status is EvaluatingGates. + EvaluatingGates: "evaluatingGates", + // The deployment operation status is GateFailed. + GateFailed: "gateFailed", + // The deployment operation status is all. + All: "all", +} + +type DeploymentQueryParameters struct { + // Query deployments based specified artifact source id. + ArtifactSourceId *string `json:"artifactSourceId,omitempty"` + // Query deployments based specified artifact type id. + ArtifactTypeId *string `json:"artifactTypeId,omitempty"` + // Query deployments based specified artifact versions. + ArtifactVersions *[]string `json:"artifactVersions,omitempty"` + // Query deployments number of deployments per environment. + DeploymentsPerEnvironment *int `json:"deploymentsPerEnvironment,omitempty"` + // Query deployment based on deployment status. + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + // Query deployments of specified environments. + Environments *[]DefinitionEnvironmentReference `json:"environments,omitempty"` + // Query deployments based specified expands. + Expands *DeploymentExpands `json:"expands,omitempty"` + // Specify deleted deployments should return or not. + IsDeleted *bool `json:"isDeleted,omitempty"` + // Deprecated: + LatestDeploymentsOnly *bool `json:"latestDeploymentsOnly,omitempty"` + // Deprecated: + MaxDeploymentsPerEnvironment *int `json:"maxDeploymentsPerEnvironment,omitempty"` + // Deprecated: + MaxModifiedTime *azuredevops.Time `json:"maxModifiedTime,omitempty"` + // Deprecated: + MinModifiedTime *azuredevops.Time `json:"minModifiedTime,omitempty"` + // Query deployment based on deployment operation status. + OperationStatus *DeploymentOperationStatus `json:"operationStatus,omitempty"` + // Deprecated: + QueryOrder *ReleaseQueryOrder `json:"queryOrder,omitempty"` + // Query deployments based query type. + QueryType *DeploymentsQueryType `json:"queryType,omitempty"` + // Query deployments based specified source branch. + SourceBranch *string `json:"sourceBranch,omitempty"` +} + +// [Flags] +type DeploymentReason string + +type deploymentReasonValuesType struct { + None DeploymentReason + Manual DeploymentReason + Automated DeploymentReason + Scheduled DeploymentReason + RedeployTrigger DeploymentReason +} + +var DeploymentReasonValues = deploymentReasonValuesType{ + // The deployment reason is none. + None: "none", + // The deployment reason is manual. + Manual: "manual", + // The deployment reason is automated. + Automated: "automated", + // The deployment reason is scheduled. + Scheduled: "scheduled", + // The deployment reason is RedeployTrigger. + RedeployTrigger: "redeployTrigger", +} + +type DeploymentsQueryType string + +type deploymentsQueryTypeValuesType struct { + Regular DeploymentsQueryType + FailingSince DeploymentsQueryType +} + +var DeploymentsQueryTypeValues = deploymentsQueryTypeValuesType{ + Regular: "regular", + FailingSince: "failingSince", +} + +type DeploymentStartedEvent struct { + Environment *ReleaseEnvironment `json:"environment,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +// [Flags] +type DeploymentStatus string + +type deploymentStatusValuesType struct { + Undefined DeploymentStatus + NotDeployed DeploymentStatus + InProgress DeploymentStatus + Succeeded DeploymentStatus + PartiallySucceeded DeploymentStatus + Failed DeploymentStatus + All DeploymentStatus +} + +var DeploymentStatusValues = deploymentStatusValuesType{ + // The deployment status is undefined. + Undefined: "undefined", + // The deployment status is not deployed. + NotDeployed: "notDeployed", + // The deployment status is in progress. + InProgress: "inProgress", + // The deployment status is succeeded. + Succeeded: "succeeded", + // The deployment status is partiallysucceeded. + PartiallySucceeded: "partiallySucceeded", + // The deployment status is failed. + Failed: "failed", + // The deployment status is all. + All: "all", +} + +type DeployPhase struct { + // Gets and sets the name of deploy phase. + Name *string `json:"name,omitempty"` + // Indicates the deploy phase type. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Gets and sets the rank of deploy phase. + Rank *int `json:"rank,omitempty"` + // Gets and sets the reference name of deploy phase. + RefName *string `json:"refName,omitempty"` + // Gets and sets the workflow tasks for the deploy phase. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` +} + +// [Flags] +type DeployPhaseStatus string + +type deployPhaseStatusValuesType struct { + Undefined DeployPhaseStatus + NotStarted DeployPhaseStatus + InProgress DeployPhaseStatus + PartiallySucceeded DeployPhaseStatus + Succeeded DeployPhaseStatus + Failed DeployPhaseStatus + Canceled DeployPhaseStatus + Skipped DeployPhaseStatus + Cancelling DeployPhaseStatus +} + +var DeployPhaseStatusValues = deployPhaseStatusValuesType{ + // Phase status not set. + Undefined: "undefined", + // Phase execution not started. + NotStarted: "notStarted", + // Phase execution in progress. + InProgress: "inProgress", + // Phase execution partially succeeded. + PartiallySucceeded: "partiallySucceeded", + // Phase execution succeeded. + Succeeded: "succeeded", + // Phase execution failed. + Failed: "failed", + // Phase execution canceled. + Canceled: "canceled", + // Phase execution skipped. + Skipped: "skipped", + // Phase is in cancelling state. + Cancelling: "cancelling", +} + +// [Flags] +type DeployPhaseTypes string + +type deployPhaseTypesValuesType struct { + Undefined DeployPhaseTypes + AgentBasedDeployment DeployPhaseTypes + RunOnServer DeployPhaseTypes + MachineGroupBasedDeployment DeployPhaseTypes + DeploymentGates DeployPhaseTypes +} + +var DeployPhaseTypesValues = deployPhaseTypesValuesType{ + // Phase type not defined. Don't use this. + Undefined: "undefined", + // Phase type which contains tasks executed on agent. + AgentBasedDeployment: "agentBasedDeployment", + // Phase type which contains tasks executed by server. + RunOnServer: "runOnServer", + // Phase type which contains tasks executed on deployment group machines. + MachineGroupBasedDeployment: "machineGroupBasedDeployment", + // Phase type which contains tasks which acts as Gates for the deployment to go forward. + DeploymentGates: "deploymentGates", +} + +type EmailRecipients struct { + // List of email addresses. + EmailAddresses *[]string `json:"emailAddresses,omitempty"` + // List of TFS IDs guids. + TfsIds *[]uuid.UUID `json:"tfsIds,omitempty"` +} + +// Defines policy on environment queuing at Release Management side queue. We will send to Environment Runner [creating pre-deploy and other steps] only when the policies mentioned are satisfied. +type EnvironmentExecutionPolicy struct { + // This policy decides, how many environments would be with Environment Runner. + ConcurrencyCount *int `json:"concurrencyCount,omitempty"` + // Queue depth in the EnvironmentQueue table, this table keeps the environment entries till Environment Runner is free [as per it's policy] to take another environment for running. + QueueDepthCount *int `json:"queueDepthCount,omitempty"` +} + +type EnvironmentOptions struct { + // Gets and sets as the auto link workitems or not. + AutoLinkWorkItems *bool `json:"autoLinkWorkItems,omitempty"` + // Gets and sets as the badge enabled or not. + BadgeEnabled *bool `json:"badgeEnabled,omitempty"` + // Deprecated: Use Notifications instead. + EmailNotificationType *string `json:"emailNotificationType,omitempty"` + // Deprecated: Use Notifications instead. + EmailRecipients *string `json:"emailRecipients,omitempty"` + // Deprecated: Use DeploymentInput.EnableAccessToken instead. + EnableAccessToken *bool `json:"enableAccessToken,omitempty"` + // Gets and sets as the publish deployment status or not. + PublishDeploymentStatus *bool `json:"publishDeploymentStatus,omitempty"` + // Gets and sets as the.pull request deployment enabled or not. + PullRequestDeploymentEnabled *bool `json:"pullRequestDeploymentEnabled,omitempty"` + // Deprecated: Use DeploymentInput.SkipArtifactsDownload instead. + SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` + // Deprecated: Use DeploymentInput.TimeoutInMinutes instead. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` +} + +type EnvironmentRetentionPolicy struct { + // Gets and sets the number of days to keep environment. + DaysToKeep *int `json:"daysToKeep,omitempty"` + // Gets and sets the number of releases to keep. + ReleasesToKeep *int `json:"releasesToKeep,omitempty"` + // Gets and sets as the build to be retained or not. + RetainBuild *bool `json:"retainBuild,omitempty"` +} + +// [Flags] +type EnvironmentStatus string + +type environmentStatusValuesType struct { + Undefined EnvironmentStatus + NotStarted EnvironmentStatus + InProgress EnvironmentStatus + Succeeded EnvironmentStatus + Canceled EnvironmentStatus + Rejected EnvironmentStatus + Queued EnvironmentStatus + Scheduled EnvironmentStatus + PartiallySucceeded EnvironmentStatus +} + +var EnvironmentStatusValues = environmentStatusValuesType{ + // Environment status not set. + Undefined: "undefined", + // Environment is in not started state. + NotStarted: "notStarted", + // Environment is in progress state. + InProgress: "inProgress", + // Environment is in succeeded state. + Succeeded: "succeeded", + // Environment is in canceled state. + Canceled: "canceled", + // Environment is in rejected state. + Rejected: "rejected", + // Environment is in queued state. + Queued: "queued", + // Environment is in scheduled state. + Scheduled: "scheduled", + // Environment is in partially succeeded state. + PartiallySucceeded: "partiallySucceeded", +} + +type EnvironmentTrigger struct { + // Definition environment ID on which this trigger applicable. + DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` + // ReleaseDefinition ID on which this trigger applicable. + ReleaseDefinitionId *int `json:"releaseDefinitionId,omitempty"` + // Gets or sets the trigger content. + TriggerContent *string `json:"triggerContent,omitempty"` + // Gets or sets the trigger type. + TriggerType *EnvironmentTriggerType `json:"triggerType,omitempty"` +} + +type EnvironmentTriggerContent struct { + // Gets or sets action. + Action *string `json:"action,omitempty"` + // Gets or sets list of event types. + EventTypes *[]string `json:"eventTypes,omitempty"` +} + +type EnvironmentTriggerType string + +type environmentTriggerTypeValuesType struct { + Undefined EnvironmentTriggerType + DeploymentGroupRedeploy EnvironmentTriggerType + RollbackRedeploy EnvironmentTriggerType +} + +var EnvironmentTriggerTypeValues = environmentTriggerTypeValuesType{ + // Environment trigger type undefined. + Undefined: "undefined", + // Environment trigger type is deployment group redeploy. + DeploymentGroupRedeploy: "deploymentGroupRedeploy", + // Environment trigger type is Rollback. + RollbackRedeploy: "rollbackRedeploy", +} + +type ExecutionInput struct { + // Parallel execution type, for example MultiConfiguration or MultiMachine. + ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` +} + +// Class to represent favorite entry. +type FavoriteItem struct { + // Application specific data for the entry. + Data *string `json:"data,omitempty"` + // Unique Id of the the entry. + Id *uuid.UUID `json:"id,omitempty"` + // Display text for favorite entry. + Name *string `json:"name,omitempty"` + // Application specific favorite entry type. Empty or Null represents that Favorite item is a Folder. + Type *string `json:"type,omitempty"` +} + +type Folder struct { + // Identity who created this folder. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Time when this folder created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Description of the folder. + Description *string `json:"description,omitempty"` + // Identity who last changed this folder. + LastChangedBy *webapi.IdentityRef `json:"lastChangedBy,omitempty"` + // Time when this folder last changed. + LastChangedDate *azuredevops.Time `json:"lastChangedDate,omitempty"` + // path of the folder. + Path *string `json:"path,omitempty"` +} + +type FolderPathQueryOrder string + +type folderPathQueryOrderValuesType struct { + None FolderPathQueryOrder + Ascending FolderPathQueryOrder + Descending FolderPathQueryOrder +} + +var FolderPathQueryOrderValues = folderPathQueryOrderValuesType{ + // No order. + None: "none", + // Order by folder name and path ascending. + Ascending: "ascending", + // Order by folder name and path descending. + Descending: "descending", +} + +type GatesDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Gates minimum success duration. + MinimumSuccessDuration *int `json:"minimumSuccessDuration,omitempty"` + // Gates sampling interval. + SamplingInterval *int `json:"samplingInterval,omitempty"` + // Gates stabilization time. + StabilizationTime *int `json:"stabilizationTime,omitempty"` +} + +type GatesDeployPhase struct { + // Gets and sets the name of deploy phase. + Name *string `json:"name,omitempty"` + // Indicates the deploy phase type. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Gets and sets the rank of deploy phase. + Rank *int `json:"rank,omitempty"` + // Gets and sets the reference name of deploy phase. + RefName *string `json:"refName,omitempty"` + // Gets and sets the workflow tasks for the deploy phase. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` + // Gets and sets the gate job input. + DeploymentInput *GatesDeploymentInput `json:"deploymentInput,omitempty"` +} + +// [Flags] +type GateStatus string + +type gateStatusValuesType struct { + None GateStatus + Pending GateStatus + InProgress GateStatus + Succeeded GateStatus + Failed GateStatus + Canceled GateStatus +} + +var GateStatusValues = gateStatusValuesType{ + // The gate does not have the status set. + None: "none", + // The gate is in pending state. + Pending: "pending", + // The gate is currently in progress. + InProgress: "inProgress", + // The gate completed successfully. + Succeeded: "succeeded", + // The gate execution failed. + Failed: "failed", + // The gate execution cancelled. + Canceled: "canceled", +} + +type GateUpdateMetadata struct { + // Comment. + Comment *string `json:"comment,omitempty"` + // Name of gate to be ignored. + GatesToIgnore *[]string `json:"gatesToIgnore,omitempty"` +} + +type GitArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type GitHubArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type IgnoredGate struct { + // Gets the date on which gate is last ignored. + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + // Name of gate ignored. + Name *string `json:"name,omitempty"` +} + +type Issue struct { + // Issue data. + Data *map[string]string `json:"data,omitempty"` + // Issue type, for example error, warning or info. + IssueType *string `json:"issueType,omitempty"` + // Issue message. + Message *string `json:"message,omitempty"` +} + +type IssueSource string + +type issueSourceValuesType struct { + None IssueSource + User IssueSource + System IssueSource +} + +var IssueSourceValues = issueSourceValuesType{ + None: "none", + User: "user", + System: "system", +} + +type JenkinsArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type MachineGroupBasedDeployPhase struct { + // Gets and sets the name of deploy phase. + Name *string `json:"name,omitempty"` + // Indicates the deploy phase type. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Gets and sets the rank of deploy phase. + Rank *int `json:"rank,omitempty"` + // Gets and sets the reference name of deploy phase. + RefName *string `json:"refName,omitempty"` + // Gets and sets the workflow tasks for the deploy phase. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` + // Gets and sets the deployment group job input + DeploymentInput *MachineGroupDeploymentInput `json:"deploymentInput,omitempty"` +} + +type MachineGroupDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Artifacts that downloaded during job execution. + ArtifactsDownloadInput *ArtifactsDownloadInput `json:"artifactsDownloadInput,omitempty"` + // List demands that needs to meet to execute the job. + Demands *[]interface{} `json:"demands,omitempty"` + // Indicates whether to include access token in deployment job or not. + EnableAccessToken *bool `json:"enableAccessToken,omitempty"` + // Id of the pool on which job get executed. + QueueId *int `json:"queueId,omitempty"` + // Indicates whether artifacts downloaded while job execution or not. + SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` + // Deployment group health option. + DeploymentHealthOption *string `json:"deploymentHealthOption,omitempty"` + // Minimum percentage of the targets guaranteed to be healthy. + HealthPercent *int `json:"healthPercent,omitempty"` + // Deployment target tag filter. + Tags *[]string `json:"tags,omitempty"` +} + +type MailMessage struct { + // Body of mail. + Body *string `json:"body,omitempty"` + // Mail CC recipients. + Cc *EmailRecipients `json:"cc,omitempty"` + // Reply to. + InReplyTo *string `json:"inReplyTo,omitempty"` + // Message ID of the mail. + MessageId *string `json:"messageId,omitempty"` + // Data when should be replied to mail. + ReplyBy *azuredevops.Time `json:"replyBy,omitempty"` + // Reply to Email recipients. + ReplyTo *EmailRecipients `json:"replyTo,omitempty"` + // List of mail section types. + Sections *[]MailSectionType `json:"sections,omitempty"` + // Mail sender type. + SenderType *SenderType `json:"senderType,omitempty"` + // Subject of the mail. + Subject *string `json:"subject,omitempty"` + // Mail To recipients. + To *EmailRecipients `json:"to,omitempty"` +} + +type MailSectionType string + +type mailSectionTypeValuesType struct { + Details MailSectionType + Environments MailSectionType + Issues MailSectionType + TestResults MailSectionType + WorkItems MailSectionType + ReleaseInfo MailSectionType +} + +var MailSectionTypeValues = mailSectionTypeValuesType{ + Details: "details", + Environments: "environments", + Issues: "issues", + TestResults: "testResults", + WorkItems: "workItems", + ReleaseInfo: "releaseInfo", +} + +type ManualIntervention struct { + // Gets or sets the identity who should approve. + Approver *webapi.IdentityRef `json:"approver,omitempty"` + // Gets or sets comments for approval. + Comments *string `json:"comments,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets the unique identifier for manual intervention. + Id *int `json:"id,omitempty"` + // Gets or sets instructions for approval. + Instructions *string `json:"instructions,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets the name. + Name *string `json:"name,omitempty"` + // Gets releaseReference for manual intervention. + Release *ReleaseShallowReference `json:"release,omitempty"` + // Gets releaseDefinitionReference for manual intervention. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Gets releaseEnvironmentReference for manual intervention. + ReleaseEnvironment *ReleaseEnvironmentShallowReference `json:"releaseEnvironment,omitempty"` + // Gets or sets the status of the manual intervention. + Status *ManualInterventionStatus `json:"status,omitempty"` + // Get task instance identifier. + TaskInstanceId *uuid.UUID `json:"taskInstanceId,omitempty"` + // Gets url to access the manual intervention. + Url *string `json:"url,omitempty"` +} + +// [Flags] Describes manual intervention status +type ManualInterventionStatus string + +type manualInterventionStatusValuesType struct { + Unknown ManualInterventionStatus + Pending ManualInterventionStatus + Rejected ManualInterventionStatus + Approved ManualInterventionStatus + Canceled ManualInterventionStatus +} + +var ManualInterventionStatusValues = manualInterventionStatusValuesType{ + // The manual intervention does not have the status set. + Unknown: "unknown", + // The manual intervention is pending. + Pending: "pending", + // The manual intervention is rejected. + Rejected: "rejected", + // The manual intervention is approved. + Approved: "approved", + // The manual intervention is canceled. + Canceled: "canceled", +} + +type ManualInterventionUpdateMetadata struct { + // Sets the comment for manual intervention update. + Comment *string `json:"comment,omitempty"` + // Sets the status of the manual intervention. + Status *ManualInterventionStatus `json:"status,omitempty"` +} + +type MappingDetails struct { + Mappings *map[string]forminput.InputValue `json:"mappings,omitempty"` +} + +type Metric struct { + // Name of the Metric. + Name *string `json:"name,omitempty"` + // Value of the Metric. + Value *int `json:"value,omitempty"` +} + +type MultiConfigInput struct { + // Parallel execution type, for example MultiConfiguration or MultiMachine. + ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` + // Indicate whether continue execution of deployment on error or not. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // Maximum number of agents used while parallel execution. + MaxNumberOfAgents *int `json:"maxNumberOfAgents,omitempty"` + // Multipliers for parallel execution of deployment, for example x86,x64. + Multipliers *string `json:"multipliers,omitempty"` +} + +type MultiMachineInput struct { + // Parallel execution type, for example MultiConfiguration or MultiMachine. + ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` + // Indicate whether continue execution of deployment on error or not. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // Maximum number of agents used while parallel execution. + MaxNumberOfAgents *int `json:"maxNumberOfAgents,omitempty"` +} + +type PackageTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Package trigger alias. + Alias *string `json:"alias,omitempty"` +} + +type ParallelExecutionInputBase struct { + // Parallel execution type, for example MultiConfiguration or MultiMachine. + ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` + // Indicate whether continue execution of deployment on error or not. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // Maximum number of agents used while parallel execution. + MaxNumberOfAgents *int `json:"maxNumberOfAgents,omitempty"` +} + +// [Flags] +type ParallelExecutionTypes string + +type parallelExecutionTypesValuesType struct { + None ParallelExecutionTypes + MultiConfiguration ParallelExecutionTypes + MultiMachine ParallelExecutionTypes +} + +var ParallelExecutionTypesValues = parallelExecutionTypesValuesType{ + None: "none", + MultiConfiguration: "multiConfiguration", + MultiMachine: "multiMachine", +} + +// [Flags] +type PipelineProcessTypes string + +type pipelineProcessTypesValuesType struct { + Designer PipelineProcessTypes + Yaml PipelineProcessTypes +} + +var PipelineProcessTypesValues = pipelineProcessTypesValuesType{ + Designer: "designer", + Yaml: "yaml", +} + +type ProjectReference struct { + // Gets the unique identifier of this field. + Id *uuid.UUID `json:"id,omitempty"` + // Gets name of project. + Name *string `json:"name,omitempty"` +} + +type PropertySelector struct { + // List of properties. + Properties *[]string `json:"properties,omitempty"` + // Property selector type. + SelectorType *PropertySelectorType `json:"selectorType,omitempty"` +} + +type PropertySelectorType string + +type propertySelectorTypeValuesType struct { + Inclusion PropertySelectorType + Exclusion PropertySelectorType +} + +var PropertySelectorTypeValues = propertySelectorTypeValuesType{ + // Include in property selector. + Inclusion: "inclusion", + // Exclude in property selector. + Exclusion: "exclusion", +} + +type PullRequestConfiguration struct { + // Code repository reference. + CodeRepositoryReference *CodeRepositoryReference `json:"codeRepositoryReference,omitempty"` + // In case of Source based artifacts, Code reference will be present in Artifact details. + UseArtifactReference *bool `json:"useArtifactReference,omitempty"` +} + +type PullRequestFilter struct { + // List of tags. + Tags *[]string `json:"tags,omitempty"` + // Target branch of pull request. + TargetBranch *string `json:"targetBranch,omitempty"` +} + +type PullRequestSystemType string + +type pullRequestSystemTypeValuesType struct { + None PullRequestSystemType + TfsGit PullRequestSystemType + GitHub PullRequestSystemType +} + +var PullRequestSystemTypeValues = pullRequestSystemTypeValuesType{ + None: "none", + TfsGit: "tfsGit", + GitHub: "gitHub", +} + +type PullRequestTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Artifact alias trigger is linked to. + ArtifactAlias *string `json:"artifactAlias,omitempty"` + // Code reference details of pull request. + PullRequestConfiguration *PullRequestConfiguration `json:"pullRequestConfiguration,omitempty"` + // Policy name using which status will be published to pull request. + StatusPolicyName *string `json:"statusPolicyName,omitempty"` + // List of filters applied while trigger. + TriggerConditions *[]PullRequestFilter `json:"triggerConditions,omitempty"` +} + +type QueuedReleaseData struct { + // Project ID of the release. + ProjectId *uuid.UUID `json:"projectId,omitempty"` + // Release queue position. + QueuePosition *int `json:"queuePosition,omitempty"` + // Queued release ID. + ReleaseId *int `json:"releaseId,omitempty"` +} + +type RealtimeReleaseDefinitionEvent struct { + DefinitionId *int `json:"definitionId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` +} + +type RealtimeReleaseEvent struct { + EnvironmentId *int `json:"environmentId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` +} + +type Release struct { + // Gets links to access the release. + Links interface{} `json:"_links,omitempty"` + // Gets or sets the list of artifacts. + Artifacts *[]Artifact `json:"artifacts,omitempty"` + // Gets or sets comment. + Comment *string `json:"comment,omitempty"` + // Gets or sets the identity who created. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets revision number of definition snapshot. + DefinitionSnapshotRevision *int `json:"definitionSnapshotRevision,omitempty"` + // Gets or sets description of release. + Description *string `json:"description,omitempty"` + // Gets list of environments. + Environments *[]ReleaseEnvironment `json:"environments,omitempty"` + // Gets the unique identifier of this field. + Id *int `json:"id,omitempty"` + // Whether to exclude the release from retention policies. + KeepForever *bool `json:"keepForever,omitempty"` + // Gets logs container url. + LogsContainerUrl *string `json:"logsContainerUrl,omitempty"` + // Gets or sets the identity who modified. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets name. + Name *string `json:"name,omitempty"` + // Gets pool name. + PoolName *string `json:"poolName,omitempty"` + // Gets or sets project reference. + ProjectReference *ProjectReference `json:"projectReference,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // Gets reason of release. + Reason *ReleaseReason `json:"reason,omitempty"` + // Gets releaseDefinitionReference which specifies the reference of the release definition to which this release is associated. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Gets or sets the release definition revision. + ReleaseDefinitionRevision *int `json:"releaseDefinitionRevision,omitempty"` + // Gets release name format. + ReleaseNameFormat *string `json:"releaseNameFormat,omitempty"` + // Gets status. + Status *ReleaseStatus `json:"status,omitempty"` + // Gets or sets list of tags. + Tags *[]string `json:"tags,omitempty"` + TriggeringArtifactAlias *string `json:"triggeringArtifactAlias,omitempty"` + // Deprecated: Use Links instead. + Url *string `json:"url,omitempty"` + // Gets the list of variable groups. + VariableGroups *[]VariableGroup `json:"variableGroups,omitempty"` + // Gets or sets the dictionary of variables. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +type ReleaseAbandonedEvent struct { + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +type ReleaseApproval struct { + // Gets or sets the type of approval. + ApprovalType *ApprovalType `json:"approvalType,omitempty"` + // Gets the identity who approved. + ApprovedBy *webapi.IdentityRef `json:"approvedBy,omitempty"` + // Gets or sets the identity who should approve. + Approver *webapi.IdentityRef `json:"approver,omitempty"` + // Gets or sets attempt which specifies as which deployment attempt it belongs. + Attempt *int `json:"attempt,omitempty"` + // Gets or sets comments for approval. + Comments *string `json:"comments,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets history which specifies all approvals associated with this approval. + History *[]ReleaseApprovalHistory `json:"history,omitempty"` + // Gets the unique identifier of this field. + Id *int `json:"id,omitempty"` + // Gets or sets as approval is automated or not. + IsAutomated *bool `json:"isAutomated,omitempty"` + // Deprecated: Use Notifications instead. + IsNotificationOn *bool `json:"isNotificationOn,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets rank which specifies the order of the approval. e.g. Same rank denotes parallel approval. + Rank *int `json:"rank,omitempty"` + // Gets releaseReference which specifies the reference of the release to which this approval is associated. + Release *ReleaseShallowReference `json:"release,omitempty"` + // Gets releaseDefinitionReference which specifies the reference of the release definition to which this approval is associated. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Gets releaseEnvironmentReference which specifies the reference of the release environment to which this approval is associated. + ReleaseEnvironment *ReleaseEnvironmentShallowReference `json:"releaseEnvironment,omitempty"` + // Gets the revision number. + Revision *int `json:"revision,omitempty"` + // Gets or sets the status of the approval. + Status *ApprovalStatus `json:"status,omitempty"` + // Deprecated: Use Attempt instead. + TrialNumber *int `json:"trialNumber,omitempty"` + // Gets url to access the approval. + Url *string `json:"url,omitempty"` +} + +type ReleaseApprovalHistory struct { + // Identity of the approver. + Approver *webapi.IdentityRef `json:"approver,omitempty"` + // Identity of the object who changed approval. + ChangedBy *webapi.IdentityRef `json:"changedBy,omitempty"` + // Approval history comments. + Comments *string `json:"comments,omitempty"` + // Time when this approval created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Time when this approval modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Approval history revision. + Revision *int `json:"revision,omitempty"` +} + +type ReleaseApprovalPendingEvent struct { + Approval *ReleaseApproval `json:"approval,omitempty"` + ApprovalOptions *ApprovalOptions `json:"approvalOptions,omitempty"` + CompletedApprovals *[]ReleaseApproval `json:"completedApprovals,omitempty"` + DefinitionName *string `json:"definitionName,omitempty"` + Deployment *Deployment `json:"deployment,omitempty"` + EnvironmentId *int `json:"environmentId,omitempty"` + EnvironmentName *string `json:"environmentName,omitempty"` + Environments *[]ReleaseEnvironment `json:"environments,omitempty"` + IsMultipleRankApproval *bool `json:"isMultipleRankApproval,omitempty"` + PendingApprovals *[]ReleaseApproval `json:"pendingApprovals,omitempty"` + ReleaseCreator *string `json:"releaseCreator,omitempty"` + ReleaseName *string `json:"releaseName,omitempty"` + Title *string `json:"title,omitempty"` + WebAccessUri *string `json:"webAccessUri,omitempty"` +} + +type ReleaseArtifact struct { + // Gets or sets the artifact provider of ReleaseArtifact. + ArtifactProvider *ArtifactProvider `json:"artifactProvider,omitempty"` + // Gets or sets the artifact type of ReleaseArtifact. + ArtifactType *string `json:"artifactType,omitempty"` + // Gets or sets the definition json of ReleaseArtifact. + DefinitionData *string `json:"definitionData,omitempty"` + // Gets or sets the definition id of ReleaseArtifact. + DefinitionId *int `json:"definitionId,omitempty"` + // Gets or sets the description of ReleaseArtifact. + Description *string `json:"description,omitempty"` + // Gets or sets the id of ReleaseArtifact. + Id *int `json:"id,omitempty"` + // Gets or sets the name of ReleaseArtifact. + Name *string `json:"name,omitempty"` + // Gets or sets the release id. + ReleaseId *int `json:"releaseId,omitempty"` +} + +type ReleaseCondition struct { + // Gets or sets the condition type. + ConditionType *ConditionType `json:"conditionType,omitempty"` + // Gets or sets the name of the condition. e.g. 'ReleaseStarted'. + Name *string `json:"name,omitempty"` + // Gets or set value of the condition. + Value *string `json:"value,omitempty"` + // The release condition result. + Result *bool `json:"result,omitempty"` +} + +type ReleaseCreatedEvent struct { + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +type ReleaseDefinition struct { + // Gets the links to related resources, APIs, and views for the release definition. + Links interface{} `json:"_links,omitempty"` + // Gets the unique identifier of release definition. + Id *int `json:"id,omitempty"` + // Gets or sets the name of the release definition. + Name *string `json:"name,omitempty"` + // Gets or sets the path of the release definition. + Path *string `json:"path,omitempty"` + // Gets or sets project reference. + ProjectReference *ProjectReference `json:"projectReference,omitempty"` + // Gets the REST API url to access the release definition. + Url *string `json:"url,omitempty"` + // Gets or sets the list of artifacts. + Artifacts *[]Artifact `json:"artifacts,omitempty"` + // Gets or sets comment. + Comment *string `json:"comment,omitempty"` + // Gets or sets the identity who created. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets or sets the description. + Description *string `json:"description,omitempty"` + // Gets or sets the list of environments. + Environments *[]ReleaseDefinitionEnvironment `json:"environments,omitempty"` + // Whether release definition is deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + // Gets the reference of last release. + LastRelease *ReleaseReference `json:"lastRelease,omitempty"` + // Gets or sets the identity who modified. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets properties. + Properties interface{} `json:"properties,omitempty"` + // Gets or sets the release name format. + ReleaseNameFormat *string `json:"releaseNameFormat,omitempty"` + // Deprecated: Retention policy at Release Definition level is deprecated. Use the Retention Policy at environment and API version 3.0-preview.2 or later + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` + // Gets the revision number. + Revision *int `json:"revision,omitempty"` + // Gets or sets source of release definition. + Source *ReleaseDefinitionSource `json:"source,omitempty"` + // Gets or sets list of tags. + Tags *[]string `json:"tags,omitempty"` + // Gets or sets the list of triggers. + Triggers *[]interface{} `json:"triggers,omitempty"` + // Gets or sets the list of variable groups. + VariableGroups *[]int `json:"variableGroups,omitempty"` + // Gets or sets the dictionary of variables. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +type ReleaseDefinitionApprovals struct { + // Gets or sets the approval options. + ApprovalOptions *ApprovalOptions `json:"approvalOptions,omitempty"` + // Gets or sets the approvals. + Approvals *[]ReleaseDefinitionApprovalStep `json:"approvals,omitempty"` +} + +type ReleaseDefinitionApprovalStep struct { + // ID of the approval or deploy step. + Id *int `json:"id,omitempty"` + // Gets and sets the approver. + Approver *webapi.IdentityRef `json:"approver,omitempty"` + // Indicates whether the approval automated. + IsAutomated *bool `json:"isAutomated,omitempty"` + // Indicates whether the approval notification set. + IsNotificationOn *bool `json:"isNotificationOn,omitempty"` + // Gets or sets the rank of approval step. + Rank *int `json:"rank,omitempty"` +} + +type ReleaseDefinitionDeployStep struct { + // ID of the approval or deploy step. + Id *int `json:"id,omitempty"` + // The list of steps for this definition. + Tasks *[]WorkflowTask `json:"tasks,omitempty"` +} + +type ReleaseDefinitionEnvironment struct { + // Gets or sets the BadgeUrl. BadgeUrl will be used when Badge will be enabled in Release Definition Environment. + BadgeUrl *string `json:"badgeUrl,omitempty"` + // Gets or sets the environment conditions. + Conditions *[]Condition `json:"conditions,omitempty"` + // Gets or sets the current release reference. + CurrentRelease *ReleaseShallowReference `json:"currentRelease,omitempty"` + // Gets or sets the demands. + Demands *[]interface{} `json:"demands,omitempty"` + // Gets or sets the deploy phases of environment. + DeployPhases *[]interface{} `json:"deployPhases,omitempty"` + // Gets or sets the deploystep. + DeployStep *ReleaseDefinitionDeployStep `json:"deployStep,omitempty"` + // Gets or sets the environment options. + EnvironmentOptions *EnvironmentOptions `json:"environmentOptions,omitempty"` + // Gets or sets the triggers on environment. + EnvironmentTriggers *[]EnvironmentTrigger `json:"environmentTriggers,omitempty"` + // Gets or sets the environment execution policy. + ExecutionPolicy *EnvironmentExecutionPolicy `json:"executionPolicy,omitempty"` + // Gets and sets the ID of the ReleaseDefinitionEnvironment. + Id *int `json:"id,omitempty"` + // Gets and sets the name of the ReleaseDefinitionEnvironment. + Name *string `json:"name,omitempty"` + // Gets and sets the Owner of the ReleaseDefinitionEnvironment. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Gets or sets the post deployment approvals. + PostDeployApprovals *ReleaseDefinitionApprovals `json:"postDeployApprovals,omitempty"` + // Gets or sets the post deployment gates. + PostDeploymentGates *ReleaseDefinitionGatesStep `json:"postDeploymentGates,omitempty"` + // Gets or sets the pre deployment approvals. + PreDeployApprovals *ReleaseDefinitionApprovals `json:"preDeployApprovals,omitempty"` + // Gets or sets the pre deployment gates. + PreDeploymentGates *ReleaseDefinitionGatesStep `json:"preDeploymentGates,omitempty"` + // Gets or sets the environment process parameters. + ProcessParameters *distributedtaskcommon.ProcessParameters `json:"processParameters,omitempty"` + // Gets or sets the properties on environment. + Properties interface{} `json:"properties,omitempty"` + // Gets or sets the queue ID. + QueueId *int `json:"queueId,omitempty"` + // Gets and sets the rank of the ReleaseDefinitionEnvironment. + Rank *int `json:"rank,omitempty"` + // Gets or sets the environment retention policy. + RetentionPolicy *EnvironmentRetentionPolicy `json:"retentionPolicy,omitempty"` + // Deprecated: This property is deprecated, use EnvironmentOptions instead. + RunOptions *map[string]string `json:"runOptions,omitempty"` + // Gets or sets the schedules + Schedules *[]ReleaseSchedule `json:"schedules,omitempty"` + // Gets or sets the variable groups. + VariableGroups *[]int `json:"variableGroups,omitempty"` + // Gets and sets the variables. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +type ReleaseDefinitionEnvironmentStep struct { + // ID of the approval or deploy step. + Id *int `json:"id,omitempty"` +} + +type ReleaseDefinitionEnvironmentSummary struct { + // ID of ReleaseDefinition environment summary. + Id *int `json:"id,omitempty"` + // List of release shallow reference deployed using this ReleaseDefinition. + LastReleases *[]ReleaseShallowReference `json:"lastReleases,omitempty"` + // Name of ReleaseDefinition environment summary. + Name *string `json:"name,omitempty"` +} + +type ReleaseDefinitionEnvironmentTemplate struct { + // Indicates whether template can be deleted or not. + CanDelete *bool `json:"canDelete,omitempty"` + // Category of the ReleaseDefinition environment template. + Category *string `json:"category,omitempty"` + // Description of the ReleaseDefinition environment template. + Description *string `json:"description,omitempty"` + // ReleaseDefinition environment data which used to create this template. + Environment *ReleaseDefinitionEnvironment `json:"environment,omitempty"` + // ID of the task which used to display icon used for this template. + IconTaskId *uuid.UUID `json:"iconTaskId,omitempty"` + // Icon uri of the template. + IconUri *string `json:"iconUri,omitempty"` + // ID of the ReleaseDefinition environment template. + Id *uuid.UUID `json:"id,omitempty"` + // Indicates whether template deleted or not. + IsDeleted *bool `json:"isDeleted,omitempty"` + // Name of the ReleaseDefinition environment template. + Name *string `json:"name,omitempty"` +} + +// [Flags] +type ReleaseDefinitionExpands string + +type releaseDefinitionExpandsValuesType struct { + None ReleaseDefinitionExpands + Environments ReleaseDefinitionExpands + Artifacts ReleaseDefinitionExpands + Triggers ReleaseDefinitionExpands + Variables ReleaseDefinitionExpands + Tags ReleaseDefinitionExpands + LastRelease ReleaseDefinitionExpands +} + +var ReleaseDefinitionExpandsValues = releaseDefinitionExpandsValuesType{ + // Returns top level properties of object. + None: "none", + // Include environments in return object. + Environments: "environments", + // Include artifacts in return object. + Artifacts: "artifacts", + // Include triggers in return object. + Triggers: "triggers", + // Include variables in return object. + Variables: "variables", + // Include tags in return object. + Tags: "tags", + // Include last release in return object. + LastRelease: "lastRelease", +} + +type ReleaseDefinitionGate struct { + // Gets or sets the gates workflow. + Tasks *[]WorkflowTask `json:"tasks,omitempty"` +} + +type ReleaseDefinitionGatesOptions struct { + // Gets or sets as the gates enabled or not. + IsEnabled *bool `json:"isEnabled,omitempty"` + // Gets or sets the minimum duration for steady results after a successful gates evaluation. + MinimumSuccessDuration *int `json:"minimumSuccessDuration,omitempty"` + // Gets or sets the time between re-evaluation of gates. + SamplingInterval *int `json:"samplingInterval,omitempty"` + // Gets or sets the delay before evaluation. + StabilizationTime *int `json:"stabilizationTime,omitempty"` + // Gets or sets the timeout after which gates fail. + Timeout *int `json:"timeout,omitempty"` +} + +type ReleaseDefinitionGatesStep struct { + // Gets or sets the gates. + Gates *[]ReleaseDefinitionGate `json:"gates,omitempty"` + // Gets or sets the gate options. + GatesOptions *ReleaseDefinitionGatesOptions `json:"gatesOptions,omitempty"` + // ID of the ReleaseDefinitionGateStep. + Id *int `json:"id,omitempty"` +} + +type ReleaseDefinitionQueryOrder string + +type releaseDefinitionQueryOrderValuesType struct { + IdAscending ReleaseDefinitionQueryOrder + IdDescending ReleaseDefinitionQueryOrder + NameAscending ReleaseDefinitionQueryOrder + NameDescending ReleaseDefinitionQueryOrder +} + +var ReleaseDefinitionQueryOrderValues = releaseDefinitionQueryOrderValuesType{ + // Return results based on release definition Id ascending order. + IdAscending: "idAscending", + // Return results based on release definition Id descending order. + IdDescending: "idDescending", + // Return results based on release definition name ascending order. + NameAscending: "nameAscending", + // Return results based on release definition name descending order. + NameDescending: "nameDescending", +} + +type ReleaseDefinitionRevision struct { + // Gets api-version for revision object. + ApiVersion *string `json:"apiVersion,omitempty"` + // Gets the identity who did change. + ChangedBy *webapi.IdentityRef `json:"changedBy,omitempty"` + // Gets date on which ReleaseDefinition changed. + ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` + // Gets type of change. + ChangeType *AuditAction `json:"changeType,omitempty"` + // Gets comments for revision. + Comment *string `json:"comment,omitempty"` + // Get id of the definition. + DefinitionId *int `json:"definitionId,omitempty"` + // Gets definition URL. + DefinitionUrl *string `json:"definitionUrl,omitempty"` + // Get revision number of the definition. + Revision *int `json:"revision,omitempty"` +} + +type ReleaseDefinitionShallowReference struct { + // Gets the links to related resources, APIs, and views for the release definition. + Links interface{} `json:"_links,omitempty"` + // Gets the unique identifier of release definition. + Id *int `json:"id,omitempty"` + // Gets or sets the name of the release definition. + Name *string `json:"name,omitempty"` + // Gets or sets the path of the release definition. + Path *string `json:"path,omitempty"` + // Gets or sets project reference. + ProjectReference *ProjectReference `json:"projectReference,omitempty"` + // Gets the REST API url to access the release definition. + Url *string `json:"url,omitempty"` +} + +// [Flags] +type ReleaseDefinitionSource string + +type releaseDefinitionSourceValuesType struct { + Undefined ReleaseDefinitionSource + RestApi ReleaseDefinitionSource + UserInterface ReleaseDefinitionSource + Ibiza ReleaseDefinitionSource + PortalExtensionApi ReleaseDefinitionSource +} + +var ReleaseDefinitionSourceValues = releaseDefinitionSourceValuesType{ + // Indicates ReleaseDefinition source not defined. + Undefined: "undefined", + // Indicates ReleaseDefinition created using REST API. + RestApi: "restApi", + // Indicates ReleaseDefinition created using UI. + UserInterface: "userInterface", + // Indicates ReleaseDefinition created from Ibiza. + Ibiza: "ibiza", + // Indicates ReleaseDefinition created from PortalExtension API. + PortalExtensionApi: "portalExtensionApi", +} + +type ReleaseDefinitionSummary struct { + // List of Release Definition environment summary. + Environments *[]ReleaseDefinitionEnvironmentSummary `json:"environments,omitempty"` + // Release Definition reference. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // List of releases deployed using this Release Definition. + Releases *[]Release `json:"releases,omitempty"` +} + +type ReleaseDefinitionUndeleteParameter struct { + // Gets or sets comment. + Comment *string `json:"comment,omitempty"` +} + +type ReleaseDeployPhase struct { + // Deployment jobs of the phase. + DeploymentJobs *[]DeploymentJob `json:"deploymentJobs,omitempty"` + // Phase execution error logs. + ErrorLog *string `json:"errorLog,omitempty"` + // Deprecated: + Id *int `json:"id,omitempty"` + // List of manual intervention tasks execution information in phase. + ManualInterventions *[]ManualIntervention `json:"manualInterventions,omitempty"` + // Name of the phase. + Name *string `json:"name,omitempty"` + // ID of the phase. + PhaseId *string `json:"phaseId,omitempty"` + // Type of the phase. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Rank of the phase. + Rank *int `json:"rank,omitempty"` + // Run Plan ID of the phase. + RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` + // Phase start time. + StartedOn *azuredevops.Time `json:"startedOn,omitempty"` + // Status of the phase. + Status *DeployPhaseStatus `json:"status,omitempty"` +} + +type ReleaseEnvironment struct { + // Gets list of conditions. + Conditions *[]ReleaseCondition `json:"conditions,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets definition environment id. + DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` + // Deprecated: Use DeploymentInput.Demands instead. + Demands *[]interface{} `json:"demands,omitempty"` + // Gets list of deploy phases snapshot. + DeployPhasesSnapshot *[]interface{} `json:"deployPhasesSnapshot,omitempty"` + // Gets deploy steps. + DeploySteps *[]DeploymentAttempt `json:"deploySteps,omitempty"` + // Gets environment options. + EnvironmentOptions *EnvironmentOptions `json:"environmentOptions,omitempty"` + // Gets the unique identifier of this field. + Id *int `json:"id,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets name. + Name *string `json:"name,omitempty"` + // Gets next scheduled UTC time. + NextScheduledUtcTime *azuredevops.Time `json:"nextScheduledUtcTime,omitempty"` + // Gets the identity who is owner for release environment. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Gets list of post deploy approvals snapshot. + PostApprovalsSnapshot *ReleaseDefinitionApprovals `json:"postApprovalsSnapshot,omitempty"` + // Gets list of post deploy approvals. + PostDeployApprovals *[]ReleaseApproval `json:"postDeployApprovals,omitempty"` + // Post deployment gates snapshot data. + PostDeploymentGatesSnapshot *ReleaseDefinitionGatesStep `json:"postDeploymentGatesSnapshot,omitempty"` + // Gets list of pre deploy approvals snapshot. + PreApprovalsSnapshot *ReleaseDefinitionApprovals `json:"preApprovalsSnapshot,omitempty"` + // Gets list of pre deploy approvals. + PreDeployApprovals *[]ReleaseApproval `json:"preDeployApprovals,omitempty"` + // Pre deployment gates snapshot data. + PreDeploymentGatesSnapshot *ReleaseDefinitionGatesStep `json:"preDeploymentGatesSnapshot,omitempty"` + // Gets process parameters. + ProcessParameters *distributedtaskcommon.ProcessParameters `json:"processParameters,omitempty"` + // Deprecated: Use DeploymentInput.QueueId instead. + QueueId *int `json:"queueId,omitempty"` + // Gets rank. + Rank *int `json:"rank,omitempty"` + // Gets release reference which specifies the reference of the release to which this release environment is associated. + Release *ReleaseShallowReference `json:"release,omitempty"` + // Gets the identity who created release. + ReleaseCreatedBy *webapi.IdentityRef `json:"releaseCreatedBy,omitempty"` + // Gets releaseDefinitionReference which specifies the reference of the release definition to which this release environment is associated. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Deprecated: Use Release object Description instead. + ReleaseDescription *string `json:"releaseDescription,omitempty"` + // Gets release id. + ReleaseId *int `json:"releaseId,omitempty"` + // Gets schedule deployment time of release environment. + ScheduledDeploymentTime *azuredevops.Time `json:"scheduledDeploymentTime,omitempty"` + // Gets list of schedules. + Schedules *[]ReleaseSchedule `json:"schedules,omitempty"` + // Gets environment status. + Status *EnvironmentStatus `json:"status,omitempty"` + // Gets time to deploy. + TimeToDeploy *float64 `json:"timeToDeploy,omitempty"` + // Gets trigger reason. + TriggerReason *string `json:"triggerReason,omitempty"` + // Gets the list of variable groups. + VariableGroups *[]VariableGroup `json:"variableGroups,omitempty"` + // Gets the dictionary of variables. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` + // Deprecated: Use DeployPhase.WorkflowTasks instead. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` +} + +type ReleaseEnvironmentCompletedEvent struct { + CreatedByName *string `json:"createdByName,omitempty"` + DefinitionId *int `json:"definitionId,omitempty"` + DefinitionName *string `json:"definitionName,omitempty"` + Environment *ReleaseEnvironment `json:"environment,omitempty"` + EnvironmentId *int `json:"environmentId,omitempty"` + ProjectName *string `json:"projectName,omitempty"` + Reason *DeploymentReason `json:"reason,omitempty"` + ReleaseCreatedBy *webapi.IdentityRef `json:"releaseCreatedBy,omitempty"` + ReleaseLogsUri *string `json:"releaseLogsUri,omitempty"` + ReleaseName *string `json:"releaseName,omitempty"` + Status *string `json:"status,omitempty"` + Title *string `json:"title,omitempty"` + WebAccessUri *string `json:"webAccessUri,omitempty"` +} + +type ReleaseEnvironmentShallowReference struct { + // Gets the links to related resources, APIs, and views for the release environment. + Links interface{} `json:"_links,omitempty"` + // Gets the unique identifier of release environment. + Id *int `json:"id,omitempty"` + // Gets or sets the name of the release environment. + Name *string `json:"name,omitempty"` + // Gets the REST API url to access the release environment. + Url *string `json:"url,omitempty"` +} + +type ReleaseEnvironmentStatusUpdatedEvent struct { + DefinitionId *int `json:"definitionId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + EnvironmentId *int `json:"environmentId,omitempty"` + EnvironmentStatus *EnvironmentStatus `json:"environmentStatus,omitempty"` + LatestDeploymentOperationStatus *DeploymentOperationStatus `json:"latestDeploymentOperationStatus,omitempty"` + LatestDeploymentStatus *DeploymentStatus `json:"latestDeploymentStatus,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` +} + +type ReleaseEnvironmentUpdateMetadata struct { + // Gets or sets comment. + Comment *string `json:"comment,omitempty"` + // Gets or sets scheduled deployment time. + ScheduledDeploymentTime *azuredevops.Time `json:"scheduledDeploymentTime,omitempty"` + // Gets or sets status of environment. + Status *EnvironmentStatus `json:"status,omitempty"` + // Sets list of environment variables to be overridden at deployment time. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +// [Flags] +type ReleaseExpands string + +type releaseExpandsValuesType struct { + None ReleaseExpands + Environments ReleaseExpands + Artifacts ReleaseExpands + Approvals ReleaseExpands + ManualInterventions ReleaseExpands + Variables ReleaseExpands + Tags ReleaseExpands +} + +var ReleaseExpandsValues = releaseExpandsValuesType{ + None: "none", + Environments: "environments", + Artifacts: "artifacts", + Approvals: "approvals", + ManualInterventions: "manualInterventions", + Variables: "variables", + Tags: "tags", +} + +type ReleaseGates struct { + // Contains the gates job details of each evaluation. + DeploymentJobs *[]DeploymentJob `json:"deploymentJobs,omitempty"` + // ID of release gates. + Id *int `json:"id,omitempty"` + // List of ignored gates. + IgnoredGates *[]IgnoredGate `json:"ignoredGates,omitempty"` + // Gates last modified time. + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + // Run plan ID of the gates. + RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` + // Gates stabilization completed date and time. + StabilizationCompletedOn *azuredevops.Time `json:"stabilizationCompletedOn,omitempty"` + // Gates evaluation started time. + StartedOn *azuredevops.Time `json:"startedOn,omitempty"` + // Status of release gates. + Status *GateStatus `json:"status,omitempty"` + // Date and time at which all gates executed successfully. + SucceedingSince *azuredevops.Time `json:"succeedingSince,omitempty"` +} + +type ReleaseGatesPhase struct { + // Deployment jobs of the phase. + DeploymentJobs *[]DeploymentJob `json:"deploymentJobs,omitempty"` + // Phase execution error logs. + ErrorLog *string `json:"errorLog,omitempty"` + // ID of the phase. + Id *int `json:"id,omitempty"` + // List of manual intervention tasks execution information in phase. + ManualInterventions *[]ManualIntervention `json:"manualInterventions,omitempty"` + // Name of the phase. + Name *string `json:"name,omitempty"` + // ID of the phase. + PhaseId *string `json:"phaseId,omitempty"` + // Type of the phase. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Rank of the phase. + Rank *int `json:"rank,omitempty"` + // Run Plan ID of the phase. + RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` + // Phase start time. + StartedOn *azuredevops.Time `json:"startedOn,omitempty"` + // Status of the phase. + Status *DeployPhaseStatus `json:"status,omitempty"` + // List of ignored gates. + IgnoredGates *[]IgnoredGate `json:"ignoredGates,omitempty"` + // Date and time at which stabilization of gates completed. + StabilizationCompletedOn *azuredevops.Time `json:"stabilizationCompletedOn,omitempty"` + // Date and time at which all gates executed successfully. + SucceedingSince *azuredevops.Time `json:"succeedingSince,omitempty"` +} + +type ReleaseManagementInputValue struct { + // The text to show for the display of this value. + DisplayValue *string `json:"displayValue,omitempty"` + // The value to store for this input. + Value *string `json:"value,omitempty"` +} + +type ReleaseNotCreatedEvent struct { + DefinitionReference *ReleaseDefinitionShallowReference `json:"definitionReference,omitempty"` + Message *string `json:"message,omitempty"` + ReleaseReason *ReleaseReason `json:"releaseReason,omitempty"` + RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` +} + +type ReleaseQueryOrder string + +type releaseQueryOrderValuesType struct { + Descending ReleaseQueryOrder + Ascending ReleaseQueryOrder +} + +var ReleaseQueryOrderValues = releaseQueryOrderValuesType{ + // Return results in descending order. + Descending: "descending", + // Return results in ascending order. + Ascending: "ascending", +} + +type ReleaseReason string + +type releaseReasonValuesType struct { + None ReleaseReason + Manual ReleaseReason + ContinuousIntegration ReleaseReason + Schedule ReleaseReason + PullRequest ReleaseReason +} + +var ReleaseReasonValues = releaseReasonValuesType{ + // Indicates the release triggered reason not set. + None: "none", + // Indicates the release triggered manually. + Manual: "manual", + // Indicates the release triggered by continuous integration. + ContinuousIntegration: "continuousIntegration", + // Indicates the release triggered by schedule. + Schedule: "schedule", + // Indicates the release triggered by PullRequest. + PullRequest: "pullRequest", +} + +type ReleaseReference struct { + // Gets links to access the release. + Links interface{} `json:"_links,omitempty"` + // Gets list of artifacts. + Artifacts *[]Artifact `json:"artifacts,omitempty"` + // Gets the identity who created release. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets date on when this release created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets description. + Description *string `json:"description,omitempty"` + // ID of the Release. + Id *int `json:"id,omitempty"` + // Gets the identity who modified release. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets name of release. + Name *string `json:"name,omitempty"` + // Gets reason for release. + Reason *ReleaseReason `json:"reason,omitempty"` + // Gets release definition shallow reference. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Deprecated: Use Links instead + Url *string `json:"url,omitempty"` + // Deprecated: Use Links instead + WebAccessUri *string `json:"webAccessUri,omitempty"` +} + +type ReleaseRevision struct { + // Gets or sets the identity who changed. + ChangedBy *webapi.IdentityRef `json:"changedBy,omitempty"` + // Change date of the revision. + ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` + // Change details of the revision. + ChangeDetails *string `json:"changeDetails,omitempty"` + // Change details of the revision. Typically ChangeDetails values are Add and Update. + ChangeType *string `json:"changeType,omitempty"` + // Comment of the revision. + Comment *string `json:"comment,omitempty"` + // Release ID of which this revision belongs. + DefinitionSnapshotRevision *int `json:"definitionSnapshotRevision,omitempty"` + // Gets or sets the release ID of which this revision belongs. + ReleaseId *int `json:"releaseId,omitempty"` +} + +type ReleaseSchedule struct { + // Days of the week to release. + DaysToRelease *ScheduleDays `json:"daysToRelease,omitempty"` + // Team Foundation Job Definition Job Id. + JobId *uuid.UUID `json:"jobId,omitempty"` + // Flag to determine if this schedule should only release if the associated artifact has been changed or release definition changed. + ScheduleOnlyWithChanges *bool `json:"scheduleOnlyWithChanges,omitempty"` + // Local time zone hour to start. + StartHours *int `json:"startHours,omitempty"` + // Local time zone minute to start. + StartMinutes *int `json:"startMinutes,omitempty"` + // Time zone Id of release schedule, such as 'UTC'. + TimeZoneId *string `json:"timeZoneId,omitempty"` +} + +type ReleaseSettings struct { + // Release Compliance settings. + ComplianceSettings *ComplianceSettings `json:"complianceSettings,omitempty"` + // Release retention settings. + RetentionSettings *RetentionSettings `json:"retentionSettings,omitempty"` +} + +type ReleaseShallowReference struct { + // Gets the links to related resources, APIs, and views for the release. + Links interface{} `json:"_links,omitempty"` + // Gets the unique identifier of release. + Id *int `json:"id,omitempty"` + // Gets or sets the name of the release. + Name *string `json:"name,omitempty"` + // Gets the REST API url to access the release. + Url *string `json:"url,omitempty"` +} + +type ReleaseStartEnvironmentMetadata struct { + // Sets release definition environment id. + DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` + // Sets list of environments variables to be overridden at deployment time. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +type ReleaseStartMetadata struct { + // Sets list of artifact to create a release. + Artifacts *[]ArtifactMetadata `json:"artifacts,omitempty"` + // Sets definition Id to create a release. + DefinitionId *int `json:"definitionId,omitempty"` + // Sets description to create a release. + Description *string `json:"description,omitempty"` + // Sets list of environments meta data. + EnvironmentsMetadata *[]ReleaseStartEnvironmentMetadata `json:"environmentsMetadata,omitempty"` + // Sets 'true' to create release in draft mode, 'false' otherwise. + IsDraft *bool `json:"isDraft,omitempty"` + // Sets list of environments to manual as condition. + ManualEnvironments *[]string `json:"manualEnvironments,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // Sets reason to create a release. + Reason *ReleaseReason `json:"reason,omitempty"` + // Sets list of release variables to be overridden at deployment time. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +// [Flags] +type ReleaseStatus string + +type releaseStatusValuesType struct { + Undefined ReleaseStatus + Draft ReleaseStatus + Active ReleaseStatus + Abandoned ReleaseStatus +} + +var ReleaseStatusValues = releaseStatusValuesType{ + // Release status not set. + Undefined: "undefined", + // Release is in draft state. + Draft: "draft", + // Release status is in active. + Active: "active", + // Release status is in abandoned. + Abandoned: "abandoned", +} + +type ReleaseTask struct { + // Agent name on which task executed. + AgentName *string `json:"agentName,omitempty"` + // Deprecated: Use FinishTime instead + DateEnded *azuredevops.Time `json:"dateEnded,omitempty"` + // Deprecated: Use StartTime instead. + DateStarted *azuredevops.Time `json:"dateStarted,omitempty"` + // Finish time of the release task. + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + // ID of the release task. + Id *int `json:"id,omitempty"` + // List of issues occurred while execution of task. + Issues *[]Issue `json:"issues,omitempty"` + // Number of lines log release task has. + LineCount *uint64 `json:"lineCount,omitempty"` + // Log URL of the task. + LogUrl *string `json:"logUrl,omitempty"` + // Name of the task. + Name *string `json:"name,omitempty"` + // Task execution complete precent. + PercentComplete *int `json:"percentComplete,omitempty"` + // Rank of the release task. + Rank *int `json:"rank,omitempty"` + // Result code of the task. + ResultCode *string `json:"resultCode,omitempty"` + // ID of the release task. + StartTime *azuredevops.Time `json:"startTime,omitempty"` + // Status of release task. + Status *TaskStatus `json:"status,omitempty"` + // Workflow task reference. + Task *WorkflowTaskReference `json:"task,omitempty"` + // Timeline record ID of the release task. + TimelineRecordId *uuid.UUID `json:"timelineRecordId,omitempty"` +} + +type ReleaseTaskAttachment struct { + // Reference links of task. + Links interface{} `json:"_links,omitempty"` + // Data and time when it created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Identity who modified. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Data and time when modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Name of the task attachment. + Name *string `json:"name,omitempty"` + // Record ID of the task. + RecordId *uuid.UUID `json:"recordId,omitempty"` + // Timeline ID of the task. + TimelineId *uuid.UUID `json:"timelineId,omitempty"` + // Type of task attachment. + Type *string `json:"type,omitempty"` +} + +type ReleaseTaskLogUpdatedEvent struct { + EnvironmentId *int `json:"environmentId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` + Lines *[]string `json:"lines,omitempty"` + StepRecordId *uuid.UUID `json:"stepRecordId,omitempty"` + TimelineRecordId *uuid.UUID `json:"timelineRecordId,omitempty"` +} + +type ReleaseTasksUpdatedEvent struct { + EnvironmentId *int `json:"environmentId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` + Job *ReleaseTask `json:"job,omitempty"` + PlanId *uuid.UUID `json:"planId,omitempty"` + // Deprecated: + ReleaseDeployPhaseId *int `json:"releaseDeployPhaseId,omitempty"` + ReleaseStepId *int `json:"releaseStepId,omitempty"` + Tasks *[]ReleaseTask `json:"tasks,omitempty"` +} + +type ReleaseTriggerBase struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` +} + +type ReleaseTriggerType string + +type releaseTriggerTypeValuesType struct { + Undefined ReleaseTriggerType + ArtifactSource ReleaseTriggerType + Schedule ReleaseTriggerType + SourceRepo ReleaseTriggerType + ContainerImage ReleaseTriggerType + Package ReleaseTriggerType + PullRequest ReleaseTriggerType +} + +var ReleaseTriggerTypeValues = releaseTriggerTypeValuesType{ + // Release trigger type not set. + Undefined: "undefined", + // Artifact based release trigger. + ArtifactSource: "artifactSource", + // Schedule based release trigger. + Schedule: "schedule", + // Source repository based release trigger. + SourceRepo: "sourceRepo", + // Container image based release trigger. + ContainerImage: "containerImage", + // Package based release trigger. + Package: "package", + // Pull request based release trigger. + PullRequest: "pullRequest", +} + +type ReleaseUpdatedEvent struct { + EnvironmentId *int `json:"environmentId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` + Release *Release `json:"release,omitempty"` +} + +type ReleaseUpdateMetadata struct { + // Sets comment for release. + Comment *string `json:"comment,omitempty"` + // Set 'true' to exclude the release from retention policies. + KeepForever *bool `json:"keepForever,omitempty"` + // Sets list of manual environments. + ManualEnvironments *[]string `json:"manualEnvironments,omitempty"` + // Sets name of the release. + Name *string `json:"name,omitempty"` + // Sets status of the release. + Status *ReleaseStatus `json:"status,omitempty"` +} + +type ReleaseWorkItemRef struct { + // Deprecated: + Assignee *string `json:"assignee,omitempty"` + // Gets or sets the ID. + Id *string `json:"id,omitempty"` + // Gets or sets the state. + State *string `json:"state,omitempty"` + // Gets or sets the title. + Title *string `json:"title,omitempty"` + // Gets or sets the type. + Type *string `json:"type,omitempty"` + // Gets or sets the workitem url. + Url *string `json:"url,omitempty"` +} + +type RetentionPolicy struct { + // Indicates the number of days to keep deployment. + DaysToKeep *int `json:"daysToKeep,omitempty"` +} + +type RetentionSettings struct { + // Number of days to keep deleted releases. + DaysToKeepDeletedReleases *int `json:"daysToKeepDeletedReleases,omitempty"` + // Specifies the default environment retention policy. + DefaultEnvironmentRetentionPolicy *EnvironmentRetentionPolicy `json:"defaultEnvironmentRetentionPolicy,omitempty"` + // Specifies the maximum environment retention policy. + MaximumEnvironmentRetentionPolicy *EnvironmentRetentionPolicy `json:"maximumEnvironmentRetentionPolicy,omitempty"` +} + +type RunOnServerDeployPhase struct { + // Gets and sets the name of deploy phase. + Name *string `json:"name,omitempty"` + // Indicates the deploy phase type. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Gets and sets the rank of deploy phase. + Rank *int `json:"rank,omitempty"` + // Gets and sets the reference name of deploy phase. + RefName *string `json:"refName,omitempty"` + // Gets and sets the workflow tasks for the deploy phase. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` + // Gets and sets the agentless job input. + DeploymentInput *ServerDeploymentInput `json:"deploymentInput,omitempty"` +} + +type ScheduleDays string + +type scheduleDaysValuesType struct { + None ScheduleDays + Monday ScheduleDays + Tuesday ScheduleDays + Wednesday ScheduleDays + Thursday ScheduleDays + Friday ScheduleDays + Saturday ScheduleDays + Sunday ScheduleDays + All ScheduleDays +} + +var ScheduleDaysValues = scheduleDaysValuesType{ + // Scheduled day not set. + None: "none", + // Scheduled on Monday. + Monday: "monday", + // Scheduled on Tuesday. + Tuesday: "tuesday", + // Scheduled on Wednesday. + Wednesday: "wednesday", + // Scheduled on Thursday. + Thursday: "thursday", + // Scheduled on Friday. + Friday: "friday", + // Scheduled on Saturday. + Saturday: "saturday", + // Scheduled on Sunday. + Sunday: "sunday", + // Scheduled on all the days in week. + All: "all", +} + +type ScheduledReleaseTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Release schedule for Scheduled Release trigger type. + Schedule *ReleaseSchedule `json:"schedule,omitempty"` +} + +type SenderType string + +type senderTypeValuesType struct { + ServiceAccount SenderType + RequestingUser SenderType +} + +var SenderTypeValues = senderTypeValuesType{ + ServiceAccount: "serviceAccount", + RequestingUser: "requestingUser", +} + +type ServerDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Gets or sets the parallel execution input. + ParallelExecution *ExecutionInput `json:"parallelExecution,omitempty"` +} + +// [Flags] +type SingleReleaseExpands string + +type singleReleaseExpandsValuesType struct { + None SingleReleaseExpands + Tasks SingleReleaseExpands +} + +var SingleReleaseExpandsValues = singleReleaseExpandsValuesType{ + // Return top level properties of object. + None: "none", + // Expand release with tasks. + Tasks: "tasks", +} + +type SourceIdInput struct { + // ID of source. + Id *string `json:"id,omitempty"` + // Name of the source. + Name *string `json:"name,omitempty"` +} + +type SourcePullRequestVersion struct { + // Pull Request Iteration Id for which the release will publish status. + IterationId *string `json:"iterationId,omitempty"` + // Pull Request Id for which the release will publish status. + PullRequestId *string `json:"pullRequestId,omitempty"` + // Date and time of the pull request merge creation. It is required to keep timeline record of Releases created by pull request. + PullRequestMergedAt *azuredevops.Time `json:"pullRequestMergedAt,omitempty"` + // Source branch of the Pull Request. + SourceBranch *string `json:"sourceBranch,omitempty"` + // Source branch commit Id of the Pull Request for which the release will publish status. + SourceBranchCommitId *string `json:"sourceBranchCommitId,omitempty"` + // Target branch of the Pull Request. + TargetBranch *string `json:"targetBranch,omitempty"` +} + +type SourceRepoTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Alias of the source repo trigger. + Alias *string `json:"alias,omitempty"` + BranchFilters *[]string `json:"branchFilters,omitempty"` +} + +type SummaryMailSection struct { + // Html content of summary mail. + HtmlContent *string `json:"htmlContent,omitempty"` + // Rank of the summary mail. + Rank *int `json:"rank,omitempty"` + // Summary mail section type. MailSectionType has section types. + SectionType *MailSectionType `json:"sectionType,omitempty"` + // Title of the summary mail. + Title *string `json:"title,omitempty"` +} + +type TagFilter struct { + // Gets or sets the tag filter pattern. + Pattern *string `json:"pattern,omitempty"` +} + +type TaskOrchestrationPlanGroupReference struct { + // Gets or sets the plan group. + PlanGroup *string `json:"planGroup,omitempty"` + // ID of the Project. + ProjectId *uuid.UUID `json:"projectId,omitempty"` +} + +type TaskOrchestrationPlanGroupsStartedEvent struct { + PlanGroups *[]TaskOrchestrationPlanGroupReference `json:"planGroups,omitempty"` +} + +type TaskStatus string + +type taskStatusValuesType struct { + Unknown TaskStatus + Pending TaskStatus + InProgress TaskStatus + Success TaskStatus + Failure TaskStatus + Canceled TaskStatus + Skipped TaskStatus + Succeeded TaskStatus + Failed TaskStatus + PartiallySucceeded TaskStatus +} + +var TaskStatusValues = taskStatusValuesType{ + // The task does not have the status set. + Unknown: "unknown", + // The task is in pending status. + Pending: "pending", + // The task is currently in progress. + InProgress: "inProgress", + // The task completed successfully. + Success: "success", + // The task execution failed. + Failure: "failure", + // The task execution canceled. + Canceled: "canceled", + // The task execution skipped. + Skipped: "skipped", + // The task completed successfully. + Succeeded: "succeeded", + // The task execution failed. + Failed: "failed", + // The task execution partially succeeded. + PartiallySucceeded: "partiallySucceeded", +} + +type TfvcArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type TimeZone struct { + // Display name of the time zone. + DisplayName *string `json:"displayName,omitempty"` + // Id of the time zone. + Id *string `json:"id,omitempty"` +} + +type TimeZoneList struct { + // UTC timezone. + UtcTimeZone *TimeZone `json:"utcTimeZone,omitempty"` + // List of valid timezones. + ValidTimeZones *[]TimeZone `json:"validTimeZones,omitempty"` +} + +type VariableGroup struct { + // Gets or sets the identity who created. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets or sets description. + Description *string `json:"description,omitempty"` + // Gets the unique identifier of this field. + Id *int `json:"id,omitempty"` + // Denotes if a variable group is shared with other project or not. + IsShared *bool `json:"isShared,omitempty"` + // Gets or sets the identity who modified. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets name. + Name *string `json:"name,omitempty"` + // Gets or sets provider data. + ProviderData *VariableGroupProviderData `json:"providerData,omitempty"` + // Gets or sets type. + Type *string `json:"type,omitempty"` + // Gets and sets the dictionary of variables. + Variables *map[string]VariableValue `json:"variables,omitempty"` +} + +// [Flags] +type VariableGroupActionFilter string + +type variableGroupActionFilterValuesType struct { + None VariableGroupActionFilter + Manage VariableGroupActionFilter + Use VariableGroupActionFilter +} + +var VariableGroupActionFilterValues = variableGroupActionFilterValuesType{ + None: "none", + Manage: "manage", + Use: "use", +} + +type VariableGroupProviderData struct { +} + +type VariableValue struct { + // Gets or sets as the variable is secret or not. + IsSecret *bool `json:"isSecret,omitempty"` + // Gets or sets the value. + Value *string `json:"value,omitempty"` +} + +type WorkflowTask struct { + // Gets or sets as the task always run or not. + AlwaysRun *bool `json:"alwaysRun,omitempty"` + // Gets or sets the task condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets as the task continue run on error or not. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // Gets or sets the task definition type. Example:- 'Agent', DeploymentGroup', 'Server' or 'ServerGate'. + DefinitionType *string `json:"definitionType,omitempty"` + // Gets or sets as the task enabled or not. + Enabled *bool `json:"enabled,omitempty"` + // Gets or sets the task environment variables. + Environment *map[string]string `json:"environment,omitempty"` + // Gets or sets the task inputs. + Inputs *map[string]string `json:"inputs,omitempty"` + // Gets or sets the name of the task. + Name *string `json:"name,omitempty"` + // Gets or sets the task override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the reference name of the task. + RefName *string `json:"refName,omitempty"` + // Gets or sets the ID of the task. + TaskId *uuid.UUID `json:"taskId,omitempty"` + // Gets or sets the task timeout. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Gets or sets the version of the task. + Version *string `json:"version,omitempty"` +} + +type WorkflowTaskReference struct { + // Task identifier. + Id *uuid.UUID `json:"id,omitempty"` + // Name of the task. + Name *string `json:"name,omitempty"` + // Version of the task. + Version *string `json:"version,omitempty"` +} + +// [Flags] +type YamlFileSourceTypes string + +type yamlFileSourceTypesValuesType struct { + None YamlFileSourceTypes + TfsGit YamlFileSourceTypes +} + +var YamlFileSourceTypesValues = yamlFileSourceTypesValuesType{ + None: "none", + TfsGit: "tfsGit", +} diff --git a/azuredevops/search/client.go b/azuredevops/search/client.go new file mode 100644 index 00000000..3c62e05e --- /dev/null +++ b/azuredevops/search/client.go @@ -0,0 +1,215 @@ +// -------------------------------------------------------------------------------------------- +// 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 search + +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/searchshared" + "net/http" +) + +var ResourceAreaId, _ = uuid.Parse("ea48a0a1-269c-42d8-b8ad-ddc8fcdcf578") + +type Client interface { + // [Preview API] Provides a set of results for the search text. + FetchCodeSearchResults(context.Context, FetchCodeSearchResultsArgs) (*CodeSearchResponse, error) + // [Preview API] Provides a set of results for the search text. + FetchPackageSearchResults(context.Context, FetchPackageSearchResultsArgs) (*searchshared.PackageSearchResponse, error) + // [Preview API] Provides a set of results for the search text. + FetchScrollCodeSearchResults(context.Context, FetchScrollCodeSearchResultsArgs) (*CodeSearchResponse, error) + // [Preview API] Provides a set of results for the search request. + FetchWikiSearchResults(context.Context, FetchWikiSearchResultsArgs) (*searchshared.WikiSearchResponse, error) + // [Preview API] Provides a set of results for the search text. + FetchWorkItemSearchResults(context.Context, FetchWorkItemSearchResultsArgs) (*WorkItemSearchResponse, 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] Provides a set of results for the search text. +func (client *ClientImpl) FetchCodeSearchResults(ctx context.Context, args FetchCodeSearchResultsArgs) (*CodeSearchResponse, error) { + if args.Request == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Request"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.Request) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e7f29993-5b82-4fca-9386-f5cfe683d524") + 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 CodeSearchResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the FetchCodeSearchResults function +type FetchCodeSearchResultsArgs struct { + // (required) The Code Search Request. + Request *CodeSearchRequest + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Provides a set of results for the search text. +func (client *ClientImpl) FetchPackageSearchResults(ctx context.Context, args FetchPackageSearchResultsArgs) (*searchshared.PackageSearchResponse, error) { + if args.Request == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Request"} + } + body, marshalErr := json.Marshal(*args.Request) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("f62ada48-eedc-4c8e-93f0-de870e4ecce0") + 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 responseBodyValue searchshared.PackageSearchResponseContent + err = client.Client.UnmarshalBody(resp, &responseBodyValue) + + var responseValue *searchshared.PackageSearchResponse + if err == nil { + responseValue = &searchshared.PackageSearchResponse{ + Content: &responseBodyValue, + ActivityId: &[]string{resp.Header.Get("ActivityId")}, + } + } + + return responseValue, err +} + +// Arguments for the FetchPackageSearchResults function +type FetchPackageSearchResultsArgs struct { + // (required) The Package Search Request. + Request *searchshared.PackageSearchRequest +} + +// [Preview API] Provides a set of results for the search text. +func (client *ClientImpl) FetchScrollCodeSearchResults(ctx context.Context, args FetchScrollCodeSearchResultsArgs) (*CodeSearchResponse, error) { + if args.Request == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Request"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.Request) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("852dac94-e8f7-45a2-9910-927ae35766a2") + 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 CodeSearchResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the FetchScrollCodeSearchResults function +type FetchScrollCodeSearchResultsArgs struct { + // (required) The Code Search Request. + Request *searchshared.ScrollSearchRequest + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Provides a set of results for the search request. +func (client *ClientImpl) FetchWikiSearchResults(ctx context.Context, args FetchWikiSearchResultsArgs) (*searchshared.WikiSearchResponse, error) { + if args.Request == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Request"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.Request) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e90e7664-7049-4100-9a86-66b161d81080") + 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 searchshared.WikiSearchResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the FetchWikiSearchResults function +type FetchWikiSearchResultsArgs struct { + // (required) The Wiki Search Request. + Request *searchshared.WikiSearchRequest + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Provides a set of results for the search text. +func (client *ClientImpl) FetchWorkItemSearchResults(ctx context.Context, args FetchWorkItemSearchResultsArgs) (*WorkItemSearchResponse, error) { + if args.Request == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Request"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.Request) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("73b2c9e2-ff9e-4447-8cda-5f5b21ff7cae") + 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 WorkItemSearchResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the FetchWorkItemSearchResults function +type FetchWorkItemSearchResultsArgs struct { + // (required) The Work Item Search Request. + Request *WorkItemSearchRequest + // (optional) Project ID or project name + Project *string +} diff --git a/azuredevops/search/models.go b/azuredevops/search/models.go new file mode 100644 index 00000000..15d28ca0 --- /dev/null +++ b/azuredevops/search/models.go @@ -0,0 +1,118 @@ +// -------------------------------------------------------------------------------------------- +// 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 search + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops/searchshared" +) + +// Defines the code result containing information of the searched files and its metadata. +type CodeResult struct { + // Collection of the result file. + Collection *searchshared.Collection `json:"collection,omitempty"` + // ContentId of the result file. + ContentId *string `json:"contentId,omitempty"` + // Name of the result file. + FileName *string `json:"fileName,omitempty"` + // Dictionary of field to hit offsets in the result file. Key identifies the area in which hits were found, for ex: file content/file name etc. + Matches *map[string][]searchshared.Hit `json:"matches,omitempty"` + // Path at which result file is present. + Path *string `json:"path,omitempty"` + // Project of the result file. + Project *Project `json:"project,omitempty"` + // Repository of the result file. + Repository *searchshared.Repository `json:"repository,omitempty"` + // Versions of the result file. + Versions *[]searchshared.Version `json:"versions,omitempty"` +} + +// Defines a code search request. +type CodeSearchRequest struct { + // Filters to be applied. Set it to null if there are no filters to be applied. + Filters *map[string][]string `json:"filters,omitempty"` + // The search text. + SearchText *string `json:"searchText,omitempty"` + // Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + OrderBy *[]searchshared.SortOption `json:"$orderBy,omitempty"` + // Number of results to be skipped. + Skip *int `json:"$skip,omitempty"` + // Number of results to be returned. + Top *int `json:"$top,omitempty"` + // Flag to opt for faceting in the result. Default behavior is false. + IncludeFacets *bool `json:"includeFacets,omitempty"` +} + +// Defines a code search response item. +type CodeSearchResponse struct { + // A dictionary storing an array of Filter object against each facet. + Facets *map[string][]searchshared.Filter `json:"facets,omitempty"` + // Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + InfoCode *int `json:"infoCode,omitempty"` + // Total number of matched files. + Count *int `json:"count,omitempty"` + // List of matched files. + Results *[]CodeResult `json:"results,omitempty"` +} + +// Defines the details of the project. +type Project struct { + // Id of the project. + Id *uuid.UUID `json:"id,omitempty"` + // Name of the project. + Name *string `json:"name,omitempty"` +} + +// Defines the matched terms in the field of the work item result. +type WorkItemHit struct { + // Reference name of the highlighted field. + FieldReferenceName *string `json:"fieldReferenceName,omitempty"` + // Matched/highlighted snippets of the field. + Highlights *[]string `json:"highlights,omitempty"` +} + +// Defines the work item result that matched a work item search request. +type WorkItemResult struct { + // A standard set of work item fields and their values. + Fields *map[string]string `json:"fields,omitempty"` + // Highlighted snippets of fields that match the search request. The list is sorted by relevance of the snippets. + Hits *[]WorkItemHit `json:"hits,omitempty"` + // Project details of the work item. + Project *Project `json:"project,omitempty"` + // Reference to the work item. + Url *string `json:"url,omitempty"` +} + +// Defines a work item search request. +type WorkItemSearchRequest struct { + // Filters to be applied. Set it to null if there are no filters to be applied. + Filters *map[string][]string `json:"filters,omitempty"` + // The search text. + SearchText *string `json:"searchText,omitempty"` + // Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + OrderBy *[]searchshared.SortOption `json:"$orderBy,omitempty"` + // Number of results to be skipped. + Skip *int `json:"$skip,omitempty"` + // Number of results to be returned. + Top *int `json:"$top,omitempty"` + // Flag to opt for faceting in the result. Default behavior is false. + IncludeFacets *bool `json:"includeFacets,omitempty"` +} + +// Defines a response item that is returned for a work item search request. +type WorkItemSearchResponse struct { + // A dictionary storing an array of Filter object against each facet. + Facets *map[string][]searchshared.Filter `json:"facets,omitempty"` + // Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + InfoCode *int `json:"infoCode,omitempty"` + // Total number of matched work items. + Count *int `json:"count,omitempty"` + // List of top matched work items. + Results *[]WorkItemResult `json:"results,omitempty"` +} diff --git a/azuredevops/searchshared/models.go b/azuredevops/searchshared/models.go new file mode 100644 index 00000000..f7199c9a --- /dev/null +++ b/azuredevops/searchshared/models.go @@ -0,0 +1,368 @@ +// -------------------------------------------------------------------------------------------- +// 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 searchshared + +import ( + "github.com/google/uuid" +) + +// Defines the details of the collection. +type Collection struct { + // Name of the collection. + Name *string `json:"name,omitempty"` +} + +// Base contract for search request types without scroll support. +type EntitySearchRequest struct { + // Filters to be applied. Set it to null if there are no filters to be applied. + Filters *map[string][]string `json:"filters,omitempty"` + // The search text. + SearchText *string `json:"searchText,omitempty"` + // Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + OrderBy *[]SortOption `json:"$orderBy,omitempty"` + // Number of results to be skipped. + Skip *int `json:"$skip,omitempty"` + // Number of results to be returned. + Top *int `json:"$top,omitempty"` + // Flag to opt for faceting in the result. Default behavior is false. + IncludeFacets *bool `json:"includeFacets,omitempty"` +} + +// Base class for search request types. +type EntitySearchRequestBase struct { + // Filters to be applied. Set it to null if there are no filters to be applied. + Filters *map[string][]string `json:"filters,omitempty"` + // The search text. + SearchText *string `json:"searchText,omitempty"` +} + +// Defines the base contract for search response. +type EntitySearchResponse struct { + // A dictionary storing an array of Filter object against each facet. + Facets *map[string][]Filter `json:"facets,omitempty"` + // Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + InfoCode *int `json:"infoCode,omitempty"` +} + +// Defines the details of a feed. +type FeedInfo struct { + // Id of the collection. + CollectionId *string `json:"collectionId,omitempty"` + // Name of the collection. + CollectionName *string `json:"collectionName,omitempty"` + // Id of the feed. + FeedId *string `json:"feedId,omitempty"` + // Name of the feed. + FeedName *string `json:"feedName,omitempty"` + // Latest matched version of package in this Feed. + LatestMatchedVersion *string `json:"latestMatchedVersion,omitempty"` + // Latest version of package in this Feed. + LatestVersion *string `json:"latestVersion,omitempty"` + // Url of package in this Feed. + PackageUrl *string `json:"packageUrl,omitempty"` + // List of views which contain the matched package. + Views *[]string `json:"views,omitempty"` +} + +// Describes a filter bucket item representing the total matches of search result, name and id. +type Filter struct { + // Id of the filter bucket. + Id *string `json:"id,omitempty"` + // Name of the filter bucket. + Name *string `json:"name,omitempty"` + // Count of matches in the filter bucket. + ResultCount *int `json:"resultCount,omitempty"` +} + +// Describes the position of a piece of text in a document. +type Hit struct { + // Gets or sets the start character offset of a piece of text. + CharOffset *int `json:"charOffset,omitempty"` + // Gets or sets the length of a piece of text. + Length *int `json:"length,omitempty"` +} + +// Standard info codes that we return from Query Pipeline to UX/Client as part of REST contracts +type InfoCodes string + +type infoCodesValuesType struct { + Ok InfoCodes + AccountIsBeingReindexed InfoCodes + IndexingNotStarted InfoCodes + InvalidRequest InfoCodes + PrefixWildcardQueryNotSupported InfoCodes + MultiWordWithCodeFacetNotSupported InfoCodes + AccountIsBeingOnboarded InfoCodes + TakeResultValueTrimmedToMaxResultAllowed InfoCodes + BranchesAreBeingIndexed InfoCodes + FacetingNotEnabledAtScaleUnit InfoCodes + WorkItemsNotAccessible InfoCodes + EmptyQueryNotSupported InfoCodes + OnlyWildcardQueryNotSupported InfoCodes + ZeroResultsWithWildcard InfoCodes + ZeroResultsWithFilter InfoCodes + ZeroResultsWithWildcardAndFilter InfoCodes + ZeroResultsWithNoWildcardNoFilter InfoCodes + PartialResultsDueToSearchRequestTimeout InfoCodes + PhraseQueriesWithCEFacetsNotSupported InfoCodes + WildcardQueriesWithCEFacetsNotSupported InfoCodes + ClearedScrollSearchRequestParam InfoCodes + InvalidScrollSearchRequestParam InfoCodes + StopWarmerRequests InfoCodes +} + +var InfoCodesValues = infoCodesValuesType{ + // Everything ok with the result. + Ok: "ok", + // Account is being re-indexed. Do not use this for fault-in scenarios; use AccountIsBeingOnboarded instead. + AccountIsBeingReindexed: "accountIsBeingReindexed", + // Indexing is not started yet for the collection + IndexingNotStarted: "indexingNotStarted", + // Invalid request + InvalidRequest: "invalidRequest", + // Search text containing prefix wildcard code term is not supported. + PrefixWildcardQueryNotSupported: "prefixWildcardQueryNotSupported", + // Multi Word Search text with code facet is not supported. + MultiWordWithCodeFacetNotSupported: "multiWordWithCodeFacetNotSupported", + // Account is being onboarded. This is similar to AccountIsBeingReindexed except that this is used only when the collection is faulted-in for the first time in search service. + AccountIsBeingOnboarded: "accountIsBeingOnboarded", + // $top Value is more than the value allowed in one fetch. $top is truncated as specified value exceeds the limit. + TakeResultValueTrimmedToMaxResultAllowed: "takeResultValueTrimmedToMaxResultAllowed", + // One or more branches in the collection are being indexed. + BranchesAreBeingIndexed: "branchesAreBeingIndexed", + // IncludeFacets is true but facets support is disabled for this deployment. + FacetingNotEnabledAtScaleUnit: "facetingNotEnabledAtScaleUnit", + // User has no permissions. + WorkItemsNotAccessible: "workItemsNotAccessible", + // When Search query contains only operators (i.e. [, ], (, ), :, ", ?, *) it is converted to empty expression and no results are fetched for them. [Todo:ManasaP] [Task 1163307] Once we have suggestions supported as part of the response, remove this info code. + EmptyQueryNotSupported: "emptyQueryNotSupported", + // When Search query contains only wildcard chars (ex: ***, *?, ??) + OnlyWildcardQueryNotSupported: "onlyWildcardQueryNotSupported", + // When Search query fetches zero results with wildcard in it + ZeroResultsWithWildcard: "zeroResultsWithWildcard", + // When Search query fetches zero results and has filters + ZeroResultsWithFilter: "zeroResultsWithFilter", + // When Search query fetches zero results and has wildcard and filter + ZeroResultsWithWildcardAndFilter: "zeroResultsWithWildcardAndFilter", + // When Search query fetches zero results and has no wildcard or filter + ZeroResultsWithNoWildcardNoFilter: "zeroResultsWithNoWildcardNoFilter", + // When Search request times out and hence potentially gives partial results + PartialResultsDueToSearchRequestTimeout: "partialResultsDueToSearchRequestTimeout", + // Phrase queries with code facet is not supported. + PhraseQueriesWithCEFacetsNotSupported: "phraseQueriesWithCEFacetsNotSupported", + // Wildcard queries with code facet is not supported. + WildcardQueriesWithCEFacetsNotSupported: "wildcardQueriesWithCEFacetsNotSupported", + // When Scroll Search Request returns count of zero we will clear the scroll. + ClearedScrollSearchRequestParam: "clearedScrollSearchRequestParam", + // When Scroll Search Request has an invalid scroll id value. + InvalidScrollSearchRequestParam: "invalidScrollSearchRequestParam", + // For Stopping warmer requests + StopWarmerRequests: "stopWarmerRequests", +} + +// Defines the matched terms in the field of the package result. +type PackageHit struct { + // Reference name of the highlighted field. + FieldReferenceName *string `json:"fieldReferenceName,omitempty"` + // Matched/highlighted snippets of the field. + Highlights *[]string `json:"highlights,omitempty"` +} + +// Defines the package result that matched a package search request. +type PackageResult struct { + // Description of the package. + Description *string `json:"description,omitempty"` + // List of feeds which contain the matching package. + Feeds *[]FeedInfo `json:"feeds,omitempty"` + // List of highlighted fields for the match. + Hits *[]PackageHit `json:"hits,omitempty"` + // Id of the package. + Id *string `json:"id,omitempty"` + // Name of the package. + Name *string `json:"name,omitempty"` + // Type of the package. + ProtocolType *string `json:"protocolType,omitempty"` +} + +// Defines a package search request. +type PackageSearchRequest struct { + // Filters to be applied. Set it to null if there are no filters to be applied. + Filters *map[string][]string `json:"filters,omitempty"` + // The search text. + SearchText *string `json:"searchText,omitempty"` + // Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + OrderBy *[]SortOption `json:"$orderBy,omitempty"` + // Number of results to be skipped. + Skip *int `json:"$skip,omitempty"` + // Number of results to be returned. + Top *int `json:"$top,omitempty"` + // Flag to opt for faceting in the result. Default behavior is false. + IncludeFacets *bool `json:"includeFacets,omitempty"` +} + +type PackageSearchResponse struct { + ActivityId *[]string `json:"activityId,omitempty"` + Content *PackageSearchResponseContent `json:"content,omitempty"` +} + +// Defines a response item that is returned for a package search request. +type PackageSearchResponseContent struct { + // A dictionary storing an array of Filter object against each facet. + Facets *map[string][]Filter `json:"facets,omitempty"` + // Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + InfoCode *int `json:"infoCode,omitempty"` + // Total number of matched packages. + Count *int `json:"count,omitempty"` + // List of matched packages. + Results *[]PackageResult `json:"results,omitempty"` +} + +// Defines the details of the project. +type ProjectReference struct { + // ID of the project. + Id *uuid.UUID `json:"id,omitempty"` + // Name of the project. + Name *string `json:"name,omitempty"` + // Visibility of the project. + Visibility *string `json:"visibility,omitempty"` +} + +// Defines the details of the repository. +type Repository struct { + // Id of the repository. + Id *string `json:"id,omitempty"` + // Name of the repository. + Name *string `json:"name,omitempty"` + // Version control type of the result file. + Type *VersionControlType `json:"type,omitempty"` +} + +// Defines a scroll code search request. +type ScrollSearchRequest struct { + // Filters to be applied. Set it to null if there are no filters to be applied. + Filters *map[string][]string `json:"filters,omitempty"` + // The search text. + SearchText *string `json:"searchText,omitempty"` + // Scroll Id for scroll search query. + ScrollId *string `json:"$scrollId,omitempty"` + // Size of data to return for scroll search query. Min value is 201. + ScrollSize *int `json:"$scrollSize,omitempty"` +} + +// Defines how to sort the result. +type SortOption struct { + // Field name on which sorting should be done. + Field *string `json:"field,omitempty"` + // Order (ASC/DESC) in which the results should be sorted. + SortOrder *string `json:"sortOrder,omitempty"` +} + +type SortOrder string + +type sortOrderValuesType struct { + Undefined SortOrder + Ascending SortOrder + Descending SortOrder +} + +var SortOrderValues = sortOrderValuesType{ + Undefined: "undefined", + Ascending: "ascending", + Descending: "descending", +} + +// Describes the details pertaining to a version of the result file. +type Version struct { + // Name of the branch. + BranchName *string `json:"branchName,omitempty"` + // ChangeId in the given branch associated with this match. + ChangeId *string `json:"changeId,omitempty"` +} + +// Version control of the repository. +type VersionControlType string + +type versionControlTypeValuesType struct { + Git VersionControlType + Tfvc VersionControlType + Custom VersionControlType +} + +var VersionControlTypeValues = versionControlTypeValuesType{ + Git: "git", + Tfvc: "tfvc", + // For internal use. + Custom: "custom", +} + +// Defines the details of wiki. +type Wiki struct { + // Id of the wiki. + Id *string `json:"id,omitempty"` + // Mapped path for the wiki. + MappedPath *string `json:"mappedPath,omitempty"` + // Name of the wiki. + Name *string `json:"name,omitempty"` + // Version for wiki. + Version *string `json:"version,omitempty"` +} + +// Defines the matched terms in the field of the wiki result. +type WikiHit struct { + // Reference name of the highlighted field. + FieldReferenceName *string `json:"fieldReferenceName,omitempty"` + // Matched/highlighted snippets of the field. + Highlights *[]string `json:"highlights,omitempty"` +} + +// Defines the wiki result that matched a wiki search request. +type WikiResult struct { + // Collection of the result file. + Collection *Collection `json:"collection,omitempty"` + // ContentId of the result file. + ContentId *string `json:"contentId,omitempty"` + // Name of the result file. + FileName *string `json:"fileName,omitempty"` + // Highlighted snippets of fields that match the search request. The list is sorted by relevance of the snippets. + Hits *[]WikiHit `json:"hits,omitempty"` + // Path at which result file is present. + Path *string `json:"path,omitempty"` + // Project details of the wiki document. + Project *ProjectReference `json:"project,omitempty"` + // Wiki information for the result. + Wiki *Wiki `json:"wiki,omitempty"` +} + +// Defines a wiki search request. +type WikiSearchRequest struct { + // Filters to be applied. Set it to null if there are no filters to be applied. + Filters *map[string][]string `json:"filters,omitempty"` + // The search text. + SearchText *string `json:"searchText,omitempty"` + // Options for sorting search results. If set to null, the results will be returned sorted by relevance. If more than one sort option is provided, the results are sorted in the order specified in the OrderBy. + OrderBy *[]SortOption `json:"$orderBy,omitempty"` + // Number of results to be skipped. + Skip *int `json:"$skip,omitempty"` + // Number of results to be returned. + Top *int `json:"$top,omitempty"` + // Flag to opt for faceting in the result. Default behavior is false. + IncludeFacets *bool `json:"includeFacets,omitempty"` +} + +// Defines a wiki search response item. +type WikiSearchResponse struct { + // A dictionary storing an array of Filter object against each facet. + Facets *map[string][]Filter `json:"facets,omitempty"` + // Numeric code indicating any additional information: 0 - Ok, 1 - Account is being reindexed, 2 - Account indexing has not started, 3 - Invalid Request, 4 - Prefix wildcard query not supported, 5 - MultiWords with code facet not supported, 6 - Account is being onboarded, 7 - Account is being onboarded or reindexed, 8 - Top value trimmed to maxresult allowed 9 - Branches are being indexed, 10 - Faceting not enabled, 11 - Work items not accessible, 19 - Phrase queries with code type filters not supported, 20 - Wildcard queries with code type filters not supported. Any other info code is used for internal purpose. + InfoCode *int `json:"infoCode,omitempty"` + // Total number of matched wiki documents. + Count *int `json:"count,omitempty"` + // List of top matched wiki documents. + Results *[]WikiResult `json:"results,omitempty"` +} diff --git a/azuredevops/security/client.go b/azuredevops/security/client.go new file mode 100644 index 00000000..16af49d4 --- /dev/null +++ b/azuredevops/security/client.go @@ -0,0 +1,380 @@ +// -------------------------------------------------------------------------------------------- +// 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 security + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" +) + +type Client interface { + // Evaluates whether the caller has the specified permissions on the specified set of security tokens. + HasPermissions(context.Context, HasPermissionsArgs) (*[]bool, error) + // Evaluates multiple permissions for the calling user. Note: This method does not aggregate the results, nor does it short-circuit if one of the permissions evaluates to false. + HasPermissionsBatch(context.Context, HasPermissionsBatchArgs) (*PermissionEvaluationBatch, error) + // Return a list of access control lists for the specified security namespace and token. All ACLs in the security namespace will be retrieved if no optional parameters are provided. + QueryAccessControlLists(context.Context, QueryAccessControlListsArgs) (*[]AccessControlList, error) + // List all security namespaces or just the specified namespace. + QuerySecurityNamespaces(context.Context, QuerySecurityNamespacesArgs) (*[]SecurityNamespaceDescription, error) + // Remove the specified ACEs from the ACL belonging to the specified token. + RemoveAccessControlEntries(context.Context, RemoveAccessControlEntriesArgs) (*bool, error) + // Remove access control lists under the specfied security namespace. + RemoveAccessControlLists(context.Context, RemoveAccessControlListsArgs) (*bool, error) + // Removes the specified permissions on a security token for a user or group. + RemovePermission(context.Context, RemovePermissionArgs) (*AccessControlEntry, error) + // Add or update ACEs in the ACL for the provided token. The request body contains the target token, a list of [ACEs](https://docs.microsoft.com/en-us/rest/api/azure/devops/security/access%20control%20entries/set%20access%20control%20entries?#accesscontrolentry) and a optional merge parameter. In the case of a collision (by identity descriptor) with an existing ACE in the ACL, the "merge" parameter determines the behavior. If set, the existing ACE has its allow and deny merged with the incoming ACE's allow and deny. If unset, the existing ACE is displaced. + SetAccessControlEntries(context.Context, SetAccessControlEntriesArgs) (*[]AccessControlEntry, error) + // Create or update one or more access control lists. All data that currently exists for the ACLs supplied will be overwritten. + SetAccessControlLists(context.Context, SetAccessControlListsArgs) 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, + } +} + +// Evaluates whether the caller has the specified permissions on the specified set of security tokens. +func (client *ClientImpl) HasPermissions(ctx context.Context, args HasPermissionsArgs) (*[]bool, error) { + routeValues := make(map[string]string) + if args.SecurityNamespaceId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SecurityNamespaceId"} + } + routeValues["securityNamespaceId"] = (*args.SecurityNamespaceId).String() + if args.Permissions != nil { + routeValues["permissions"] = strconv.Itoa(*args.Permissions) + } + + queryParams := url.Values{} + if args.Tokens != nil { + queryParams.Add("tokens", *args.Tokens) + } + if args.AlwaysAllowAdministrators != nil { + queryParams.Add("alwaysAllowAdministrators", strconv.FormatBool(*args.AlwaysAllowAdministrators)) + } + if args.Delimiter != nil { + queryParams.Add("delimiter", *args.Delimiter) + } + locationId, _ := uuid.Parse("dd3b8bd6-c7fc-4cbd-929a-933d9c011c9d") + 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 []bool + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the HasPermissions function +type HasPermissionsArgs struct { + // (required) Security namespace identifier. + SecurityNamespaceId *uuid.UUID + // (optional) Permissions to evaluate. + Permissions *int + // (optional) One or more security tokens to evaluate. + Tokens *string + // (optional) If true and if the caller is an administrator, always return true. + AlwaysAllowAdministrators *bool + // (optional) Optional security token separator. Defaults to ",". + Delimiter *string +} + +// Evaluates multiple permissions for the calling user. Note: This method does not aggregate the results, nor does it short-circuit if one of the permissions evaluates to false. +func (client *ClientImpl) HasPermissionsBatch(ctx context.Context, args HasPermissionsBatchArgs) (*PermissionEvaluationBatch, error) { + if args.EvalBatch == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EvalBatch"} + } + body, marshalErr := json.Marshal(*args.EvalBatch) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("cf1faa59-1b63-4448-bf04-13d981a46f5d") + 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 PermissionEvaluationBatch + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the HasPermissionsBatch function +type HasPermissionsBatchArgs struct { + // (required) The set of evaluation requests. + EvalBatch *PermissionEvaluationBatch +} + +// Return a list of access control lists for the specified security namespace and token. All ACLs in the security namespace will be retrieved if no optional parameters are provided. +func (client *ClientImpl) QueryAccessControlLists(ctx context.Context, args QueryAccessControlListsArgs) (*[]AccessControlList, error) { + routeValues := make(map[string]string) + if args.SecurityNamespaceId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SecurityNamespaceId"} + } + routeValues["securityNamespaceId"] = (*args.SecurityNamespaceId).String() + + queryParams := url.Values{} + if args.Token != nil { + queryParams.Add("token", *args.Token) + } + if args.Descriptors != nil { + queryParams.Add("descriptors", *args.Descriptors) + } + if args.IncludeExtendedInfo != nil { + queryParams.Add("includeExtendedInfo", strconv.FormatBool(*args.IncludeExtendedInfo)) + } + if args.Recurse != nil { + queryParams.Add("recurse", strconv.FormatBool(*args.Recurse)) + } + locationId, _ := uuid.Parse("18a2ad18-7571-46ae-bec7-0c7da1495885") + 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 []AccessControlList + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryAccessControlLists function +type QueryAccessControlListsArgs struct { + // (required) Security namespace identifier. + SecurityNamespaceId *uuid.UUID + // (optional) Security token + Token *string + // (optional) An optional filter string containing a list of identity descriptors separated by ',' whose ACEs should be retrieved. If this is left null, entire ACLs will be returned. + Descriptors *string + // (optional) If true, populate the extended information properties for the access control entries contained in the returned lists. + IncludeExtendedInfo *bool + // (optional) If true and this is a hierarchical namespace, return child ACLs of the specified token. + Recurse *bool +} + +// List all security namespaces or just the specified namespace. +func (client *ClientImpl) QuerySecurityNamespaces(ctx context.Context, args QuerySecurityNamespacesArgs) (*[]SecurityNamespaceDescription, error) { + routeValues := make(map[string]string) + if args.SecurityNamespaceId != nil { + routeValues["securityNamespaceId"] = (*args.SecurityNamespaceId).String() + } + + queryParams := url.Values{} + if args.LocalOnly != nil { + queryParams.Add("localOnly", strconv.FormatBool(*args.LocalOnly)) + } + locationId, _ := uuid.Parse("ce7b9f95-fde9-4be8-a86d-83b366f0b87a") + 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 []SecurityNamespaceDescription + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QuerySecurityNamespaces function +type QuerySecurityNamespacesArgs struct { + // (optional) Security namespace identifier. + SecurityNamespaceId *uuid.UUID + // (optional) If true, retrieve only local security namespaces. + LocalOnly *bool +} + +// Remove the specified ACEs from the ACL belonging to the specified token. +func (client *ClientImpl) RemoveAccessControlEntries(ctx context.Context, args RemoveAccessControlEntriesArgs) (*bool, error) { + routeValues := make(map[string]string) + if args.SecurityNamespaceId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SecurityNamespaceId"} + } + routeValues["securityNamespaceId"] = (*args.SecurityNamespaceId).String() + + queryParams := url.Values{} + if args.Token != nil { + queryParams.Add("token", *args.Token) + } + if args.Descriptors != nil { + queryParams.Add("descriptors", *args.Descriptors) + } + locationId, _ := uuid.Parse("ac08c8ff-4323-4b08-af90-bcd018d380ce") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, queryParams, 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 RemoveAccessControlEntries function +type RemoveAccessControlEntriesArgs struct { + // (required) Security namespace identifier. + SecurityNamespaceId *uuid.UUID + // (optional) The token whose ACL should be modified. + Token *string + // (optional) String containing a list of identity descriptors separated by ',' whose entries should be removed. + Descriptors *string +} + +// Remove access control lists under the specfied security namespace. +func (client *ClientImpl) RemoveAccessControlLists(ctx context.Context, args RemoveAccessControlListsArgs) (*bool, error) { + routeValues := make(map[string]string) + if args.SecurityNamespaceId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SecurityNamespaceId"} + } + routeValues["securityNamespaceId"] = (*args.SecurityNamespaceId).String() + + queryParams := url.Values{} + if args.Tokens != nil { + queryParams.Add("tokens", *args.Tokens) + } + if args.Recurse != nil { + queryParams.Add("recurse", strconv.FormatBool(*args.Recurse)) + } + locationId, _ := uuid.Parse("18a2ad18-7571-46ae-bec7-0c7da1495885") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, queryParams, 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 RemoveAccessControlLists function +type RemoveAccessControlListsArgs struct { + // (required) Security namespace identifier. + SecurityNamespaceId *uuid.UUID + // (optional) One or more comma-separated security tokens + Tokens *string + // (optional) If true and this is a hierarchical namespace, also remove child ACLs of the specified tokens. + Recurse *bool +} + +// Removes the specified permissions on a security token for a user or group. +func (client *ClientImpl) RemovePermission(ctx context.Context, args RemovePermissionArgs) (*AccessControlEntry, error) { + routeValues := make(map[string]string) + if args.SecurityNamespaceId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SecurityNamespaceId"} + } + routeValues["securityNamespaceId"] = (*args.SecurityNamespaceId).String() + if args.Permissions != nil { + routeValues["permissions"] = strconv.Itoa(*args.Permissions) + } + + queryParams := url.Values{} + if args.Descriptor == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "descriptor"} + } + queryParams.Add("descriptor", *args.Descriptor) + if args.Token != nil { + queryParams.Add("token", *args.Token) + } + locationId, _ := uuid.Parse("dd3b8bd6-c7fc-4cbd-929a-933d9c011c9d") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue AccessControlEntry + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the RemovePermission function +type RemovePermissionArgs struct { + // (required) Security namespace identifier. + SecurityNamespaceId *uuid.UUID + // (required) Identity descriptor of the user to remove permissions for. + Descriptor *string + // (optional) Permissions to remove. + Permissions *int + // (optional) Security token to remove permissions for. + Token *string +} + +// Add or update ACEs in the ACL for the provided token. The request body contains the target token, a list of [ACEs](https://docs.microsoft.com/en-us/rest/api/azure/devops/security/access%20control%20entries/set%20access%20control%20entries?#accesscontrolentry) and a optional merge parameter. In the case of a collision (by identity descriptor) with an existing ACE in the ACL, the "merge" parameter determines the behavior. If set, the existing ACE has its allow and deny merged with the incoming ACE's allow and deny. If unset, the existing ACE is displaced. +func (client *ClientImpl) SetAccessControlEntries(ctx context.Context, args SetAccessControlEntriesArgs) (*[]AccessControlEntry, error) { + if args.Container == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Container"} + } + routeValues := make(map[string]string) + if args.SecurityNamespaceId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SecurityNamespaceId"} + } + routeValues["securityNamespaceId"] = (*args.SecurityNamespaceId).String() + + body, marshalErr := json.Marshal(args.Container) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ac08c8ff-4323-4b08-af90-bcd018d380ce") + 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 []AccessControlEntry + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the SetAccessControlEntries function +type SetAccessControlEntriesArgs struct { + // (required) + Container interface{} + // (required) Security namespace identifier. + SecurityNamespaceId *uuid.UUID +} + +// Create or update one or more access control lists. All data that currently exists for the ACLs supplied will be overwritten. +func (client *ClientImpl) SetAccessControlLists(ctx context.Context, args SetAccessControlListsArgs) error { + if args.AccessControlLists == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.AccessControlLists"} + } + routeValues := make(map[string]string) + if args.SecurityNamespaceId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.SecurityNamespaceId"} + } + routeValues["securityNamespaceId"] = (*args.SecurityNamespaceId).String() + + body, marshalErr := json.Marshal(*args.AccessControlLists) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("18a2ad18-7571-46ae-bec7-0c7da1495885") + _, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the SetAccessControlLists function +type SetAccessControlListsArgs struct { + // (required) A list of ACLs to create or update. + AccessControlLists *azuredevops.VssJsonCollectionWrapper + // (required) Security namespace identifier. + SecurityNamespaceId *uuid.UUID +} diff --git a/azuredevops/security/models.go b/azuredevops/security/models.go new file mode 100644 index 00000000..7341ebcc --- /dev/null +++ b/azuredevops/security/models.go @@ -0,0 +1,116 @@ +// -------------------------------------------------------------------------------------------- +// 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 security + +import ( + "github.com/google/uuid" +) + +// Class for encapsulating the allowed and denied permissions for a given IdentityDescriptor. +type AccessControlEntry struct { + // The set of permission bits that represent the actions that the associated descriptor is allowed to perform. + Allow *int `json:"allow,omitempty"` + // The set of permission bits that represent the actions that the associated descriptor is not allowed to perform. + Deny *int `json:"deny,omitempty"` + // The descriptor for the user this AccessControlEntry applies to. + Descriptor *string `json:"descriptor,omitempty"` + // This value, when set, reports the inherited and effective information for the associated descriptor. This value is only set on AccessControlEntries returned by the QueryAccessControlList(s) call when its includeExtendedInfo parameter is set to true. + ExtendedInfo *AceExtendedInformation `json:"extendedInfo,omitempty"` +} + +// The AccessControlList class is meant to associate a set of AccessControlEntries with a security token and its inheritance settings. +type AccessControlList struct { + // Storage of permissions keyed on the identity the permission is for. + AcesDictionary *map[string]AccessControlEntry `json:"acesDictionary,omitempty"` + // True if this ACL holds ACEs that have extended information. + IncludeExtendedInfo *bool `json:"includeExtendedInfo,omitempty"` + // True if the given token inherits permissions from parents. + InheritPermissions *bool `json:"inheritPermissions,omitempty"` + // The token that this AccessControlList is for. + Token *string `json:"token,omitempty"` +} + +// A list of AccessControlList. An AccessControlList is meant to associate a set of AccessControlEntries with a security token and its inheritance settings. +type AccessControlListsCollection struct { +} + +// Holds the inherited and effective permission information for a given AccessControlEntry. +type AceExtendedInformation struct { + // This is the combination of all of the explicit and inherited permissions for this identity on this token. These are the permissions used when determining if a given user has permission to perform an action. + EffectiveAllow *int `json:"effectiveAllow,omitempty"` + // This is the combination of all of the explicit and inherited permissions for this identity on this token. These are the permissions used when determining if a given user has permission to perform an action. + EffectiveDeny *int `json:"effectiveDeny,omitempty"` + // These are the permissions that are inherited for this identity on this token. If the token does not inherit permissions this will be 0. Note that any permissions that have been explicitly set on this token for this identity, or any groups that this identity is a part of, are not included here. + InheritedAllow *int `json:"inheritedAllow,omitempty"` + // These are the permissions that are inherited for this identity on this token. If the token does not inherit permissions this will be 0. Note that any permissions that have been explicitly set on this token for this identity, or any groups that this identity is a part of, are not included here. + InheritedDeny *int `json:"inheritedDeny,omitempty"` +} + +type ActionDefinition struct { + // The bit mask integer for this action. Must be a power of 2. + Bit *int `json:"bit,omitempty"` + // The localized display name for this action. + DisplayName *string `json:"displayName,omitempty"` + // The non-localized name for this action. + Name *string `json:"name,omitempty"` + // The namespace that this action belongs to. This will only be used for reading from the database. + NamespaceId *uuid.UUID `json:"namespaceId,omitempty"` +} + +// Represents an evaluated permission. +type PermissionEvaluation struct { + // Permission bit for this evaluated permission. + Permissions *int `json:"permissions,omitempty"` + // Security namespace identifier for this evaluated permission. + SecurityNamespaceId *uuid.UUID `json:"securityNamespaceId,omitempty"` + // Security namespace-specific token for this evaluated permission. + Token *string `json:"token,omitempty"` + // Permission evaluation value. + Value *bool `json:"value,omitempty"` +} + +// Represents a set of evaluated permissions. +type PermissionEvaluationBatch struct { + // True if members of the Administrators group should always pass the security check. + AlwaysAllowAdministrators *bool `json:"alwaysAllowAdministrators,omitempty"` + // Array of permission evaluations to evaluate. + Evaluations *[]PermissionEvaluation `json:"evaluations,omitempty"` +} + +// Class for describing the details of a TeamFoundationSecurityNamespace. +type SecurityNamespaceDescription struct { + // The list of actions that this Security Namespace is responsible for securing. + Actions *[]ActionDefinition `json:"actions,omitempty"` + // This is the dataspace category that describes where the security information for this SecurityNamespace should be stored. + DataspaceCategory *string `json:"dataspaceCategory,omitempty"` + // This localized name for this namespace. + DisplayName *string `json:"displayName,omitempty"` + // If the security tokens this namespace will be operating on need to be split on certain character lengths to determine its elements, that length should be specified here. If not, this value will be -1. + ElementLength *int `json:"elementLength,omitempty"` + // This is the type of the extension that should be loaded from the plugins directory for extending this security namespace. + ExtensionType *string `json:"extensionType,omitempty"` + // If true, the security namespace is remotable, allowing another service to proxy the namespace. + IsRemotable *bool `json:"isRemotable,omitempty"` + // This non-localized for this namespace. + Name *string `json:"name,omitempty"` + // The unique identifier for this namespace. + NamespaceId *uuid.UUID `json:"namespaceId,omitempty"` + // The permission bits needed by a user in order to read security data on the Security Namespace. + ReadPermission *int `json:"readPermission,omitempty"` + // If the security tokens this namespace will be operating on need to be split on certain characters to determine its elements that character should be specified here. If not, this value will be the null character. + SeparatorValue *string `json:"separatorValue,omitempty"` + // Used to send information about the structure of the security namespace over the web service. + StructureValue *int `json:"structureValue,omitempty"` + // The bits reserved by system store + SystemBitMask *int `json:"systemBitMask,omitempty"` + // If true, the security service will expect an ISecurityDataspaceTokenTranslator plugin to exist for this namespace + UseTokenTranslator *bool `json:"useTokenTranslator,omitempty"` + // The permission bits needed by a user in order to modify security data on the Security Namespace. + WritePermission *int `json:"writePermission,omitempty"` +} diff --git a/azuredevops/serviceendpoint/client.go b/azuredevops/serviceendpoint/client.go new file mode 100644 index 00000000..71261970 --- /dev/null +++ b/azuredevops/serviceendpoint/client.go @@ -0,0 +1,480 @@ +// -------------------------------------------------------------------------------------------- +// 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 serviceendpoint + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("1814ab31-2f4f-4a9f-8761-f4d77dc5a5d7") + +type Client interface { + // [Preview API] Create a service endpoint. + CreateServiceEndpoint(context.Context, CreateServiceEndpointArgs) (*ServiceEndpoint, error) + // [Preview API] Delete a service endpoint. + DeleteServiceEndpoint(context.Context, DeleteServiceEndpointArgs) error + // [Preview API] Proxy for a GET request defined by a service endpoint. + ExecuteServiceEndpointRequest(context.Context, ExecuteServiceEndpointRequestArgs) (*ServiceEndpointRequestResult, error) + // [Preview API] Get the service endpoint details. + GetServiceEndpointDetails(context.Context, GetServiceEndpointDetailsArgs) (*ServiceEndpoint, error) + // [Preview API] Get service endpoint execution records. + GetServiceEndpointExecutionRecords(context.Context, GetServiceEndpointExecutionRecordsArgs) (*GetServiceEndpointExecutionRecordsResponseValue, error) + // [Preview API] Get the service endpoints. + GetServiceEndpoints(context.Context, GetServiceEndpointsArgs) (*[]ServiceEndpoint, error) + // [Preview API] Get the service endpoints by name. + GetServiceEndpointsByNames(context.Context, GetServiceEndpointsByNamesArgs) (*[]ServiceEndpoint, error) + // [Preview API] Get service endpoint types. + GetServiceEndpointTypes(context.Context, GetServiceEndpointTypesArgs) (*[]ServiceEndpointType, error) + // [Preview API] Update a service endpoint. + UpdateServiceEndpoint(context.Context, UpdateServiceEndpointArgs) (*ServiceEndpoint, error) + // [Preview API] Update the service endpoints. + UpdateServiceEndpoints(context.Context, UpdateServiceEndpointsArgs) (*[]ServiceEndpoint, 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 a service endpoint. +func (client *ClientImpl) CreateServiceEndpoint(ctx context.Context, args CreateServiceEndpointArgs) (*ServiceEndpoint, error) { + if args.Endpoint == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Endpoint"} + } + 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.Endpoint) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e85f1c62-adfc-4b74-b618-11a150fb195e") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ServiceEndpoint + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateServiceEndpoint function +type CreateServiceEndpointArgs struct { + // (required) Service endpoint to create. + Endpoint *ServiceEndpoint + // (required) Project ID or project name + Project *string +} + +// [Preview API] Delete a service endpoint. +func (client *ClientImpl) DeleteServiceEndpoint(ctx context.Context, args DeleteServiceEndpointArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.EndpointId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.EndpointId"} + } + routeValues["endpointId"] = (*args.EndpointId).String() + + queryParams := url.Values{} + if args.Deep != nil { + queryParams.Add("deep", strconv.FormatBool(*args.Deep)) + } + locationId, _ := uuid.Parse("e85f1c62-adfc-4b74-b618-11a150fb195e") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteServiceEndpoint function +type DeleteServiceEndpointArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the service endpoint to delete. + EndpointId *uuid.UUID + // (optional) Specific to AzureRM endpoint created in Automatic flow. When set to true, this will also delete corresponding AAD application in Azure. Default value is true. + Deep *bool +} + +// [Preview API] Proxy for a GET request defined by a service endpoint. +func (client *ClientImpl) ExecuteServiceEndpointRequest(ctx context.Context, args ExecuteServiceEndpointRequestArgs) (*ServiceEndpointRequestResult, error) { + if args.ServiceEndpointRequest == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ServiceEndpointRequest"} + } + 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.EndpointId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "endpointId"} + } + queryParams.Add("endpointId", *args.EndpointId) + body, marshalErr := json.Marshal(*args.ServiceEndpointRequest) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("cc63bb57-2a5f-4a7a-b79c-c142d308657e") + 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 ServiceEndpointRequestResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ExecuteServiceEndpointRequest function +type ExecuteServiceEndpointRequestArgs struct { + // (required) Service endpoint request. + ServiceEndpointRequest *ServiceEndpointRequest + // (required) Project ID or project name + Project *string + // (required) Id of the service endpoint. + EndpointId *string +} + +// [Preview API] Get the service endpoint details. +func (client *ClientImpl) GetServiceEndpointDetails(ctx context.Context, args GetServiceEndpointDetailsArgs) (*ServiceEndpoint, 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.EndpointId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EndpointId"} + } + routeValues["endpointId"] = (*args.EndpointId).String() + + locationId, _ := uuid.Parse("e85f1c62-adfc-4b74-b618-11a150fb195e") + 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 ServiceEndpoint + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetServiceEndpointDetails function +type GetServiceEndpointDetailsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the service endpoint. + EndpointId *uuid.UUID +} + +// [Preview API] Get service endpoint execution records. +func (client *ClientImpl) GetServiceEndpointExecutionRecords(ctx context.Context, args GetServiceEndpointExecutionRecordsArgs) (*GetServiceEndpointExecutionRecordsResponseValue, 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.EndpointId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EndpointId"} + } + routeValues["endpointId"] = (*args.EndpointId).String() + + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", strconv.FormatUint(*args.ContinuationToken, 10)) + } + locationId, _ := uuid.Parse("10a16738-9299-4cd1-9a81-fd23ad6200d0") + 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 GetServiceEndpointExecutionRecordsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetServiceEndpointExecutionRecords function +type GetServiceEndpointExecutionRecordsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the service endpoint. + EndpointId *uuid.UUID + // (optional) Number of service endpoint execution records to get. + Top *int + // (optional) A continuation token, returned by a previous call to this method, that can be used to return the next set of records + ContinuationToken *uint64 +} + +// Return type for the GetServiceEndpointExecutionRecords function +type GetServiceEndpointExecutionRecordsResponseValue struct { + Value []ServiceEndpointExecutionRecord + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get the service endpoints. +func (client *ClientImpl) GetServiceEndpoints(ctx context.Context, args GetServiceEndpointsArgs) (*[]ServiceEndpoint, 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.Type != nil { + queryParams.Add("type", *args.Type) + } + if args.AuthSchemes != nil { + listAsString := strings.Join((*args.AuthSchemes)[:], ",") + queryParams.Add("authSchemes", listAsString) + } + if args.EndpointIds != nil { + var stringList []string + for _, item := range *args.EndpointIds { + stringList = append(stringList, item.String()) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("endpointIds", listAsString) + } + if args.Owner != nil { + queryParams.Add("owner", *args.Owner) + } + if args.IncludeFailed != nil { + queryParams.Add("includeFailed", strconv.FormatBool(*args.IncludeFailed)) + } + if args.IncludeDetails != nil { + queryParams.Add("includeDetails", strconv.FormatBool(*args.IncludeDetails)) + } + locationId, _ := uuid.Parse("e85f1c62-adfc-4b74-b618-11a150fb195e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []ServiceEndpoint + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetServiceEndpoints function +type GetServiceEndpointsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Type of the service endpoints. + Type *string + // (optional) Authorization schemes used for service endpoints. + AuthSchemes *[]string + // (optional) Ids of the service endpoints. + EndpointIds *[]uuid.UUID + // (optional) Owner for service endpoints. + Owner *string + // (optional) Failed flag for service endpoints. + IncludeFailed *bool + // (optional) Flag to include more details for service endpoints. This is for internal use only and the flag will be treated as false for all other requests + IncludeDetails *bool +} + +// [Preview API] Get the service endpoints by name. +func (client *ClientImpl) GetServiceEndpointsByNames(ctx context.Context, args GetServiceEndpointsByNamesArgs) (*[]ServiceEndpoint, 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.EndpointNames == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "endpointNames"} + } + listAsString := strings.Join((*args.EndpointNames)[:], ",") + queryParams.Add("endpointNames", listAsString) + if args.Type != nil { + queryParams.Add("type", *args.Type) + } + if args.AuthSchemes != nil { + listAsString := strings.Join((*args.AuthSchemes)[:], ",") + queryParams.Add("authSchemes", listAsString) + } + if args.Owner != nil { + queryParams.Add("owner", *args.Owner) + } + if args.IncludeFailed != nil { + queryParams.Add("includeFailed", strconv.FormatBool(*args.IncludeFailed)) + } + if args.IncludeDetails != nil { + queryParams.Add("includeDetails", strconv.FormatBool(*args.IncludeDetails)) + } + locationId, _ := uuid.Parse("e85f1c62-adfc-4b74-b618-11a150fb195e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []ServiceEndpoint + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetServiceEndpointsByNames function +type GetServiceEndpointsByNamesArgs struct { + // (required) Project ID or project name + Project *string + // (required) Names of the service endpoints. + EndpointNames *[]string + // (optional) Type of the service endpoints. + Type *string + // (optional) Authorization schemes used for service endpoints. + AuthSchemes *[]string + // (optional) Owner for service endpoints. + Owner *string + // (optional) Failed flag for service endpoints. + IncludeFailed *bool + // (optional) Flag to include more details for service endpoints. This is for internal use only and the flag will be treated as false for all other requests + IncludeDetails *bool +} + +// [Preview API] Get service endpoint types. +func (client *ClientImpl) GetServiceEndpointTypes(ctx context.Context, args GetServiceEndpointTypesArgs) (*[]ServiceEndpointType, error) { + queryParams := url.Values{} + if args.Type != nil { + queryParams.Add("type", *args.Type) + } + if args.Scheme != nil { + queryParams.Add("scheme", *args.Scheme) + } + locationId, _ := uuid.Parse("5a7938a4-655e-486c-b562-b78c54a7e87b") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []ServiceEndpointType + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetServiceEndpointTypes function +type GetServiceEndpointTypesArgs struct { + // (optional) Type of service endpoint. + Type *string + // (optional) Scheme of service endpoint. + Scheme *string +} + +// [Preview API] Update a service endpoint. +func (client *ClientImpl) UpdateServiceEndpoint(ctx context.Context, args UpdateServiceEndpointArgs) (*ServiceEndpoint, error) { + if args.Endpoint == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Endpoint"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.EndpointId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EndpointId"} + } + routeValues["endpointId"] = (*args.EndpointId).String() + + queryParams := url.Values{} + if args.Operation != nil { + queryParams.Add("operation", *args.Operation) + } + body, marshalErr := json.Marshal(*args.Endpoint) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e85f1c62-adfc-4b74-b618-11a150fb195e") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.2", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ServiceEndpoint + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateServiceEndpoint function +type UpdateServiceEndpointArgs struct { + // (required) Service endpoint to update. + Endpoint *ServiceEndpoint + // (required) Project ID or project name + Project *string + // (required) Id of the service endpoint to update. + EndpointId *uuid.UUID + // (optional) Operation for the service endpoint. + Operation *string +} + +// [Preview API] Update the service endpoints. +func (client *ClientImpl) UpdateServiceEndpoints(ctx context.Context, args UpdateServiceEndpointsArgs) (*[]ServiceEndpoint, error) { + if args.Endpoints == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Endpoints"} + } + 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.Endpoints) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e85f1c62-adfc-4b74-b618-11a150fb195e") + 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 []ServiceEndpoint + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateServiceEndpoints function +type UpdateServiceEndpointsArgs struct { + // (required) Names of the service endpoints to update. + Endpoints *[]ServiceEndpoint + // (required) Project ID or project name + Project *string +} diff --git a/azuredevops/serviceendpoint/models.go b/azuredevops/serviceendpoint/models.go new file mode 100644 index 00000000..8ed19627 --- /dev/null +++ b/azuredevops/serviceendpoint/models.go @@ -0,0 +1,606 @@ +// -------------------------------------------------------------------------------------------- +// 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 serviceendpoint + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/distributedtaskcommon" + "github.com/microsoft/azure-devops-go-api/azuredevops/forminput" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type AadLoginPromptOption string + +type aadLoginPromptOptionValuesType struct { + NoOption AadLoginPromptOption + Login AadLoginPromptOption + SelectAccount AadLoginPromptOption + FreshLogin AadLoginPromptOption + FreshLoginWithMfa AadLoginPromptOption +} + +var AadLoginPromptOptionValues = aadLoginPromptOptionValuesType{ + // Do not provide a prompt option + NoOption: "noOption", + // Force the user to login again. + Login: "login", + // Force the user to select which account they are logging in with instead of automatically picking the user up from the session state. NOTE: This does not work for switching between the variants of a dual-homed user. + SelectAccount: "selectAccount", + // Force the user to login again. Ignore current authentication state and force the user to authenticate again. This option should be used instead of Login. + FreshLogin: "freshLogin", + // Force the user to login again with mfa. Ignore current authentication state and force the user to authenticate again. This option should be used instead of Login, if MFA is required. + FreshLoginWithMfa: "freshLoginWithMfa", +} + +type AadOauthTokenRequest struct { + Refresh *bool `json:"refresh,omitempty"` + Resource *string `json:"resource,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + Token *string `json:"token,omitempty"` +} + +type AadOauthTokenResult struct { + AccessToken *string `json:"accessToken,omitempty"` + RefreshTokenCache *string `json:"refreshTokenCache,omitempty"` +} + +type AccessTokenRequestType string + +type accessTokenRequestTypeValuesType struct { + None AccessTokenRequestType + Oauth AccessTokenRequestType + Direct AccessTokenRequestType +} + +var AccessTokenRequestTypeValues = accessTokenRequestTypeValuesType{ + None: "none", + Oauth: "oauth", + Direct: "direct", +} + +type AuthConfiguration struct { + // Gets or sets the ClientId + ClientId *string `json:"clientId,omitempty"` + // Gets or sets the ClientSecret + ClientSecret *string `json:"clientSecret,omitempty"` + // Gets or sets the identity who created the config. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets or sets the time when config was created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets or sets the type of the endpoint. + EndpointType *string `json:"endpointType,omitempty"` + // Gets or sets the unique identifier of this field + Id *uuid.UUID `json:"id,omitempty"` + // Gets or sets the identity who modified the config. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets or sets the time when variable group was modified + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets the name + Name *string `json:"name,omitempty"` + // Gets or sets the Url + Url *string `json:"url,omitempty"` + // Gets or sets parameters contained in configuration object. + Parameters *map[string]Parameter `json:"parameters,omitempty"` +} + +// Specifies the authentication scheme to be used for authentication. +type AuthenticationSchemeReference struct { + // Gets or sets the key and value of the fields used for authentication. + Inputs *map[string]string `json:"inputs,omitempty"` + // Gets or sets the type of authentication scheme of an endpoint. + Type *string `json:"type,omitempty"` +} + +// Represents the header of the REST request. +type AuthorizationHeader struct { + // Gets or sets the name of authorization header. + Name *string `json:"name,omitempty"` + // Gets or sets the value of authorization header. + Value *string `json:"value,omitempty"` +} + +type AzureKeyVaultPermission struct { + Provisioned *bool `json:"provisioned,omitempty"` + ResourceProvider *string `json:"resourceProvider,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + Vault *string `json:"vault,omitempty"` +} + +// Azure Management Group +type AzureManagementGroup struct { + // Display name of azure management group + DisplayName *string `json:"displayName,omitempty"` + // Id of azure management group + Id *string `json:"id,omitempty"` + // Azure management group name + Name *string `json:"name,omitempty"` + // Id of tenant from which azure management group belogs + TenantId *string `json:"tenantId,omitempty"` +} + +// Azure management group query result +type AzureManagementGroupQueryResult struct { + // Error message in case of an exception + ErrorMessage *string `json:"errorMessage,omitempty"` + // List of azure management groups + Value *[]AzureManagementGroup `json:"value,omitempty"` +} + +type AzureMLWorkspace struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` +} + +type AzurePermission struct { + Provisioned *bool `json:"provisioned,omitempty"` + ResourceProvider *string `json:"resourceProvider,omitempty"` +} + +type AzureResourcePermission struct { + Provisioned *bool `json:"provisioned,omitempty"` + ResourceProvider *string `json:"resourceProvider,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` +} + +type AzureRoleAssignmentPermission struct { + Provisioned *bool `json:"provisioned,omitempty"` + ResourceProvider *string `json:"resourceProvider,omitempty"` + RoleAssignmentId *uuid.UUID `json:"roleAssignmentId,omitempty"` +} + +type AzureSpnOperationStatus struct { + State *string `json:"state,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} + +type AzureSubscription struct { + DisplayName *string `json:"displayName,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + SubscriptionTenantId *string `json:"subscriptionTenantId,omitempty"` + SubscriptionTenantName *string `json:"subscriptionTenantName,omitempty"` +} + +type AzureSubscriptionQueryResult struct { + ErrorMessage *string `json:"errorMessage,omitempty"` + Value *[]AzureSubscription `json:"value,omitempty"` +} + +// Specifies the client certificate to be used for the endpoint request. +type ClientCertificate struct { + // Gets or sets the value of client certificate. + Value *string `json:"value,omitempty"` +} + +// Specifies the data sources for this endpoint. +type DataSource struct { + // Gets or sets the authentication scheme for the endpoint request. + AuthenticationScheme *AuthenticationSchemeReference `json:"authenticationScheme,omitempty"` + // Gets or sets the pagination format supported by this data source(ContinuationToken/SkipTop). + CallbackContextTemplate *string `json:"callbackContextTemplate,omitempty"` + // Gets or sets the template to check if subsequent call is needed. + CallbackRequiredTemplate *string `json:"callbackRequiredTemplate,omitempty"` + // Gets or sets the endpoint url of the data source. + EndpointUrl *string `json:"endpointUrl,omitempty"` + // Gets or sets the authorization headers of the request. + Headers *[]AuthorizationHeader `json:"headers,omitempty"` + // Gets or sets the initial value of the query params. + InitialContextTemplate *string `json:"initialContextTemplate,omitempty"` + // Gets or sets the name of the data source. + Name *string `json:"name,omitempty"` + // Gets or sets the request content of the endpoint request. + RequestContent *string `json:"requestContent,omitempty"` + // Gets or sets the request method of the endpoint request. + RequestVerb *string `json:"requestVerb,omitempty"` + // Gets or sets the resource url of the endpoint request. + ResourceUrl *string `json:"resourceUrl,omitempty"` + // Gets or sets the result selector to filter the response of the endpoint request. + ResultSelector *string `json:"resultSelector,omitempty"` +} + +// Represents the data source binding of the endpoint. +type DataSourceBinding struct { + // Pagination format supported by this data source(ContinuationToken/SkipTop). + CallbackContextTemplate *string `json:"callbackContextTemplate,omitempty"` + // Subsequent calls needed? + CallbackRequiredTemplate *string `json:"callbackRequiredTemplate,omitempty"` + // Gets or sets the name of the data source. + DataSourceName *string `json:"dataSourceName,omitempty"` + // Gets or sets the endpoint Id. + EndpointId *string `json:"endpointId,omitempty"` + // Gets or sets the url of the service endpoint. + EndpointUrl *string `json:"endpointUrl,omitempty"` + // Gets or sets the authorization headers. + Headers *[]distributedtaskcommon.AuthorizationHeader `json:"headers,omitempty"` + // Defines the initial value of the query params + InitialContextTemplate *string `json:"initialContextTemplate,omitempty"` + // Gets or sets the parameters for the data source. + Parameters *map[string]string `json:"parameters,omitempty"` + // Gets or sets http request body + RequestContent *string `json:"requestContent,omitempty"` + // Gets or sets http request verb + RequestVerb *string `json:"requestVerb,omitempty"` + // Gets or sets the result selector. + ResultSelector *string `json:"resultSelector,omitempty"` + // Gets or sets the result template. + ResultTemplate *string `json:"resultTemplate,omitempty"` + // Gets or sets the target of the data source. + Target *string `json:"target,omitempty"` +} + +// Represents details of the service endpoint data source. +type DataSourceDetails struct { + // Gets or sets the data source name. + DataSourceName *string `json:"dataSourceName,omitempty"` + // Gets or sets the data source url. + DataSourceUrl *string `json:"dataSourceUrl,omitempty"` + // Gets or sets the request headers. + Headers *[]AuthorizationHeader `json:"headers,omitempty"` + // Gets or sets the initialization context used for the initial call to the data source + InitialContextTemplate *string `json:"initialContextTemplate,omitempty"` + // Gets the parameters of data source. + Parameters *map[string]string `json:"parameters,omitempty"` + // Gets or sets the data source request content. + RequestContent *string `json:"requestContent,omitempty"` + // Gets or sets the data source request verb. Get/Post are the only implemented types + RequestVerb *string `json:"requestVerb,omitempty"` + // Gets or sets the resource url of data source. + ResourceUrl *string `json:"resourceUrl,omitempty"` + // Gets or sets the result selector. + ResultSelector *string `json:"resultSelector,omitempty"` +} + +// Represents the details of the input on which a given input is dependent. +type DependencyBinding struct { + // Gets or sets the value of the field on which url is dependent. + Key *string `json:"key,omitempty"` + // Gets or sets the corresponding value of url. + Value *string `json:"value,omitempty"` +} + +// Represents the dependency data for the endpoint inputs. +type DependencyData struct { + // Gets or sets the category of dependency data. + Input *string `json:"input,omitempty"` + // Gets or sets the key-value pair to specify properties and their values. + Map *[]azuredevops.KeyValuePair `json:"map,omitempty"` +} + +// Represents the inputs on which any given input is dependent. +type DependsOn struct { + // Gets or sets the ID of the field on which URL's value is dependent. + Input *string `json:"input,omitempty"` + // Gets or sets key-value pair containing other's field value and corresponding url value. + Map *[]DependencyBinding `json:"map,omitempty"` +} + +// Represents the authorization used for service endpoint. +type EndpointAuthorization struct { + // Gets or sets the parameters for the selected authorization scheme. + Parameters *map[string]string `json:"parameters,omitempty"` + // Gets or sets the scheme used for service endpoint authentication. + Scheme *string `json:"scheme,omitempty"` +} + +type EndpointOperationStatus struct { + State *string `json:"state,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} + +// Represents url of the service endpoint. +type EndpointUrl struct { + // Gets or sets the dependency bindings. + DependsOn *DependsOn `json:"dependsOn,omitempty"` + // Gets or sets the display name of service endpoint url. + DisplayName *string `json:"displayName,omitempty"` + // Gets or sets the help text of service endpoint url. + HelpText *string `json:"helpText,omitempty"` + // Gets or sets the visibility of service endpoint url. + IsVisible *string `json:"isVisible,omitempty"` + // Gets or sets the value of service endpoint url. + Value *string `json:"value,omitempty"` +} + +// Specifies the public url of the help documentation. +type HelpLink struct { + // Gets or sets the help text. + Text *string `json:"text,omitempty"` + // Gets or sets the public url of the help documentation. + Url *string `json:"url,omitempty"` +} + +type OAuth2TokenResult struct { + AccessToken *string `json:"accessToken,omitempty"` + Error *string `json:"error,omitempty"` + ErrorDescription *string `json:"errorDescription,omitempty"` + ExpiresIn *string `json:"expiresIn,omitempty"` + IssuedAt *string `json:"issuedAt,omitempty"` + RefreshToken *string `json:"refreshToken,omitempty"` + Scope *string `json:"scope,omitempty"` +} + +type OAuthConfiguration struct { + // Gets or sets the ClientId + ClientId *string `json:"clientId,omitempty"` + // Gets or sets the ClientSecret + ClientSecret *string `json:"clientSecret,omitempty"` + // Gets or sets the identity who created the config. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets or sets the time when config was created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets or sets the type of the endpoint. + EndpointType *string `json:"endpointType,omitempty"` + // Gets or sets the unique identifier of this field + Id *uuid.UUID `json:"id,omitempty"` + // Gets or sets the identity who modified the config. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets or sets the time when variable group was modified + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets the name + Name *string `json:"name,omitempty"` + // Gets or sets the Url + Url *string `json:"url,omitempty"` +} + +// [Flags] +type OAuthConfigurationActionFilter string + +type oAuthConfigurationActionFilterValuesType struct { + None OAuthConfigurationActionFilter + Manage OAuthConfigurationActionFilter + Use OAuthConfigurationActionFilter +} + +var OAuthConfigurationActionFilterValues = oAuthConfigurationActionFilterValuesType{ + None: "none", + Manage: "manage", + Use: "use", +} + +type OAuthConfigurationParams struct { + // Gets or sets the ClientId + ClientId *string `json:"clientId,omitempty"` + // Gets or sets the ClientSecret + ClientSecret *string `json:"clientSecret,omitempty"` + // Gets or sets the type of the endpoint. + EndpointType *string `json:"endpointType,omitempty"` + // Gets or sets the name + Name *string `json:"name,omitempty"` + // Gets or sets the Url + Url *string `json:"url,omitempty"` +} + +type OAuthEndpointStatus struct { + State *string `json:"state,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} + +type Parameter struct { + IsSecret *bool `json:"isSecret,omitempty"` + Value *string `json:"value,omitempty"` +} + +type ProjectReference struct { + Id *uuid.UUID `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +// Represents template to transform the result data. +type ResultTransformationDetails struct { + // Gets or sets the template for callback parameters + CallbackContextTemplate *string `json:"callbackContextTemplate,omitempty"` + // Gets or sets the template to decide whether to callback or not + CallbackRequiredTemplate *string `json:"callbackRequiredTemplate,omitempty"` + // Gets or sets the template for result transformation. + ResultTemplate *string `json:"resultTemplate,omitempty"` +} + +// Represents an endpoint which may be used by an orchestration job. +type ServiceEndpoint struct { + // Gets or sets the identity reference for the administrators group of the service endpoint. + AdministratorsGroup *webapi.IdentityRef `json:"administratorsGroup,omitempty"` + // Gets or sets the authorization data for talking to the endpoint. + Authorization *EndpointAuthorization `json:"authorization,omitempty"` + // Gets or sets the identity reference for the user who created the Service endpoint. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + Data *map[string]string `json:"data,omitempty"` + // Gets or sets the description of endpoint. + Description *string `json:"description,omitempty"` + // This is a deprecated field. + GroupScopeId *uuid.UUID `json:"groupScopeId,omitempty"` + // Gets or sets the identifier of this endpoint. + Id *uuid.UUID `json:"id,omitempty"` + // EndPoint state indicator + IsReady *bool `json:"isReady,omitempty"` + // Indicates whether service endpoint is shared with other projects or not. + IsShared *bool `json:"isShared,omitempty"` + // Gets or sets the friendly name of the endpoint. + Name *string `json:"name,omitempty"` + // Error message during creation/deletion of endpoint + OperationStatus interface{} `json:"operationStatus,omitempty"` + // Owner of the endpoint Supported values are "library", "agentcloud" + Owner *string `json:"owner,omitempty"` + // Gets or sets the identity reference for the readers group of the service endpoint. + ReadersGroup *webapi.IdentityRef `json:"readersGroup,omitempty"` + // Gets or sets the type of the endpoint. + Type *string `json:"type,omitempty"` + // Gets or sets the url of the endpoint. + Url *string `json:"url,omitempty"` +} + +// [Flags] +type ServiceEndpointActionFilter string + +type serviceEndpointActionFilterValuesType struct { + None ServiceEndpointActionFilter + Manage ServiceEndpointActionFilter + Use ServiceEndpointActionFilter +} + +var ServiceEndpointActionFilterValues = serviceEndpointActionFilterValuesType{ + None: "none", + Manage: "manage", + Use: "use", +} + +// Represents the authentication scheme used to authenticate the endpoint. +type ServiceEndpointAuthenticationScheme struct { + // Gets or sets the authorization headers of service endpoint authentication scheme. + AuthorizationHeaders *[]AuthorizationHeader `json:"authorizationHeaders,omitempty"` + // Gets or sets the Authorization url required to authenticate using OAuth2 + AuthorizationUrl *string `json:"authorizationUrl,omitempty"` + // Gets or sets the certificates of service endpoint authentication scheme. + ClientCertificates *[]ClientCertificate `json:"clientCertificates,omitempty"` + // Gets or sets the data source bindings of the endpoint. + DataSourceBindings *[]DataSourceBinding `json:"dataSourceBindings,omitempty"` + // Gets or sets the display name for the service endpoint authentication scheme. + DisplayName *string `json:"displayName,omitempty"` + // Gets or sets the input descriptors for the service endpoint authentication scheme. + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + // Gets or sets the scheme for service endpoint authentication. + Scheme *string `json:"scheme,omitempty"` +} + +// Represents details of the service endpoint. +type ServiceEndpointDetails struct { + // Gets or sets the authorization of service endpoint. + Authorization *EndpointAuthorization `json:"authorization,omitempty"` + // Gets or sets the data of service endpoint. + Data *map[string]string `json:"data,omitempty"` + // Gets or sets the type of service endpoint. + Type *string `json:"type,omitempty"` + // Gets or sets the connection url of service endpoint. + Url *string `json:"url,omitempty"` +} + +// Represents service endpoint execution data. +type ServiceEndpointExecutionData struct { + // Gets the definition of service endpoint execution owner. + Definition *ServiceEndpointExecutionOwner `json:"definition,omitempty"` + // Gets the finish time of service endpoint execution. + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + // Gets the Id of service endpoint execution data. + Id *uint64 `json:"id,omitempty"` + // Gets the owner of service endpoint execution data. + Owner *ServiceEndpointExecutionOwner `json:"owner,omitempty"` + // Gets the plan type of service endpoint execution data. + PlanType *string `json:"planType,omitempty"` + // Gets the result of service endpoint execution. + Result *ServiceEndpointExecutionResult `json:"result,omitempty"` + // Gets the start time of service endpoint execution. + StartTime *azuredevops.Time `json:"startTime,omitempty"` +} + +// Represents execution owner of the service endpoint. +type ServiceEndpointExecutionOwner struct { + Links interface{} `json:"_links,omitempty"` + // Gets or sets the Id of service endpoint execution owner. + Id *int `json:"id,omitempty"` + // Gets or sets the name of service endpoint execution owner. + Name *string `json:"name,omitempty"` +} + +// Represents the details of service endpoint execution. +type ServiceEndpointExecutionRecord struct { + // Gets the execution data of service endpoint execution. + Data *ServiceEndpointExecutionData `json:"data,omitempty"` + // Gets the Id of service endpoint. + EndpointId *uuid.UUID `json:"endpointId,omitempty"` +} + +type ServiceEndpointExecutionRecordsInput struct { + Data *ServiceEndpointExecutionData `json:"data,omitempty"` + EndpointIds *[]uuid.UUID `json:"endpointIds,omitempty"` +} + +type ServiceEndpointExecutionResult string + +type serviceEndpointExecutionResultValuesType struct { + Succeeded ServiceEndpointExecutionResult + SucceededWithIssues ServiceEndpointExecutionResult + Failed ServiceEndpointExecutionResult + Canceled ServiceEndpointExecutionResult + Skipped ServiceEndpointExecutionResult + Abandoned ServiceEndpointExecutionResult +} + +var ServiceEndpointExecutionResultValues = serviceEndpointExecutionResultValuesType{ + // "Service endpoint request succeeded. + Succeeded: "succeeded", + // "Service endpoint request succeeded but with some issues. + SucceededWithIssues: "succeededWithIssues", + // "Service endpoint request failed. + Failed: "failed", + // "Service endpoint request was cancelled. + Canceled: "canceled", + // "Service endpoint request was skipped. + Skipped: "skipped", + // "Service endpoint request was abandoned. + Abandoned: "abandoned", +} + +type ServiceEndpointOAuthConfigurationReference struct { + ConfigurationId *uuid.UUID `json:"configurationId,omitempty"` + ServiceEndpointId *uuid.UUID `json:"serviceEndpointId,omitempty"` + ServiceEndpointProjectId *uuid.UUID `json:"serviceEndpointProjectId,omitempty"` +} + +type ServiceEndpointRequest struct { + // Gets or sets the data source details for the service endpoint request. + DataSourceDetails *DataSourceDetails `json:"dataSourceDetails,omitempty"` + // Gets or sets the result transformation details for the service endpoint request. + ResultTransformationDetails *ResultTransformationDetails `json:"resultTransformationDetails,omitempty"` + // Gets or sets the service endpoint details for the service endpoint request. + ServiceEndpointDetails *ServiceEndpointDetails `json:"serviceEndpointDetails,omitempty"` +} + +// Represents result of the service endpoint request. +type ServiceEndpointRequestResult struct { + // Gets or sets the parameters used to make subsequent calls to the data source + CallbackContextParameters *map[string]string `json:"callbackContextParameters,omitempty"` + // Gets or sets the flat that decides if another call to the data source is to be made + CallbackRequired *bool `json:"callbackRequired,omitempty"` + // Gets or sets the error message of the service endpoint request result. + ErrorMessage *string `json:"errorMessage,omitempty"` + // Gets or sets the result of service endpoint request. + Result interface{} `json:"result,omitempty"` + // Gets or sets the status code of the service endpoint request result. + StatusCode *string `json:"statusCode,omitempty"` +} + +// Represents type of the service endpoint. +type ServiceEndpointType struct { + // Authentication scheme of service endpoint type. + AuthenticationSchemes *[]ServiceEndpointAuthenticationScheme `json:"authenticationSchemes,omitempty"` + // Data sources of service endpoint type. + DataSources *[]DataSource `json:"dataSources,omitempty"` + // Dependency data of service endpoint type. + DependencyData *[]DependencyData `json:"dependencyData,omitempty"` + // Gets or sets the description of service endpoint type. + Description *string `json:"description,omitempty"` + // Gets or sets the display name of service endpoint type. + DisplayName *string `json:"displayName,omitempty"` + // Gets or sets the endpoint url of service endpoint type. + EndpointUrl *EndpointUrl `json:"endpointUrl,omitempty"` + // Gets or sets the help link of service endpoint type. + HelpLink *HelpLink `json:"helpLink,omitempty"` + // Gets or sets the help text shown at the endpoint create dialog. + HelpMarkDown *string `json:"helpMarkDown,omitempty"` + // Gets or sets the icon url of service endpoint type. + IconUrl *string `json:"iconUrl,omitempty"` + // Input descriptor of service endpoint type. + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + // Gets or sets the name of service endpoint type. + Name *string `json:"name,omitempty"` + // Trusted hosts of a service endpoint type. + TrustedHosts *[]string `json:"trustedHosts,omitempty"` + // Gets or sets the ui contribution id of service endpoint type. + UiContributionId *string `json:"uiContributionId,omitempty"` +} diff --git a/azuredevops/servicehooks/client.go b/azuredevops/servicehooks/client.go new file mode 100644 index 00000000..5b54c71d --- /dev/null +++ b/azuredevops/servicehooks/client.go @@ -0,0 +1,718 @@ +// -------------------------------------------------------------------------------------------- +// 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 servicehooks + +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/forminput" + "github.com/microsoft/azure-devops-go-api/azuredevops/notification" + "net/http" + "net/url" + "strconv" +) + +type Client interface { + // Create a subscription. + CreateSubscription(context.Context, CreateSubscriptionArgs) (*Subscription, error) + // Query for service hook subscriptions. + CreateSubscriptionsQuery(context.Context, CreateSubscriptionsQueryArgs) (*SubscriptionsQuery, error) + // Sends a test notification. This is useful for verifying the configuration of an updated or new service hooks subscription. + CreateTestNotification(context.Context, CreateTestNotificationArgs) (*Notification, error) + // Delete a specific service hooks subscription. + DeleteSubscription(context.Context, DeleteSubscriptionArgs) error + // Get a specific consumer service. Optionally filter out consumer actions that do not support any event types for the specified publisher. + GetConsumer(context.Context, GetConsumerArgs) (*Consumer, error) + // Get details about a specific consumer action. + GetConsumerAction(context.Context, GetConsumerActionArgs) (*ConsumerAction, error) + // Get a specific event type. + GetEventType(context.Context, GetEventTypeArgs) (*EventTypeDescriptor, error) + // Get a specific notification for a subscription. + GetNotification(context.Context, GetNotificationArgs) (*Notification, error) + // Get a list of notifications for a specific subscription. A notification includes details about the event, the request to and the response from the consumer service. + GetNotifications(context.Context, GetNotificationsArgs) (*[]Notification, error) + // Get a specific service hooks publisher. + GetPublisher(context.Context, GetPublisherArgs) (*Publisher, error) + // Get a specific service hooks subscription. + GetSubscription(context.Context, GetSubscriptionArgs) (*Subscription, error) + // [Preview API] + GetSubscriptionDiagnostics(context.Context, GetSubscriptionDiagnosticsArgs) (*notification.SubscriptionDiagnostics, error) + // Get a list of consumer actions for a specific consumer. + ListConsumerActions(context.Context, ListConsumerActionsArgs) (*[]ConsumerAction, error) + // Get a list of available service hook consumer services. Optionally filter by consumers that support at least one event type from the specific publisher. + ListConsumers(context.Context, ListConsumersArgs) (*[]Consumer, error) + // Get the event types for a specific publisher. + ListEventTypes(context.Context, ListEventTypesArgs) (*[]EventTypeDescriptor, error) + // Get a list of publishers. + ListPublishers(context.Context, ListPublishersArgs) (*[]Publisher, error) + // Get a list of subscriptions. + ListSubscriptions(context.Context, ListSubscriptionsArgs) (*[]Subscription, error) + QueryInputValues(context.Context, QueryInputValuesArgs) (*forminput.InputValuesQuery, error) + // Query for notifications. A notification includes details about the event, the request to and the response from the consumer service. + QueryNotifications(context.Context, QueryNotificationsArgs) (*NotificationsQuery, error) + // Query for service hook publishers. + QueryPublishers(context.Context, QueryPublishersArgs) (*PublishersQuery, error) + // Update a subscription. ID for a subscription that you wish to update. + ReplaceSubscription(context.Context, ReplaceSubscriptionArgs) (*Subscription, error) + // [Preview API] + UpdateSubscriptionDiagnostics(context.Context, UpdateSubscriptionDiagnosticsArgs) (*notification.SubscriptionDiagnostics, 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, + } +} + +// Create a subscription. +func (client *ClientImpl) CreateSubscription(ctx context.Context, args CreateSubscriptionArgs) (*Subscription, error) { + if args.Subscription == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Subscription"} + } + body, marshalErr := json.Marshal(*args.Subscription) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("fc50d02a-849f-41fb-8af1-0a5216103269") + 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 Subscription + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateSubscription function +type CreateSubscriptionArgs struct { + // (required) Subscription to be created. + Subscription *Subscription +} + +// Query for service hook subscriptions. +func (client *ClientImpl) CreateSubscriptionsQuery(ctx context.Context, args CreateSubscriptionsQueryArgs) (*SubscriptionsQuery, error) { + if args.Query == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"} + } + body, marshalErr := json.Marshal(*args.Query) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("c7c3c1cf-9e05-4c0d-a425-a0f922c2c6ed") + 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 SubscriptionsQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateSubscriptionsQuery function +type CreateSubscriptionsQueryArgs struct { + // (required) + Query *SubscriptionsQuery +} + +// Sends a test notification. This is useful for verifying the configuration of an updated or new service hooks subscription. +func (client *ClientImpl) CreateTestNotification(ctx context.Context, args CreateTestNotificationArgs) (*Notification, error) { + if args.TestNotification == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestNotification"} + } + queryParams := url.Values{} + if args.UseRealData != nil { + queryParams.Add("useRealData", strconv.FormatBool(*args.UseRealData)) + } + body, marshalErr := json.Marshal(*args.TestNotification) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1139462c-7e27-4524-a997-31b9b73551fe") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", nil, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Notification + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestNotification function +type CreateTestNotificationArgs struct { + // (required) + TestNotification *Notification + // (optional) Only allow testing with real data in existing subscriptions. + UseRealData *bool +} + +// Delete a specific service hooks subscription. +func (client *ClientImpl) DeleteSubscription(ctx context.Context, args DeleteSubscriptionArgs) error { + routeValues := make(map[string]string) + if args.SubscriptionId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = (*args.SubscriptionId).String() + + locationId, _ := uuid.Parse("fc50d02a-849f-41fb-8af1-0a5216103269") + _, 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 DeleteSubscription function +type DeleteSubscriptionArgs struct { + // (required) ID for a subscription. + SubscriptionId *uuid.UUID +} + +// Get a specific consumer service. Optionally filter out consumer actions that do not support any event types for the specified publisher. +func (client *ClientImpl) GetConsumer(ctx context.Context, args GetConsumerArgs) (*Consumer, error) { + routeValues := make(map[string]string) + if args.ConsumerId == nil || *args.ConsumerId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ConsumerId"} + } + routeValues["consumerId"] = *args.ConsumerId + + queryParams := url.Values{} + if args.PublisherId != nil { + queryParams.Add("publisherId", *args.PublisherId) + } + locationId, _ := uuid.Parse("4301c514-5f34-4f5d-a145-f0ea7b5b7d19") + 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 Consumer + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetConsumer function +type GetConsumerArgs struct { + // (required) ID for a consumer. + ConsumerId *string + // (optional) + PublisherId *string +} + +// Get details about a specific consumer action. +func (client *ClientImpl) GetConsumerAction(ctx context.Context, args GetConsumerActionArgs) (*ConsumerAction, error) { + routeValues := make(map[string]string) + if args.ConsumerId == nil || *args.ConsumerId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ConsumerId"} + } + routeValues["consumerId"] = *args.ConsumerId + if args.ConsumerActionId == nil || *args.ConsumerActionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ConsumerActionId"} + } + routeValues["consumerActionId"] = *args.ConsumerActionId + + queryParams := url.Values{} + if args.PublisherId != nil { + queryParams.Add("publisherId", *args.PublisherId) + } + locationId, _ := uuid.Parse("c3428e90-7a69-4194-8ed8-0f153185ee0d") + 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 ConsumerAction + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetConsumerAction function +type GetConsumerActionArgs struct { + // (required) ID for a consumer. + ConsumerId *string + // (required) ID for a consumerActionId. + ConsumerActionId *string + // (optional) + PublisherId *string +} + +// Get a specific event type. +func (client *ClientImpl) GetEventType(ctx context.Context, args GetEventTypeArgs) (*EventTypeDescriptor, error) { + routeValues := make(map[string]string) + if args.PublisherId == nil || *args.PublisherId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherId"} + } + routeValues["publisherId"] = *args.PublisherId + if args.EventTypeId == nil || *args.EventTypeId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.EventTypeId"} + } + routeValues["eventTypeId"] = *args.EventTypeId + + locationId, _ := uuid.Parse("db4777cd-8e08-4a84-8ba3-c974ea033718") + 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 EventTypeDescriptor + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetEventType function +type GetEventTypeArgs struct { + // (required) ID for a publisher. + PublisherId *string + // (required) + EventTypeId *string +} + +// Get a specific notification for a subscription. +func (client *ClientImpl) GetNotification(ctx context.Context, args GetNotificationArgs) (*Notification, error) { + routeValues := make(map[string]string) + if args.SubscriptionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = (*args.SubscriptionId).String() + if args.NotificationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.NotificationId"} + } + routeValues["notificationId"] = strconv.Itoa(*args.NotificationId) + + locationId, _ := uuid.Parse("0c62d343-21b0-4732-997b-017fde84dc28") + 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 Notification + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetNotification function +type GetNotificationArgs struct { + // (required) ID for a subscription. + SubscriptionId *uuid.UUID + // (required) + NotificationId *int +} + +// Get a list of notifications for a specific subscription. A notification includes details about the event, the request to and the response from the consumer service. +func (client *ClientImpl) GetNotifications(ctx context.Context, args GetNotificationsArgs) (*[]Notification, error) { + routeValues := make(map[string]string) + if args.SubscriptionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = (*args.SubscriptionId).String() + + queryParams := url.Values{} + if args.MaxResults != nil { + queryParams.Add("maxResults", strconv.Itoa(*args.MaxResults)) + } + if args.Status != nil { + queryParams.Add("status", string(*args.Status)) + } + if args.Result != nil { + queryParams.Add("result", string(*args.Result)) + } + locationId, _ := uuid.Parse("0c62d343-21b0-4732-997b-017fde84dc28") + 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 []Notification + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetNotifications function +type GetNotificationsArgs struct { + // (required) ID for a subscription. + SubscriptionId *uuid.UUID + // (optional) Maximum number of notifications to return. Default is **100**. + MaxResults *int + // (optional) Get only notifications with this status. + Status *NotificationStatus + // (optional) Get only notifications with this result type. + Result *NotificationResult +} + +// Get a specific service hooks publisher. +func (client *ClientImpl) GetPublisher(ctx context.Context, args GetPublisherArgs) (*Publisher, error) { + routeValues := make(map[string]string) + if args.PublisherId == nil || *args.PublisherId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherId"} + } + routeValues["publisherId"] = *args.PublisherId + + locationId, _ := uuid.Parse("1e83a210-5b53-43bc-90f0-d476a4e5d731") + 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 Publisher + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPublisher function +type GetPublisherArgs struct { + // (required) ID for a publisher. + PublisherId *string +} + +// Get a specific service hooks subscription. +func (client *ClientImpl) GetSubscription(ctx context.Context, args GetSubscriptionArgs) (*Subscription, error) { + routeValues := make(map[string]string) + if args.SubscriptionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = (*args.SubscriptionId).String() + + locationId, _ := uuid.Parse("fc50d02a-849f-41fb-8af1-0a5216103269") + 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 Subscription + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSubscription function +type GetSubscriptionArgs struct { + // (required) ID for a subscription. + SubscriptionId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) GetSubscriptionDiagnostics(ctx context.Context, args GetSubscriptionDiagnosticsArgs) (*notification.SubscriptionDiagnostics, error) { + routeValues := make(map[string]string) + if args.SubscriptionId == nil || *args.SubscriptionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = *args.SubscriptionId + + locationId, _ := uuid.Parse("3b36bcb5-02ad-43c6-bbfa-6dfc6f8e9d68") + 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 notification.SubscriptionDiagnostics + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSubscriptionDiagnostics function +type GetSubscriptionDiagnosticsArgs struct { + // (required) + SubscriptionId *string +} + +// Get a list of consumer actions for a specific consumer. +func (client *ClientImpl) ListConsumerActions(ctx context.Context, args ListConsumerActionsArgs) (*[]ConsumerAction, error) { + routeValues := make(map[string]string) + if args.ConsumerId == nil || *args.ConsumerId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ConsumerId"} + } + routeValues["consumerId"] = *args.ConsumerId + + queryParams := url.Values{} + if args.PublisherId != nil { + queryParams.Add("publisherId", *args.PublisherId) + } + locationId, _ := uuid.Parse("c3428e90-7a69-4194-8ed8-0f153185ee0d") + 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 []ConsumerAction + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListConsumerActions function +type ListConsumerActionsArgs struct { + // (required) ID for a consumer. + ConsumerId *string + // (optional) + PublisherId *string +} + +// Get a list of available service hook consumer services. Optionally filter by consumers that support at least one event type from the specific publisher. +func (client *ClientImpl) ListConsumers(ctx context.Context, args ListConsumersArgs) (*[]Consumer, error) { + queryParams := url.Values{} + if args.PublisherId != nil { + queryParams.Add("publisherId", *args.PublisherId) + } + locationId, _ := uuid.Parse("4301c514-5f34-4f5d-a145-f0ea7b5b7d19") + 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 []Consumer + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListConsumers function +type ListConsumersArgs struct { + // (optional) + PublisherId *string +} + +// Get the event types for a specific publisher. +func (client *ClientImpl) ListEventTypes(ctx context.Context, args ListEventTypesArgs) (*[]EventTypeDescriptor, error) { + routeValues := make(map[string]string) + if args.PublisherId == nil || *args.PublisherId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherId"} + } + routeValues["publisherId"] = *args.PublisherId + + locationId, _ := uuid.Parse("db4777cd-8e08-4a84-8ba3-c974ea033718") + 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 []EventTypeDescriptor + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListEventTypes function +type ListEventTypesArgs struct { + // (required) ID for a publisher. + PublisherId *string +} + +// Get a list of publishers. +func (client *ClientImpl) ListPublishers(ctx context.Context, args ListPublishersArgs) (*[]Publisher, error) { + locationId, _ := uuid.Parse("1e83a210-5b53-43bc-90f0-d476a4e5d731") + 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 []Publisher + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListPublishers function +type ListPublishersArgs struct { +} + +// Get a list of subscriptions. +func (client *ClientImpl) ListSubscriptions(ctx context.Context, args ListSubscriptionsArgs) (*[]Subscription, error) { + queryParams := url.Values{} + if args.PublisherId != nil { + queryParams.Add("publisherId", *args.PublisherId) + } + if args.EventType != nil { + queryParams.Add("eventType", *args.EventType) + } + if args.ConsumerId != nil { + queryParams.Add("consumerId", *args.ConsumerId) + } + if args.ConsumerActionId != nil { + queryParams.Add("consumerActionId", *args.ConsumerActionId) + } + locationId, _ := uuid.Parse("fc50d02a-849f-41fb-8af1-0a5216103269") + 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 []Subscription + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListSubscriptions function +type ListSubscriptionsArgs struct { + // (optional) ID for a subscription. + PublisherId *string + // (optional) The event type to filter on (if any). + EventType *string + // (optional) ID for a consumer. + ConsumerId *string + // (optional) ID for a consumerActionId. + ConsumerActionId *string +} + +func (client *ClientImpl) QueryInputValues(ctx context.Context, args QueryInputValuesArgs) (*forminput.InputValuesQuery, error) { + if args.InputValuesQuery == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.InputValuesQuery"} + } + routeValues := make(map[string]string) + if args.PublisherId == nil || *args.PublisherId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PublisherId"} + } + routeValues["publisherId"] = *args.PublisherId + + body, marshalErr := json.Marshal(*args.InputValuesQuery) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d815d352-a566-4dc1-a3e3-fd245acf688c") + 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 forminput.InputValuesQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryInputValues function +type QueryInputValuesArgs struct { + // (required) + InputValuesQuery *forminput.InputValuesQuery + // (required) + PublisherId *string +} + +// Query for notifications. A notification includes details about the event, the request to and the response from the consumer service. +func (client *ClientImpl) QueryNotifications(ctx context.Context, args QueryNotificationsArgs) (*NotificationsQuery, error) { + if args.Query == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"} + } + body, marshalErr := json.Marshal(*args.Query) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1a57562f-160a-4b5c-9185-905e95b39d36") + 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 NotificationsQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryNotifications function +type QueryNotificationsArgs struct { + // (required) + Query *NotificationsQuery +} + +// Query for service hook publishers. +func (client *ClientImpl) QueryPublishers(ctx context.Context, args QueryPublishersArgs) (*PublishersQuery, error) { + if args.Query == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"} + } + body, marshalErr := json.Marshal(*args.Query) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("99b44a8a-65a8-4670-8f3e-e7f7842cce64") + 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 PublishersQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryPublishers function +type QueryPublishersArgs struct { + // (required) + Query *PublishersQuery +} + +// Update a subscription. ID for a subscription that you wish to update. +func (client *ClientImpl) ReplaceSubscription(ctx context.Context, args ReplaceSubscriptionArgs) (*Subscription, error) { + if args.Subscription == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Subscription"} + } + routeValues := make(map[string]string) + if args.SubscriptionId != nil { + routeValues["subscriptionId"] = (*args.SubscriptionId).String() + } + + body, marshalErr := json.Marshal(*args.Subscription) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("fc50d02a-849f-41fb-8af1-0a5216103269") + 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 Subscription + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReplaceSubscription function +type ReplaceSubscriptionArgs struct { + // (required) + Subscription *Subscription + // (optional) + SubscriptionId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) UpdateSubscriptionDiagnostics(ctx context.Context, args UpdateSubscriptionDiagnosticsArgs) (*notification.SubscriptionDiagnostics, error) { + if args.UpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateParameters"} + } + routeValues := make(map[string]string) + if args.SubscriptionId == nil || *args.SubscriptionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubscriptionId"} + } + routeValues["subscriptionId"] = *args.SubscriptionId + + body, marshalErr := json.Marshal(*args.UpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("3b36bcb5-02ad-43c6-bbfa-6dfc6f8e9d68") + resp, 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 nil, err + } + + var responseValue notification.SubscriptionDiagnostics + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateSubscriptionDiagnostics function +type UpdateSubscriptionDiagnosticsArgs struct { + // (required) + UpdateParameters *notification.UpdateSubscripitonDiagnosticsParameters + // (required) + SubscriptionId *string +} diff --git a/azuredevops/servicehooks/models.go b/azuredevops/servicehooks/models.go new file mode 100644 index 00000000..cc72927c --- /dev/null +++ b/azuredevops/servicehooks/models.go @@ -0,0 +1,467 @@ +// -------------------------------------------------------------------------------------------- +// 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 servicehooks + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/forminput" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +// Enumerates consumer authentication types. +type AuthenticationType string + +type authenticationTypeValuesType struct { + None AuthenticationType + OAuth AuthenticationType + External AuthenticationType +} + +var AuthenticationTypeValues = authenticationTypeValuesType{ + // No authentication is required. + None: "none", + // OAuth authentication. + OAuth: "oAuth", + // Externally-configured authentication. + External: "external", +} + +// Defines the data contract of a consumer. +type Consumer struct { + // Reference Links + Links interface{} `json:"_links,omitempty"` + // Gets this consumer's actions. + Actions *[]ConsumerAction `json:"actions,omitempty"` + // Gets or sets this consumer's authentication type. + AuthenticationType *AuthenticationType `json:"authenticationType,omitempty"` + // Gets or sets this consumer's localized description. + Description *string `json:"description,omitempty"` + // Non-null only if subscriptions for this consumer are configured externally. + ExternalConfiguration *ExternalConfigurationDescriptor `json:"externalConfiguration,omitempty"` + // Gets or sets this consumer's identifier. + Id *string `json:"id,omitempty"` + // Gets or sets this consumer's image URL, if any. + ImageUrl *string `json:"imageUrl,omitempty"` + // Gets or sets this consumer's information URL, if any. + InformationUrl *string `json:"informationUrl,omitempty"` + // Gets or sets this consumer's input descriptors. + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + // Gets or sets this consumer's localized name. + Name *string `json:"name,omitempty"` + // The url for this resource + Url *string `json:"url,omitempty"` +} + +// Defines the data contract of a consumer action. +type ConsumerAction struct { + // Reference Links + Links interface{} `json:"_links,omitempty"` + // Gets or sets the flag indicating if resource version can be overridden when creating or editing a subscription. + AllowResourceVersionOverride *bool `json:"allowResourceVersionOverride,omitempty"` + // Gets or sets the identifier of the consumer to which this action belongs. + ConsumerId *string `json:"consumerId,omitempty"` + // Gets or sets this action's localized description. + Description *string `json:"description,omitempty"` + // Gets or sets this action's identifier. + Id *string `json:"id,omitempty"` + // Gets or sets this action's input descriptors. + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + // Gets or sets this action's localized name. + Name *string `json:"name,omitempty"` + // Gets or sets this action's supported event identifiers. + SupportedEventTypes *[]string `json:"supportedEventTypes,omitempty"` + // Gets or sets this action's supported resource versions. + SupportedResourceVersions *map[string][]string `json:"supportedResourceVersions,omitempty"` + // The url for this resource + Url *string `json:"url,omitempty"` +} + +// Encapsulates the properties of an event. +type Event struct { + // Gets or sets the UTC-based date and time that this event was created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Gets or sets the detailed message associated with this event. + DetailedMessage *FormattedEventMessage `json:"detailedMessage,omitempty"` + // Gets or sets the type of this event. + EventType *string `json:"eventType,omitempty"` + // Gets or sets the unique identifier of this event. + Id *uuid.UUID `json:"id,omitempty"` + // Gets or sets the (brief) message associated with this event. + Message *FormattedEventMessage `json:"message,omitempty"` + // Gets or sets the identifier of the publisher that raised this event. + PublisherId *string `json:"publisherId,omitempty"` + // Gets or sets the data associated with this event. + Resource interface{} `json:"resource,omitempty"` + // Gets or sets the resource containers. + ResourceContainers *map[string]ResourceContainer `json:"resourceContainers,omitempty"` + // Gets or sets the version of the data associated with this event. + ResourceVersion *string `json:"resourceVersion,omitempty"` + // Gets or sets the Session Token that can be used in further interactions + SessionToken *SessionToken `json:"sessionToken,omitempty"` +} + +// Describes a type of event +type EventTypeDescriptor struct { + // A localized description of the event type + Description *string `json:"description,omitempty"` + // A unique id for the event type + Id *string `json:"id,omitempty"` + // Event-specific inputs + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + // A localized friendly name for the event type + Name *string `json:"name,omitempty"` + // A unique id for the publisher of this event type + PublisherId *string `json:"publisherId,omitempty"` + // Supported versions for the event's resource payloads. + SupportedResourceVersions *[]string `json:"supportedResourceVersions,omitempty"` + // The url for this resource + Url *string `json:"url,omitempty"` +} + +// Describes how to configure a subscription that is managed externally. +type ExternalConfigurationDescriptor struct { + // Url of the site to create this type of subscription. + CreateSubscriptionUrl *string `json:"createSubscriptionUrl,omitempty"` + // The name of an input property that contains the URL to edit a subscription. + EditSubscriptionPropertyName *string `json:"editSubscriptionPropertyName,omitempty"` + // True if the external configuration applies only to hosted. + HostedOnly *bool `json:"hostedOnly,omitempty"` +} + +// Provides different formats of an event message +type FormattedEventMessage struct { + // Gets or sets the html format of the message + Html *string `json:"html,omitempty"` + // Gets or sets the markdown format of the message + Markdown *string `json:"markdown,omitempty"` + // Gets or sets the raw text of the message + Text *string `json:"text,omitempty"` +} + +// Defines the data contract of the result of processing an event for a subscription. +type Notification struct { + // Gets or sets date and time that this result was created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Details about this notification (if available) + Details *NotificationDetails `json:"details,omitempty"` + // The event id associated with this notification + EventId *uuid.UUID `json:"eventId,omitempty"` + // The notification id + Id *int `json:"id,omitempty"` + // Gets or sets date and time that this result was last modified. + ModifiedDate *azuredevops.Time `json:"modifiedDate,omitempty"` + // Result of the notification + Result *NotificationResult `json:"result,omitempty"` + // Status of the notification + Status *NotificationStatus `json:"status,omitempty"` + // The subscriber Id associated with this notification. This is the last identity who touched in the subscription. In case of test notifications it can be the tester if the subscription is not created yet. + SubscriberId *uuid.UUID `json:"subscriberId,omitempty"` + // The subscription id associated with this notification + SubscriptionId *uuid.UUID `json:"subscriptionId,omitempty"` +} + +// Defines the data contract of notification details. +type NotificationDetails struct { + // Gets or sets the time that this notification was completed (response received from the consumer) + CompletedDate *azuredevops.Time `json:"completedDate,omitempty"` + // Gets or sets this notification detail's consumer action identifier. + ConsumerActionId *string `json:"consumerActionId,omitempty"` + // Gets or sets this notification detail's consumer identifier. + ConsumerId *string `json:"consumerId,omitempty"` + // Gets or sets this notification detail's consumer inputs. + ConsumerInputs *map[string]string `json:"consumerInputs,omitempty"` + // Gets or sets the time that this notification was dequeued for processing + DequeuedDate *azuredevops.Time `json:"dequeuedDate,omitempty"` + // Gets or sets this notification detail's error detail. + ErrorDetail *string `json:"errorDetail,omitempty"` + // Gets or sets this notification detail's error message. + ErrorMessage *string `json:"errorMessage,omitempty"` + // Gets or sets this notification detail's event content. + Event *Event `json:"event,omitempty"` + // Gets or sets this notification detail's event type. + EventType *string `json:"eventType,omitempty"` + // Gets or sets the time that this notification was finished processing (just before the request is sent to the consumer) + ProcessedDate *azuredevops.Time `json:"processedDate,omitempty"` + // Gets or sets this notification detail's publisher identifier. + PublisherId *string `json:"publisherId,omitempty"` + // Gets or sets this notification detail's publisher inputs. + PublisherInputs *map[string]string `json:"publisherInputs,omitempty"` + // Gets or sets the time that this notification was queued (created) + QueuedDate *azuredevops.Time `json:"queuedDate,omitempty"` + // Gets or sets this notification detail's request. + Request *string `json:"request,omitempty"` + // Number of requests attempted to be sent to the consumer + RequestAttempts *int `json:"requestAttempts,omitempty"` + // Duration of the request to the consumer in seconds + RequestDuration *float64 `json:"requestDuration,omitempty"` + // Gets or sets this notification detail's response. + Response *string `json:"response,omitempty"` +} + +// Enumerates possible result types of a notification. +type NotificationResult string + +type notificationResultValuesType struct { + Pending NotificationResult + Succeeded NotificationResult + Failed NotificationResult + Filtered NotificationResult +} + +var NotificationResultValues = notificationResultValuesType{ + // The notification has not yet completed + Pending: "pending", + // The notification was sent successfully + Succeeded: "succeeded", + // The notification failed to be sent successfully to the consumer + Failed: "failed", + // The notification was filtered by the Delivery Job + Filtered: "filtered", +} + +// Summary of a particular result and count. +type NotificationResultsSummaryDetail struct { + // Count of notification sent out with a matching result. + NotificationCount *int `json:"notificationCount,omitempty"` + // Result of the notification + Result *NotificationResult `json:"result,omitempty"` +} + +// Defines a query for service hook notifications. +type NotificationsQuery struct { + // The subscriptions associated with the notifications returned from the query + AssociatedSubscriptions *[]Subscription `json:"associatedSubscriptions,omitempty"` + // If true, we will return all notification history for the query provided; otherwise, the summary is returned. + IncludeDetails *bool `json:"includeDetails,omitempty"` + // Optional maximum date at which the notification was created + MaxCreatedDate *azuredevops.Time `json:"maxCreatedDate,omitempty"` + // Optional maximum number of overall results to include + MaxResults *int `json:"maxResults,omitempty"` + // Optional maximum number of results for each subscription. Only takes effect when a list of subscription ids is supplied in the query. + MaxResultsPerSubscription *int `json:"maxResultsPerSubscription,omitempty"` + // Optional minimum date at which the notification was created + MinCreatedDate *azuredevops.Time `json:"minCreatedDate,omitempty"` + // Optional publisher id to restrict the results to + PublisherId *string `json:"publisherId,omitempty"` + // Results from the query + Results *[]Notification `json:"results,omitempty"` + // Optional notification result type to filter results to + ResultType *NotificationResult `json:"resultType,omitempty"` + // Optional notification status to filter results to + Status *NotificationStatus `json:"status,omitempty"` + // Optional list of subscription ids to restrict the results to + SubscriptionIds *[]uuid.UUID `json:"subscriptionIds,omitempty"` + // Summary of notifications - the count of each result type (success, fail, ..). + Summary *[]NotificationSummary `json:"summary,omitempty"` +} + +// Enumerates possible status' of a notification. +type NotificationStatus string + +type notificationStatusValuesType struct { + Queued NotificationStatus + Processing NotificationStatus + RequestInProgress NotificationStatus + Completed NotificationStatus +} + +var NotificationStatusValues = notificationStatusValuesType{ + // The notification has been queued + Queued: "queued", + // The notification has been dequeued and has begun processing. + Processing: "processing", + // The consumer action has processed the notification. The request is in progress. + RequestInProgress: "requestInProgress", + // The request completed + Completed: "completed", +} + +// Summary of the notifications for a subscription. +type NotificationSummary struct { + // The notification results for this particular subscription. + Results *[]NotificationResultsSummaryDetail `json:"results,omitempty"` + // The subscription id associated with this notification + SubscriptionId *uuid.UUID `json:"subscriptionId,omitempty"` +} + +// Defines the data contract of an event publisher. +type Publisher struct { + // Reference Links + Links interface{} `json:"_links,omitempty"` + // Gets this publisher's localized description. + Description *string `json:"description,omitempty"` + // Gets this publisher's identifier. + Id *string `json:"id,omitempty"` + // Publisher-specific inputs + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + // Gets this publisher's localized name. + Name *string `json:"name,omitempty"` + // The service instance type of the first party publisher. + ServiceInstanceType *string `json:"serviceInstanceType,omitempty"` + // Gets this publisher's supported event types. + SupportedEvents *[]EventTypeDescriptor `json:"supportedEvents,omitempty"` + // The url for this resource + Url *string `json:"url,omitempty"` +} + +// Wrapper around an event which is being published +type PublisherEvent struct { + // Add key/value pairs which will be stored with a published notification in the SH service DB. This key/value pairs are for diagnostic purposes only and will have not effect on the delivery of a notification. + Diagnostics *map[string]string `json:"diagnostics,omitempty"` + // The event being published + Event *Event `json:"event,omitempty"` + // Gets or sets flag for filtered events + IsFilteredEvent *bool `json:"isFilteredEvent,omitempty"` + // Additional data that needs to be sent as part of notification to complement the Resource data in the Event + NotificationData *map[string]string `json:"notificationData,omitempty"` + // Gets or sets the array of older supported resource versions. + OtherResourceVersions *[]VersionedResource `json:"otherResourceVersions,omitempty"` + // Optional publisher-input filters which restricts the set of subscriptions which are triggered by the event + PublisherInputFilters *[]forminput.InputFilter `json:"publisherInputFilters,omitempty"` + // Gets or sets matched hooks subscription which caused this event. + Subscription *Subscription `json:"subscription,omitempty"` +} + +// Defines a query for service hook publishers. +type PublishersQuery struct { + // Optional list of publisher ids to restrict the results to + PublisherIds *[]string `json:"publisherIds,omitempty"` + // Filter for publisher inputs + PublisherInputs *map[string]string `json:"publisherInputs,omitempty"` + // Results from the query + Results *[]Publisher `json:"results,omitempty"` +} + +// The base class for all resource containers, i.e. Account, Collection, Project +type ResourceContainer struct { + // Gets or sets the container's base URL, i.e. the URL of the host (collection, application, or deployment) containing the container resource. + BaseUrl *string `json:"baseUrl,omitempty"` + // Gets or sets the container's specific Id. + Id *uuid.UUID `json:"id,omitempty"` + // Gets or sets the container's name. + Name *string `json:"name,omitempty"` + // Gets or sets the container's REST API URL. + Url *string `json:"url,omitempty"` +} + +// Represents a session token to be attached in Events for Consumer actions that need it. +type SessionToken struct { + // The error message in case of error + Error *string `json:"error,omitempty"` + // The access token + Token *string `json:"token,omitempty"` + // The expiration date in UTC + ValidTo *azuredevops.Time `json:"validTo,omitempty"` +} + +// Encapsulates an event subscription. +type Subscription struct { + // Reference Links + Links interface{} `json:"_links,omitempty"` + ActionDescription *string `json:"actionDescription,omitempty"` + ConsumerActionId *string `json:"consumerActionId,omitempty"` + ConsumerId *string `json:"consumerId,omitempty"` + // Consumer input values + ConsumerInputs *map[string]string `json:"consumerInputs,omitempty"` + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + EventDescription *string `json:"eventDescription,omitempty"` + EventType *string `json:"eventType,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + ModifiedDate *azuredevops.Time `json:"modifiedDate,omitempty"` + ProbationRetries *byte `json:"probationRetries,omitempty"` + PublisherId *string `json:"publisherId,omitempty"` + // Publisher input values + PublisherInputs *map[string]string `json:"publisherInputs,omitempty"` + ResourceVersion *string `json:"resourceVersion,omitempty"` + Status *SubscriptionStatus `json:"status,omitempty"` + Subscriber *webapi.IdentityRef `json:"subscriber,omitempty"` + Url *string `json:"url,omitempty"` +} + +// The scope to which a subscription input applies +type SubscriptionInputScope string + +type subscriptionInputScopeValuesType struct { + Publisher SubscriptionInputScope + Consumer SubscriptionInputScope +} + +var SubscriptionInputScopeValues = subscriptionInputScopeValuesType{ + // An input defined and consumed by a Publisher or Publisher Event Type + Publisher: "publisher", + // An input defined and consumed by a Consumer or Consumer Action + Consumer: "consumer", +} + +// Query for obtaining information about the possible/allowed values for one or more subscription inputs +type SubscriptionInputValuesQuery struct { + // The input values to return on input, and the result from the consumer on output. + InputValues *[]forminput.InputValues `json:"inputValues,omitempty"` + // The scope at which the properties to query belong + Scope *SubscriptionInputScope `json:"scope,omitempty"` + // Subscription containing information about the publisher/consumer and the current input values + Subscription *Subscription `json:"subscription,omitempty"` +} + +// Defines a query for service hook subscriptions. +type SubscriptionsQuery struct { + // Optional consumer action id to restrict the results to (null for any) + ConsumerActionId *string `json:"consumerActionId,omitempty"` + // Optional consumer id to restrict the results to (null for any) + ConsumerId *string `json:"consumerId,omitempty"` + // Filter for subscription consumer inputs + ConsumerInputFilters *[]forminput.InputFilter `json:"consumerInputFilters,omitempty"` + // Optional event type id to restrict the results to (null for any) + EventType *string `json:"eventType,omitempty"` + // Optional publisher id to restrict the results to (null for any) + PublisherId *string `json:"publisherId,omitempty"` + // Filter for subscription publisher inputs + PublisherInputFilters *[]forminput.InputFilter `json:"publisherInputFilters,omitempty"` + // Results from the query + Results *[]Subscription `json:"results,omitempty"` + // Optional subscriber filter. + SubscriberId *uuid.UUID `json:"subscriberId,omitempty"` +} + +// Enumerates possible states of a subscription. +type SubscriptionStatus string + +type subscriptionStatusValuesType struct { + Enabled SubscriptionStatus + OnProbation SubscriptionStatus + DisabledByUser SubscriptionStatus + DisabledBySystem SubscriptionStatus + DisabledByInactiveIdentity SubscriptionStatus +} + +var SubscriptionStatusValues = subscriptionStatusValuesType{ + // The subscription is enabled. + Enabled: "enabled", + // The subscription is temporarily on probation by the system. + OnProbation: "onProbation", + // The subscription is disabled by a user. + DisabledByUser: "disabledByUser", + // The subscription is disabled by the system. + DisabledBySystem: "disabledBySystem", + // The subscription is disabled because the owner is inactive or is missing permissions. + DisabledByInactiveIdentity: "disabledByInactiveIdentity", +} + +// Encapsulates the resource version and its data or reference to the compatible version. Only one of the two last fields should be not null. +type VersionedResource struct { + // Gets or sets the reference to the compatible version. + CompatibleWith *string `json:"compatibleWith,omitempty"` + // Gets or sets the resource data. + Resource interface{} `json:"resource,omitempty"` + // Gets or sets the version of the resource data. + ResourceVersion *string `json:"resourceVersion,omitempty"` +} diff --git a/azuredevops/settings/client.go b/azuredevops/settings/client.go new file mode 100644 index 00000000..f4d593ca --- /dev/null +++ b/azuredevops/settings/client.go @@ -0,0 +1,262 @@ +// -------------------------------------------------------------------------------------------- +// 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 settings + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" +) + +type Client interface { + // [Preview API] Get all setting entries for the given user/all-users scope + GetEntries(context.Context, GetEntriesArgs) (*map[string]interface{}, error) + // [Preview API] Get all setting entries for the given named scope + GetEntriesForScope(context.Context, GetEntriesForScopeArgs) (*map[string]interface{}, error) + // [Preview API] Remove the entry or entries under the specified path + RemoveEntries(context.Context, RemoveEntriesArgs) error + // [Preview API] Remove the entry or entries under the specified path + RemoveEntriesForScope(context.Context, RemoveEntriesForScopeArgs) error + // [Preview API] Set the specified setting entry values for the given user/all-users scope + SetEntries(context.Context, SetEntriesArgs) error + // [Preview API] Set the specified entries for the given named scope + SetEntriesForScope(context.Context, SetEntriesForScopeArgs) 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, + } +} + +// [Preview API] Get all setting entries for the given user/all-users scope +func (client *ClientImpl) GetEntries(ctx context.Context, args GetEntriesArgs) (*map[string]interface{}, error) { + routeValues := make(map[string]string) + if args.UserScope == nil || *args.UserScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + if args.Key != nil && *args.Key != "" { + routeValues["key"] = *args.Key + } + + locationId, _ := uuid.Parse("cd006711-163d-4cd4-a597-b05bad2556ff") + 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 map[string]interface{} + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetEntries function +type GetEntriesArgs struct { + // (required) User-Scope at which to get the value. Should be "me" for the current user or "host" for all users. + UserScope *string + // (optional) Optional key under which to filter all the entries + Key *string +} + +// [Preview API] Get all setting entries for the given named scope +func (client *ClientImpl) GetEntriesForScope(ctx context.Context, args GetEntriesForScopeArgs) (*map[string]interface{}, error) { + routeValues := make(map[string]string) + if args.UserScope == nil || *args.UserScope == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + if args.ScopeName == nil || *args.ScopeName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeName"} + } + routeValues["scopeName"] = *args.ScopeName + if args.ScopeValue == nil || *args.ScopeValue == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeValue"} + } + routeValues["scopeValue"] = *args.ScopeValue + if args.Key != nil && *args.Key != "" { + routeValues["key"] = *args.Key + } + + locationId, _ := uuid.Parse("4cbaafaf-e8af-4570-98d1-79ee99c56327") + 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 map[string]interface{} + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetEntriesForScope function +type GetEntriesForScopeArgs struct { + // (required) User-Scope at which to get the value. Should be "me" for the current user or "host" for all users. + UserScope *string + // (required) Scope at which to get the setting for (e.g. "project" or "team") + ScopeName *string + // (required) Value of the scope (e.g. the project or team id) + ScopeValue *string + // (optional) Optional key under which to filter all the entries + Key *string +} + +// [Preview API] Remove the entry or entries under the specified path +func (client *ClientImpl) RemoveEntries(ctx context.Context, args RemoveEntriesArgs) error { + routeValues := make(map[string]string) + if args.UserScope == nil || *args.UserScope == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + if args.Key == nil || *args.Key == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Key"} + } + routeValues["key"] = *args.Key + + locationId, _ := uuid.Parse("cd006711-163d-4cd4-a597-b05bad2556ff") + _, 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 RemoveEntries function +type RemoveEntriesArgs struct { + // (required) User-Scope at which to remove the value. Should be "me" for the current user or "host" for all users. + UserScope *string + // (required) Root key of the entry or entries to remove + Key *string +} + +// [Preview API] Remove the entry or entries under the specified path +func (client *ClientImpl) RemoveEntriesForScope(ctx context.Context, args RemoveEntriesForScopeArgs) error { + routeValues := make(map[string]string) + if args.UserScope == nil || *args.UserScope == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + if args.ScopeName == nil || *args.ScopeName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeName"} + } + routeValues["scopeName"] = *args.ScopeName + if args.ScopeValue == nil || *args.ScopeValue == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeValue"} + } + routeValues["scopeValue"] = *args.ScopeValue + if args.Key == nil || *args.Key == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Key"} + } + routeValues["key"] = *args.Key + + locationId, _ := uuid.Parse("4cbaafaf-e8af-4570-98d1-79ee99c56327") + _, 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 RemoveEntriesForScope function +type RemoveEntriesForScopeArgs struct { + // (required) User-Scope at which to remove the value. Should be "me" for the current user or "host" for all users. + UserScope *string + // (required) Scope at which to get the setting for (e.g. "project" or "team") + ScopeName *string + // (required) Value of the scope (e.g. the project or team id) + ScopeValue *string + // (required) Root key of the entry or entries to remove + Key *string +} + +// [Preview API] Set the specified setting entry values for the given user/all-users scope +func (client *ClientImpl) SetEntries(ctx context.Context, args SetEntriesArgs) error { + if args.Entries == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Entries"} + } + routeValues := make(map[string]string) + if args.UserScope == nil || *args.UserScope == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + + body, marshalErr := json.Marshal(*args.Entries) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("cd006711-163d-4cd4-a597-b05bad2556ff") + _, 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 err + } + + return nil +} + +// Arguments for the SetEntries function +type SetEntriesArgs struct { + // (required) The entries to set + Entries *map[string]interface{} + // (required) User-Scope at which to set the values. Should be "me" for the current user or "host" for all users. + UserScope *string +} + +// [Preview API] Set the specified entries for the given named scope +func (client *ClientImpl) SetEntriesForScope(ctx context.Context, args SetEntriesForScopeArgs) error { + if args.Entries == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Entries"} + } + routeValues := make(map[string]string) + if args.UserScope == nil || *args.UserScope == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.UserScope"} + } + routeValues["userScope"] = *args.UserScope + if args.ScopeName == nil || *args.ScopeName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeName"} + } + routeValues["scopeName"] = *args.ScopeName + if args.ScopeValue == nil || *args.ScopeValue == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ScopeValue"} + } + routeValues["scopeValue"] = *args.ScopeValue + + body, marshalErr := json.Marshal(*args.Entries) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("4cbaafaf-e8af-4570-98d1-79ee99c56327") + _, 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 err + } + + return nil +} + +// Arguments for the SetEntriesForScope function +type SetEntriesForScopeArgs struct { + // (required) The entries to set + Entries *map[string]interface{} + // (required) User-Scope at which to set the values. Should be "me" for the current user or "host" for all users. + UserScope *string + // (required) Scope at which to set the settings on (e.g. "project" or "team") + ScopeName *string + // (required) Value of the scope (e.g. the project or team id) + ScopeValue *string +} diff --git a/azuredevops/symbol/client.go b/azuredevops/symbol/client.go new file mode 100644 index 00000000..c64c7d15 --- /dev/null +++ b/azuredevops/symbol/client.go @@ -0,0 +1,421 @@ +// -------------------------------------------------------------------------------------------- +// 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 symbol + +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("af607f94-69ba-4821-8159-f04e37b66350") + +type Client interface { + // [Preview API] Check the availability of symbol service. This includes checking for feature flag, and possibly license in future. Note this is NOT an anonymous endpoint, and the caller will be redirected to authentication before hitting it. + CheckAvailability(context.Context, CheckAvailabilityArgs) error + // [Preview API] Create a new symbol request. + CreateRequests(context.Context, CreateRequestsArgs) (*Request, error) + // [Preview API] Create debug entries for a symbol request as specified by its identifier. + CreateRequestsRequestIdDebugEntries(context.Context, CreateRequestsRequestIdDebugEntriesArgs) (*[]DebugEntry, error) + // [Preview API] Create debug entries for a symbol request as specified by its name. + CreateRequestsRequestNameDebugEntries(context.Context, CreateRequestsRequestNameDebugEntriesArgs) (*[]DebugEntry, error) + // [Preview API] Delete a symbol request by request identifier. + DeleteRequestsRequestId(context.Context, DeleteRequestsRequestIdArgs) error + // [Preview API] Delete a symbol request by request name. + DeleteRequestsRequestName(context.Context, DeleteRequestsRequestNameArgs) error + // [Preview API] Get the client package. + GetClient(context.Context, GetClientArgs) (interface{}, error) + // [Preview API] Get a symbol request by request identifier. + GetRequestsRequestId(context.Context, GetRequestsRequestIdArgs) (*Request, error) + // [Preview API] Get a symbol request by request name. + GetRequestsRequestName(context.Context, GetRequestsRequestNameArgs) (*Request, error) + // [Preview API] Given a client key, returns the best matched debug entry. + GetSymSrvDebugEntryClientKey(context.Context, GetSymSrvDebugEntryClientKeyArgs) error + // [Preview API] Get client version information. + HeadClient(context.Context, HeadClientArgs) error + // [Preview API] Update a symbol request by request identifier. + UpdateRequestsRequestId(context.Context, UpdateRequestsRequestIdArgs) (*Request, error) + // [Preview API] Update a symbol request by request name. + UpdateRequestsRequestName(context.Context, UpdateRequestsRequestNameArgs) (*Request, 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] Check the availability of symbol service. This includes checking for feature flag, and possibly license in future. Note this is NOT an anonymous endpoint, and the caller will be redirected to authentication before hitting it. +func (client *ClientImpl) CheckAvailability(ctx context.Context, args CheckAvailabilityArgs) error { + locationId, _ := uuid.Parse("97c893cc-e861-4ef4-8c43-9bad4a963dee") + _, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the CheckAvailability function +type CheckAvailabilityArgs struct { +} + +// [Preview API] Create a new symbol request. +func (client *ClientImpl) CreateRequests(ctx context.Context, args CreateRequestsArgs) (*Request, error) { + if args.RequestToCreate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RequestToCreate"} + } + body, marshalErr := json.Marshal(*args.RequestToCreate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ebc09fe3-1b20-4667-abc5-f2b60fe8de52") + 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 Request + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateRequests function +type CreateRequestsArgs struct { + // (required) The symbol request to create. + RequestToCreate *Request +} + +// [Preview API] Create debug entries for a symbol request as specified by its identifier. +func (client *ClientImpl) CreateRequestsRequestIdDebugEntries(ctx context.Context, args CreateRequestsRequestIdDebugEntriesArgs) (*[]DebugEntry, error) { + if args.Batch == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Batch"} + } + routeValues := make(map[string]string) + if args.RequestId == nil || *args.RequestId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RequestId"} + } + routeValues["requestId"] = *args.RequestId + + queryParams := url.Values{} + if args.Collection == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "collection"} + } + queryParams.Add("collection", *args.Collection) + body, marshalErr := json.Marshal(*args.Batch) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ebc09fe3-1b20-4667-abc5-f2b60fe8de52") + 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 []DebugEntry + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateRequestsRequestIdDebugEntries function +type CreateRequestsRequestIdDebugEntriesArgs struct { + // (required) A batch that contains debug entries to create. + Batch *DebugEntryCreateBatch + // (required) The symbol request identifier. + RequestId *string + // (required) A valid debug entry collection name. Must be "debugentries". + Collection *string +} + +// [Preview API] Create debug entries for a symbol request as specified by its name. +func (client *ClientImpl) CreateRequestsRequestNameDebugEntries(ctx context.Context, args CreateRequestsRequestNameDebugEntriesArgs) (*[]DebugEntry, error) { + if args.Batch == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Batch"} + } + queryParams := url.Values{} + if args.RequestName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "requestName"} + } + queryParams.Add("requestName", *args.RequestName) + if args.Collection == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "collection"} + } + queryParams.Add("collection", *args.Collection) + body, marshalErr := json.Marshal(*args.Batch) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ebc09fe3-1b20-4667-abc5-f2b60fe8de52") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []DebugEntry + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateRequestsRequestNameDebugEntries function +type CreateRequestsRequestNameDebugEntriesArgs struct { + // (required) A batch that contains debug entries to create. + Batch *DebugEntryCreateBatch + // (required) The symbol request name. + RequestName *string + // (required) A valid debug entry collection name. Must be "debugentries". + Collection *string +} + +// [Preview API] Delete a symbol request by request identifier. +func (client *ClientImpl) DeleteRequestsRequestId(ctx context.Context, args DeleteRequestsRequestIdArgs) error { + routeValues := make(map[string]string) + if args.RequestId == nil || *args.RequestId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RequestId"} + } + routeValues["requestId"] = *args.RequestId + + queryParams := url.Values{} + if args.Synchronous != nil { + queryParams.Add("synchronous", strconv.FormatBool(*args.Synchronous)) + } + locationId, _ := uuid.Parse("ebc09fe3-1b20-4667-abc5-f2b60fe8de52") + _, 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 DeleteRequestsRequestId function +type DeleteRequestsRequestIdArgs struct { + // (required) The symbol request identifier. + RequestId *string + // (optional) If true, delete all the debug entries under this request synchronously in the current session. If false, the deletion will be postponed to a later point and be executed automatically by the system. + Synchronous *bool +} + +// [Preview API] Delete a symbol request by request name. +func (client *ClientImpl) DeleteRequestsRequestName(ctx context.Context, args DeleteRequestsRequestNameArgs) error { + queryParams := url.Values{} + if args.RequestName == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "requestName"} + } + queryParams.Add("requestName", *args.RequestName) + if args.Synchronous != nil { + queryParams.Add("synchronous", strconv.FormatBool(*args.Synchronous)) + } + locationId, _ := uuid.Parse("ebc09fe3-1b20-4667-abc5-f2b60fe8de52") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteRequestsRequestName function +type DeleteRequestsRequestNameArgs struct { + // (required) The symbol request name. + RequestName *string + // (optional) If true, delete all the debug entries under this request synchronously in the current session. If false, the deletion will be postponed to a later point and be executed automatically by the system. + Synchronous *bool +} + +// [Preview API] Get the client package. +func (client *ClientImpl) GetClient(ctx context.Context, args GetClientArgs) (interface{}, error) { + routeValues := make(map[string]string) + if args.ClientType == nil || *args.ClientType == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ClientType"} + } + routeValues["clientType"] = *args.ClientType + + locationId, _ := uuid.Parse("79c83865-4de3-460c-8a16-01be238e0818") + 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 GetClient function +type GetClientArgs struct { + // (required) Either "EXE" for a zip file containing a Windows symbol client (a.k.a. symbol.exe) along with dependencies, or "TASK" for a VSTS task that can be run on a VSTS build agent. All the other values are invalid. The parameter is case-insensitive. + ClientType *string +} + +// [Preview API] Get a symbol request by request identifier. +func (client *ClientImpl) GetRequestsRequestId(ctx context.Context, args GetRequestsRequestIdArgs) (*Request, error) { + routeValues := make(map[string]string) + if args.RequestId == nil || *args.RequestId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RequestId"} + } + routeValues["requestId"] = *args.RequestId + + locationId, _ := uuid.Parse("ebc09fe3-1b20-4667-abc5-f2b60fe8de52") + 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 Request + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRequestsRequestId function +type GetRequestsRequestIdArgs struct { + // (required) The symbol request identifier. + RequestId *string +} + +// [Preview API] Get a symbol request by request name. +func (client *ClientImpl) GetRequestsRequestName(ctx context.Context, args GetRequestsRequestNameArgs) (*Request, error) { + queryParams := url.Values{} + if args.RequestName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "requestName"} + } + queryParams.Add("requestName", *args.RequestName) + locationId, _ := uuid.Parse("ebc09fe3-1b20-4667-abc5-f2b60fe8de52") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Request + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRequestsRequestName function +type GetRequestsRequestNameArgs struct { + // (required) The symbol request name. + RequestName *string +} + +// [Preview API] Given a client key, returns the best matched debug entry. +func (client *ClientImpl) GetSymSrvDebugEntryClientKey(ctx context.Context, args GetSymSrvDebugEntryClientKeyArgs) error { + routeValues := make(map[string]string) + if args.DebugEntryClientKey == nil || *args.DebugEntryClientKey == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.DebugEntryClientKey"} + } + routeValues["debugEntryClientKey"] = *args.DebugEntryClientKey + + locationId, _ := uuid.Parse("9648e256-c9f9-4f16-8a27-630b06396942") + _, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the GetSymSrvDebugEntryClientKey function +type GetSymSrvDebugEntryClientKeyArgs struct { + // (required) A "client key" used by both ends of Microsoft's symbol protocol to identify a debug entry. The semantics of client key is governed by symsrv and is beyond the scope of this documentation. + DebugEntryClientKey *string +} + +// [Preview API] Get client version information. +func (client *ClientImpl) HeadClient(ctx context.Context, args HeadClientArgs) error { + locationId, _ := uuid.Parse("79c83865-4de3-460c-8a16-01be238e0818") + _, err := client.Client.Send(ctx, http.MethodHead, locationId, "5.1-preview.1", nil, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the HeadClient function +type HeadClientArgs struct { +} + +// [Preview API] Update a symbol request by request identifier. +func (client *ClientImpl) UpdateRequestsRequestId(ctx context.Context, args UpdateRequestsRequestIdArgs) (*Request, error) { + if args.UpdateRequest == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateRequest"} + } + routeValues := make(map[string]string) + if args.RequestId == nil || *args.RequestId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.RequestId"} + } + routeValues["requestId"] = *args.RequestId + + body, marshalErr := json.Marshal(*args.UpdateRequest) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ebc09fe3-1b20-4667-abc5-f2b60fe8de52") + 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 Request + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateRequestsRequestId function +type UpdateRequestsRequestIdArgs struct { + // (required) The symbol request. + UpdateRequest *Request + // (required) The symbol request identifier. + RequestId *string +} + +// [Preview API] Update a symbol request by request name. +func (client *ClientImpl) UpdateRequestsRequestName(ctx context.Context, args UpdateRequestsRequestNameArgs) (*Request, error) { + if args.UpdateRequest == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateRequest"} + } + queryParams := url.Values{} + if args.RequestName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "requestName"} + } + queryParams.Add("requestName", *args.RequestName) + body, marshalErr := json.Marshal(*args.UpdateRequest) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ebc09fe3-1b20-4667-abc5-f2b60fe8de52") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", nil, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Request + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateRequestsRequestName function +type UpdateRequestsRequestNameArgs struct { + // (required) The symbol request. + UpdateRequest *Request + // (required) The symbol request name. + RequestName *string +} diff --git a/azuredevops/symbol/models.go b/azuredevops/symbol/models.go new file mode 100644 index 00000000..5732a926 --- /dev/null +++ b/azuredevops/symbol/models.go @@ -0,0 +1,161 @@ +// -------------------------------------------------------------------------------------------- +// 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 symbol + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/symbolcommon" +) + +// A dual-purpose data object, the debug entry is used by the client to publish the symbol file (with file's blob identifier, which can be calculated from VSTS hashing algorithm) or query the file (with a client key). Since the symbol server tries to return a matched symbol file with the richest information level, it may not always point to the same symbol file for different queries with same client key. +type DebugEntry struct { + // The ID of user who created this item. Optional. + CreatedBy *uuid.UUID `json:"createdBy,omitempty"` + // The date time when this item is created. Optional. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // An identifier for this item. Optional. + Id *string `json:"id,omitempty"` + // An opaque ETag used to synchronize with the version stored at server end. Optional. + StorageETag *string `json:"storageETag,omitempty"` + // A URI which can be used to retrieve this item in its raw format. Optional. Note this is distinguished from other URIs that are present in a derived resource. + Url *string `json:"url,omitempty"` + // Details of the blob formatted to be deserialized for symbol service. + BlobDetails *JsonBlobIdentifierWithBlocks `json:"blobDetails,omitempty"` + // A blob identifier of the symbol file to upload to this debug entry. This property is mostly used during creation of debug entry (a.k.a. symbol publishing) to allow the server to query the existence of the blob. + BlobIdentifier *JsonBlobIdentifier `json:"blobIdentifier,omitempty"` + // The URI to get the symbol file. Provided by the server, the URI contains authentication information and is readily accessible by plain HTTP GET request. The client is recommended to retrieve the file as soon as it can since the URI will expire in a short period. + BlobUri *string `json:"blobUri,omitempty"` + // A key the client (debugger, for example) uses to find the debug entry. Note it is not unique for each different symbol file as it does not distinguish between those which only differ by information level. + ClientKey *string `json:"clientKey,omitempty"` + // The information level this debug entry contains. + InformationLevel *symbolcommon.DebugInformationLevel `json:"informationLevel,omitempty"` + // The identifier of symbol request to which this debug entry belongs. + RequestId *string `json:"requestId,omitempty"` + // The status of debug entry. + Status *DebugEntryStatus `json:"status,omitempty"` +} + +// A batch of debug entry to create. +type DebugEntryCreateBatch struct { + // Defines what to do when a debug entry in the batch already exists. + CreateBehavior *DebugEntryCreateBehavior `json:"createBehavior,omitempty"` + // The debug entries. + DebugEntries *[]DebugEntry `json:"debugEntries,omitempty"` +} + +// The expected behavior when a debug entry to add already exists. +type DebugEntryCreateBehavior string + +type debugEntryCreateBehaviorValuesType struct { + ThrowIfExists DebugEntryCreateBehavior + SkipIfExists DebugEntryCreateBehavior + OverwriteIfExists DebugEntryCreateBehavior +} + +var DebugEntryCreateBehaviorValues = debugEntryCreateBehaviorValuesType{ + // Throw exceptions at server end. This will translate to 409 (Conflict) HTTP status code. + ThrowIfExists: "throwIfExists", + // Do not add this debug entry. The rest of the batch, if any, is not affected. + SkipIfExists: "skipIfExists", + // Overwrite the existing debug entry. + OverwriteIfExists: "overwriteIfExists", +} + +// The status of debug entry. +type DebugEntryStatus string + +type debugEntryStatusValuesType struct { + None DebugEntryStatus + Created DebugEntryStatus + BlobMissing DebugEntryStatus +} + +var DebugEntryStatusValues = debugEntryStatusValuesType{ + // The status of this debug entry is undefined or irrelevant in the current context. + None: "none", + // The debug entry is created and read to use. + Created: "created", + // The symbol file for the requested debug entry is missing. + BlobMissing: "blobMissing", +} + +// BlobBlock hash formatted to be deserialized for symbol service. +type JsonBlobBlockHash struct { + // Array of hash bytes. + HashBytes *[]byte `json:"hashBytes,omitempty"` +} + +type JsonBlobIdentifier struct { + IdentifierValue *[]byte `json:"identifierValue,omitempty"` +} + +// BlobIdentifier with block hashes formatted to be deserialzied for symbol service. +type JsonBlobIdentifierWithBlocks struct { + // List of blob block hashes. + BlockHashes *[]JsonBlobBlockHash `json:"blockHashes,omitempty"` + // Array of blobId bytes. + IdentifierValue *[]byte `json:"identifierValue,omitempty"` +} + +// Symbol request. +type Request struct { + // The ID of user who created this item. Optional. + CreatedBy *uuid.UUID `json:"createdBy,omitempty"` + // The date time when this item is created. Optional. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // An identifier for this item. Optional. + Id *string `json:"id,omitempty"` + // An opaque ETag used to synchronize with the version stored at server end. Optional. + StorageETag *string `json:"storageETag,omitempty"` + // A URI which can be used to retrieve this item in its raw format. Optional. Note this is distinguished from other URIs that are present in a derived resource. + Url *string `json:"url,omitempty"` + // An optional human-facing description. + Description *string `json:"description,omitempty"` + // An optional expiration date for the request. The request will become inaccessible and get deleted after the date, regardless of its status. On an HTTP POST, if expiration date is null/missing, the server will assign a default expiration data (30 days unless overwridden in the registry at the account level). On PATCH, if expiration date is null/missing, the behavior is to not change whatever the request's current expiration date is. + ExpirationDate *azuredevops.Time `json:"expirationDate,omitempty"` + // A human-facing name for the request. Required on POST, ignored on PATCH. + Name *string `json:"name,omitempty"` + // The status for this request. + Status *RequestStatus `json:"status,omitempty"` +} + +// The status of request. +type RequestStatus string + +type requestStatusValuesType struct { + None RequestStatus + Created RequestStatus + Sealed RequestStatus + Unavailable RequestStatus +} + +var RequestStatusValues = requestStatusValuesType{ + // The status of this request is undefined or irrelevant in the current context. + None: "none", + // The request is created, and is open to accepting debug entries. + Created: "created", + // The request is sealed. No more debug entries can be added to it. + Sealed: "sealed", + // The request is no longer available, possibly deleted. + Unavailable: "unavailable", +} + +type ResourceBase struct { + // The ID of user who created this item. Optional. + CreatedBy *uuid.UUID `json:"createdBy,omitempty"` + // The date time when this item is created. Optional. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // An identifier for this item. Optional. + Id *string `json:"id,omitempty"` + // An opaque ETag used to synchronize with the version stored at server end. Optional. + StorageETag *string `json:"storageETag,omitempty"` + // A URI which can be used to retrieve this item in its raw format. Optional. Note this is distinguished from other URIs that are present in a derived resource. + Url *string `json:"url,omitempty"` +} diff --git a/azuredevops/symbolcommon/models.go b/azuredevops/symbolcommon/models.go new file mode 100644 index 00000000..4d31c611 --- /dev/null +++ b/azuredevops/symbolcommon/models.go @@ -0,0 +1,45 @@ +// -------------------------------------------------------------------------------------------- +// 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 symbolcommon + +// [Flags] Defines the level of debug-related information inside the .pdb file. These values can be combined together (bitwise OR'ed) to create a customized level. +type DebugInformationLevel string + +type debugInformationLevelValuesType struct { + None DebugInformationLevel + Binary DebugInformationLevel + Publics DebugInformationLevel + TraceFormatPresent DebugInformationLevel + TypeInfo DebugInformationLevel + LineNumbers DebugInformationLevel + GlobalSymbols DebugInformationLevel + Private DebugInformationLevel + SourceIndexed DebugInformationLevel +} + +var DebugInformationLevelValues = debugInformationLevelValuesType{ + // If set, the .pdb file contains no debug information. + None: "none", + // If set, the .pdb file contains debug information which is binary. + Binary: "binary", + // If set, the .pdb file contains public symbols. + Publics: "publics", + // If set, the .pdb file contains trace format. + TraceFormatPresent: "traceFormatPresent", + // If set, the .pdb file contains type information. + TypeInfo: "typeInfo", + // If set, the .pdb file contains line number information. + LineNumbers: "lineNumbers", + // If set, the .pdb file contains symbol information. + GlobalSymbols: "globalSymbols", + // If set, the .pdb file contains public symbols and has type, line number and symbol information. + Private: "private", + // If set, the .pdb file supports the source server. + SourceIndexed: "sourceIndexed", +} diff --git a/azuredevops/system/models.go b/azuredevops/system/models.go new file mode 100644 index 00000000..245ca996 --- /dev/null +++ b/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/azuredevops/task/client.go b/azuredevops/task/client.go new file mode 100644 index 00000000..e9447358 --- /dev/null +++ b/azuredevops/task/client.go @@ -0,0 +1,793 @@ +// -------------------------------------------------------------------------------------------- +// 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 task + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "io" + "net/http" + "net/url" + "strconv" +) + +type Client interface { + AppendLogContent(context.Context, AppendLogContentArgs) (*TaskLog, error) + // [Preview API] + CreateAttachment(context.Context, CreateAttachmentArgs) (*TaskAttachment, error) + CreateLog(context.Context, CreateLogArgs) (*TaskLog, error) + CreateTimeline(context.Context, CreateTimelineArgs) (*Timeline, error) + DeleteTimeline(context.Context, DeleteTimelineArgs) error + // [Preview API] + GetAttachment(context.Context, GetAttachmentArgs) (*TaskAttachment, error) + // [Preview API] + GetAttachmentContent(context.Context, GetAttachmentContentArgs) (io.ReadCloser, error) + // [Preview API] + GetAttachments(context.Context, GetAttachmentsArgs) (*[]TaskAttachment, error) + GetLog(context.Context, GetLogArgs) (*[]string, error) + GetLogs(context.Context, GetLogsArgs) (*[]TaskLog, error) + // [Preview API] + GetPlanAttachments(context.Context, GetPlanAttachmentsArgs) (*[]TaskAttachment, error) + GetRecords(context.Context, GetRecordsArgs) (*[]TimelineRecord, error) + GetTimeline(context.Context, GetTimelineArgs) (*Timeline, error) + GetTimelines(context.Context, GetTimelinesArgs) (*[]Timeline, error) + UpdateRecords(context.Context, UpdateRecordsArgs) (*[]TimelineRecord, 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, + } +} + +func (client *ClientImpl) AppendLogContent(ctx context.Context, args AppendLogContentArgs) (*TaskLog, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.LogId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.LogId"} + } + routeValues["logId"] = strconv.Itoa(*args.LogId) + + locationId, _ := uuid.Parse("46f5667d-263a-4684-91b1-dff7fdcf64e2") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, args.UploadStream, "application/octet-stream", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue TaskLog + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AppendLogContent function +type AppendLogContentArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID + // (required) + LogId *int +} + +// [Preview API] +func (client *ClientImpl) CreateAttachment(ctx context.Context, args CreateAttachmentArgs) (*TaskAttachment, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.TimelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} + } + routeValues["timelineId"] = (*args.TimelineId).String() + if args.RecordId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RecordId"} + } + routeValues["recordId"] = (*args.RecordId).String() + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + locationId, _ := uuid.Parse("7898f959-9cdf-4096-b29e-7f293031629e") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, nil, args.UploadStream, "application/octet-stream", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue TaskAttachment + 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 project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID + // (required) + TimelineId *uuid.UUID + // (required) + RecordId *uuid.UUID + // (required) + Type *string + // (required) + Name *string +} + +func (client *ClientImpl) CreateLog(ctx context.Context, args CreateLogArgs) (*TaskLog, error) { + if args.Log == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Log"} + } + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + + body, marshalErr := json.Marshal(*args.Log) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("46f5667d-263a-4684-91b1-dff7fdcf64e2") + 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 TaskLog + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateLog function +type CreateLogArgs struct { + // (required) + Log *TaskLog + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID +} + +func (client *ClientImpl) CreateTimeline(ctx context.Context, args CreateTimelineArgs) (*Timeline, error) { + if args.Timeline == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Timeline"} + } + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + + body, marshalErr := json.Marshal(*args.Timeline) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("83597576-cc2c-453c-bea6-2882ae6a1653") + 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 Timeline + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTimeline function +type CreateTimelineArgs struct { + // (required) + Timeline *Timeline + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID +} + +func (client *ClientImpl) DeleteTimeline(ctx context.Context, args DeleteTimelineArgs) error { + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.TimelineId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} + } + routeValues["timelineId"] = (*args.TimelineId).String() + + locationId, _ := uuid.Parse("83597576-cc2c-453c-bea6-2882ae6a1653") + _, 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 DeleteTimeline function +type DeleteTimelineArgs struct { + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID + // (required) + TimelineId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) GetAttachment(ctx context.Context, args GetAttachmentArgs) (*TaskAttachment, error) { + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.TimelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} + } + routeValues["timelineId"] = (*args.TimelineId).String() + if args.RecordId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RecordId"} + } + routeValues["recordId"] = (*args.RecordId).String() + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + locationId, _ := uuid.Parse("7898f959-9cdf-4096-b29e-7f293031629e") + 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 TaskAttachment + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAttachment function +type GetAttachmentArgs struct { + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID + // (required) + TimelineId *uuid.UUID + // (required) + RecordId *uuid.UUID + // (required) + Type *string + // (required) + Name *string +} + +// [Preview API] +func (client *ClientImpl) GetAttachmentContent(ctx context.Context, args GetAttachmentContentArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.TimelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} + } + routeValues["timelineId"] = (*args.TimelineId).String() + if args.RecordId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RecordId"} + } + routeValues["recordId"] = (*args.RecordId).String() + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + locationId, _ := uuid.Parse("7898f959-9cdf-4096-b29e-7f293031629e") + 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 project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID + // (required) + TimelineId *uuid.UUID + // (required) + RecordId *uuid.UUID + // (required) + Type *string + // (required) + Name *string +} + +// [Preview API] +func (client *ClientImpl) GetAttachments(ctx context.Context, args GetAttachmentsArgs) (*[]TaskAttachment, error) { + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.TimelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} + } + routeValues["timelineId"] = (*args.TimelineId).String() + if args.RecordId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RecordId"} + } + routeValues["recordId"] = (*args.RecordId).String() + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + + locationId, _ := uuid.Parse("7898f959-9cdf-4096-b29e-7f293031629e") + 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 []TaskAttachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAttachments function +type GetAttachmentsArgs struct { + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID + // (required) + TimelineId *uuid.UUID + // (required) + RecordId *uuid.UUID + // (required) + Type *string +} + +func (client *ClientImpl) GetLog(ctx context.Context, args GetLogArgs) (*[]string, error) { + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.LogId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.LogId"} + } + routeValues["logId"] = strconv.Itoa(*args.LogId) + + queryParams := url.Values{} + if args.StartLine != nil { + queryParams.Add("startLine", strconv.FormatUint(*args.StartLine, 10)) + } + if args.EndLine != nil { + queryParams.Add("endLine", strconv.FormatUint(*args.EndLine, 10)) + } + locationId, _ := uuid.Parse("46f5667d-263a-4684-91b1-dff7fdcf64e2") + 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 []string + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetLog function +type GetLogArgs struct { + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID + // (required) + LogId *int + // (optional) + StartLine *uint64 + // (optional) + EndLine *uint64 +} + +func (client *ClientImpl) GetLogs(ctx context.Context, args GetLogsArgs) (*[]TaskLog, error) { + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + + locationId, _ := uuid.Parse("46f5667d-263a-4684-91b1-dff7fdcf64e2") + 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 []TaskLog + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetLogs function +type GetLogsArgs struct { + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID +} + +// [Preview API] +func (client *ClientImpl) GetPlanAttachments(ctx context.Context, args GetPlanAttachmentsArgs) (*[]TaskAttachment, error) { + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + + locationId, _ := uuid.Parse("eb55e5d6-2f30-4295-b5ed-38da50b1fc52") + 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 []TaskAttachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPlanAttachments function +type GetPlanAttachmentsArgs struct { + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID + // (required) + Type *string +} + +func (client *ClientImpl) GetRecords(ctx context.Context, args GetRecordsArgs) (*[]TimelineRecord, error) { + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.TimelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} + } + routeValues["timelineId"] = (*args.TimelineId).String() + + queryParams := url.Values{} + if args.ChangeId != nil { + queryParams.Add("changeId", strconv.Itoa(*args.ChangeId)) + } + locationId, _ := uuid.Parse("8893bc5b-35b2-4be7-83cb-99e683551db4") + 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 []TimelineRecord + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRecords function +type GetRecordsArgs struct { + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID + // (required) + TimelineId *uuid.UUID + // (optional) + ChangeId *int +} + +func (client *ClientImpl) GetTimeline(ctx context.Context, args GetTimelineArgs) (*Timeline, error) { + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.TimelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} + } + routeValues["timelineId"] = (*args.TimelineId).String() + + queryParams := url.Values{} + if args.ChangeId != nil { + queryParams.Add("changeId", strconv.Itoa(*args.ChangeId)) + } + if args.IncludeRecords != nil { + queryParams.Add("includeRecords", strconv.FormatBool(*args.IncludeRecords)) + } + locationId, _ := uuid.Parse("83597576-cc2c-453c-bea6-2882ae6a1653") + 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 Timeline + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTimeline function +type GetTimelineArgs struct { + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID + // (required) + TimelineId *uuid.UUID + // (optional) + ChangeId *int + // (optional) + IncludeRecords *bool +} + +func (client *ClientImpl) GetTimelines(ctx context.Context, args GetTimelinesArgs) (*[]Timeline, error) { + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + + locationId, _ := uuid.Parse("83597576-cc2c-453c-bea6-2882ae6a1653") + 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 []Timeline + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTimelines function +type GetTimelinesArgs struct { + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID +} + +func (client *ClientImpl) UpdateRecords(ctx context.Context, args UpdateRecordsArgs) (*[]TimelineRecord, error) { + if args.Records == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Records"} + } + routeValues := make(map[string]string) + if args.ScopeIdentifier == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ScopeIdentifier"} + } + routeValues["scopeIdentifier"] = (*args.ScopeIdentifier).String() + if args.HubName == nil || *args.HubName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.HubName"} + } + routeValues["hubName"] = *args.HubName + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.TimelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} + } + routeValues["timelineId"] = (*args.TimelineId).String() + + body, marshalErr := json.Marshal(*args.Records) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("8893bc5b-35b2-4be7-83cb-99e683551db4") + 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 []TimelineRecord + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateRecords function +type UpdateRecordsArgs struct { + // (required) + Records *azuredevops.VssJsonCollectionWrapper + // (required) The project GUID to scope the request + ScopeIdentifier *uuid.UUID + // (required) The name of the server hub: "build" for the Build server or "rm" for the Release Management server + HubName *string + // (required) + PlanId *uuid.UUID + // (required) + TimelineId *uuid.UUID +} diff --git a/azuredevops/task/models.go b/azuredevops/task/models.go new file mode 100644 index 00000000..38910fb7 --- /dev/null +++ b/azuredevops/task/models.go @@ -0,0 +1,372 @@ +// -------------------------------------------------------------------------------------------- +// 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 task + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" +) + +type Issue struct { + Category *string `json:"category,omitempty"` + Data *map[string]string `json:"data,omitempty"` + Message *string `json:"message,omitempty"` + Type *IssueType `json:"type,omitempty"` +} + +type IssueType string + +type issueTypeValuesType struct { + Error IssueType + Warning IssueType +} + +var IssueTypeValues = issueTypeValuesType{ + Error: "error", + Warning: "warning", +} + +// Represents an option that may affect the way an agent runs the job. +type JobOption struct { + Data *map[string]string `json:"data,omitempty"` + // Gets the id of the option. + Id *uuid.UUID `json:"id,omitempty"` +} + +type MaskHint struct { + Type *MaskType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +type MaskType string + +type maskTypeValuesType struct { + Variable MaskType + Regex MaskType +} + +var MaskTypeValues = maskTypeValuesType{ + Variable: "variable", + Regex: "regex", +} + +type PlanEnvironment struct { + Mask *[]MaskHint `json:"mask,omitempty"` + Options *map[uuid.UUID]JobOption `json:"options,omitempty"` + Variables *map[string]string `json:"variables,omitempty"` +} + +// [Flags] +type PlanGroupStatus string + +type planGroupStatusValuesType struct { + Running PlanGroupStatus + Queued PlanGroupStatus + All PlanGroupStatus +} + +var PlanGroupStatusValues = planGroupStatusValuesType{ + Running: "running", + Queued: "queued", + All: "all", +} + +type ProjectReference struct { + Id *uuid.UUID `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type TaskAgentJob struct { + Container *string `json:"container,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + SidecarContainers *map[string]string `json:"sidecarContainers,omitempty"` + Steps *[]TaskAgentJobStep `json:"steps,omitempty"` + Variables *[]TaskAgentJobVariable `json:"variables,omitempty"` +} + +type TaskAgentJobStep struct { + Condition *string `json:"condition,omitempty"` + ContinueOnError *bool `json:"continueOnError,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Env *map[string]string `json:"env,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Inputs *map[string]string `json:"inputs,omitempty"` + Name *string `json:"name,omitempty"` + Task *TaskAgentJobTask `json:"task,omitempty"` + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + Type *TaskAgentJobStepType `json:"type,omitempty"` +} + +type TaskAgentJobStepType string + +type taskAgentJobStepTypeValuesType struct { + Task TaskAgentJobStepType + Action TaskAgentJobStepType +} + +var TaskAgentJobStepTypeValues = taskAgentJobStepTypeValuesType{ + Task: "task", + Action: "action", +} + +type TaskAgentJobTask struct { + Id *uuid.UUID `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +type TaskAgentJobVariable struct { + Name *string `json:"name,omitempty"` + Secret *bool `json:"secret,omitempty"` + Value *string `json:"value,omitempty"` +} + +type TaskAttachment struct { + Links interface{} `json:"_links,omitempty"` + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + LastChangedBy *uuid.UUID `json:"lastChangedBy,omitempty"` + LastChangedOn *azuredevops.Time `json:"lastChangedOn,omitempty"` + Name *string `json:"name,omitempty"` + RecordId *uuid.UUID `json:"recordId,omitempty"` + TimelineId *uuid.UUID `json:"timelineId,omitempty"` + Type *string `json:"type,omitempty"` +} + +type TaskLog struct { + Id *int `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + IndexLocation *string `json:"indexLocation,omitempty"` + LastChangedOn *azuredevops.Time `json:"lastChangedOn,omitempty"` + LineCount *uint64 `json:"lineCount,omitempty"` + Path *string `json:"path,omitempty"` +} + +type TaskLogReference struct { + Id *int `json:"id,omitempty"` + Location *string `json:"location,omitempty"` +} + +type TaskOrchestrationContainer struct { + ItemType *TaskOrchestrationItemType `json:"itemType,omitempty"` + Children *[]TaskOrchestrationItem `json:"children,omitempty"` + ContinueOnError *bool `json:"continueOnError,omitempty"` + Data *map[string]string `json:"data,omitempty"` + MaxConcurrency *int `json:"maxConcurrency,omitempty"` + Parallel *bool `json:"parallel,omitempty"` + Rollback *TaskOrchestrationContainer `json:"rollback,omitempty"` +} + +type TaskOrchestrationItem struct { + ItemType *TaskOrchestrationItemType `json:"itemType,omitempty"` +} + +type TaskOrchestrationItemType string + +type taskOrchestrationItemTypeValuesType struct { + Container TaskOrchestrationItemType + Job TaskOrchestrationItemType +} + +var TaskOrchestrationItemTypeValues = taskOrchestrationItemTypeValuesType{ + Container: "container", + Job: "job", +} + +type TaskOrchestrationOwner struct { + Links interface{} `json:"_links,omitempty"` + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type TaskOrchestrationPlan struct { + ArtifactLocation *string `json:"artifactLocation,omitempty"` + ArtifactUri *string `json:"artifactUri,omitempty"` + Definition *TaskOrchestrationOwner `json:"definition,omitempty"` + Owner *TaskOrchestrationOwner `json:"owner,omitempty"` + PlanGroup *string `json:"planGroup,omitempty"` + PlanId *uuid.UUID `json:"planId,omitempty"` + PlanType *string `json:"planType,omitempty"` + ScopeIdentifier *uuid.UUID `json:"scopeIdentifier,omitempty"` + Version *int `json:"version,omitempty"` + Environment *PlanEnvironment `json:"environment,omitempty"` + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + Implementation *TaskOrchestrationContainer `json:"implementation,omitempty"` + InitializationLog *TaskLogReference `json:"initializationLog,omitempty"` + RequestedById *uuid.UUID `json:"requestedById,omitempty"` + RequestedForId *uuid.UUID `json:"requestedForId,omitempty"` + Result *TaskResult `json:"result,omitempty"` + ResultCode *string `json:"resultCode,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + State *TaskOrchestrationPlanState `json:"state,omitempty"` + Timeline *TimelineReference `json:"timeline,omitempty"` +} + +type TaskOrchestrationPlanGroupsQueueMetrics struct { + Count *int `json:"count,omitempty"` + Status *PlanGroupStatus `json:"status,omitempty"` +} + +type TaskOrchestrationPlanReference struct { + ArtifactLocation *string `json:"artifactLocation,omitempty"` + ArtifactUri *string `json:"artifactUri,omitempty"` + Definition *TaskOrchestrationOwner `json:"definition,omitempty"` + Owner *TaskOrchestrationOwner `json:"owner,omitempty"` + PlanGroup *string `json:"planGroup,omitempty"` + PlanId *uuid.UUID `json:"planId,omitempty"` + PlanType *string `json:"planType,omitempty"` + ScopeIdentifier *uuid.UUID `json:"scopeIdentifier,omitempty"` + Version *int `json:"version,omitempty"` +} + +type TaskOrchestrationPlanState string + +type taskOrchestrationPlanStateValuesType struct { + InProgress TaskOrchestrationPlanState + Queued TaskOrchestrationPlanState + Completed TaskOrchestrationPlanState + Throttled TaskOrchestrationPlanState +} + +var TaskOrchestrationPlanStateValues = taskOrchestrationPlanStateValuesType{ + InProgress: "inProgress", + Queued: "queued", + Completed: "completed", + Throttled: "throttled", +} + +type TaskOrchestrationQueuedPlan struct { + AssignTime *azuredevops.Time `json:"assignTime,omitempty"` + Definition *TaskOrchestrationOwner `json:"definition,omitempty"` + Owner *TaskOrchestrationOwner `json:"owner,omitempty"` + PlanGroup *string `json:"planGroup,omitempty"` + PlanId *uuid.UUID `json:"planId,omitempty"` + PoolId *int `json:"poolId,omitempty"` + QueuePosition *int `json:"queuePosition,omitempty"` + QueueTime *azuredevops.Time `json:"queueTime,omitempty"` + ScopeIdentifier *uuid.UUID `json:"scopeIdentifier,omitempty"` +} + +type TaskOrchestrationQueuedPlanGroup struct { + Definition *TaskOrchestrationOwner `json:"definition,omitempty"` + Owner *TaskOrchestrationOwner `json:"owner,omitempty"` + PlanGroup *string `json:"planGroup,omitempty"` + Plans *[]TaskOrchestrationQueuedPlan `json:"plans,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + QueuePosition *int `json:"queuePosition,omitempty"` +} + +type TaskReference struct { + Id *uuid.UUID `json:"id,omitempty"` + Inputs *map[string]string `json:"inputs,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +type TaskResult string + +type taskResultValuesType struct { + Succeeded TaskResult + SucceededWithIssues TaskResult + Failed TaskResult + Canceled TaskResult + Skipped TaskResult + Abandoned TaskResult +} + +var TaskResultValues = taskResultValuesType{ + Succeeded: "succeeded", + SucceededWithIssues: "succeededWithIssues", + Failed: "failed", + Canceled: "canceled", + Skipped: "skipped", + Abandoned: "abandoned", +} + +type Timeline struct { + ChangeId *int `json:"changeId,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + LastChangedBy *uuid.UUID `json:"lastChangedBy,omitempty"` + LastChangedOn *azuredevops.Time `json:"lastChangedOn,omitempty"` + Records *[]TimelineRecord `json:"records,omitempty"` +} + +type TimelineAttempt struct { + // Gets or sets the attempt of the record. + Attempt *int `json:"attempt,omitempty"` + // Gets or sets the unique identifier for the record. + Identifier *string `json:"identifier,omitempty"` + // Gets or sets the record identifier located within the specified timeline. + RecordId *uuid.UUID `json:"recordId,omitempty"` + // Gets or sets the timeline identifier which owns the record representing this attempt. + TimelineId *uuid.UUID `json:"timelineId,omitempty"` +} + +type TimelineRecord struct { + Attempt *int `json:"attempt,omitempty"` + ChangeId *int `json:"changeId,omitempty"` + CurrentOperation *string `json:"currentOperation,omitempty"` + Details *TimelineReference `json:"details,omitempty"` + ErrorCount *int `json:"errorCount,omitempty"` + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Identifier *string `json:"identifier,omitempty"` + Issues *[]Issue `json:"issues,omitempty"` + LastModified *azuredevops.Time `json:"lastModified,omitempty"` + Location *string `json:"location,omitempty"` + Log *TaskLogReference `json:"log,omitempty"` + Name *string `json:"name,omitempty"` + Order *int `json:"order,omitempty"` + ParentId *uuid.UUID `json:"parentId,omitempty"` + PercentComplete *int `json:"percentComplete,omitempty"` + PreviousAttempts *[]TimelineAttempt `json:"previousAttempts,omitempty"` + RefName *string `json:"refName,omitempty"` + Result *TaskResult `json:"result,omitempty"` + ResultCode *string `json:"resultCode,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + State *TimelineRecordState `json:"state,omitempty"` + Task *TaskReference `json:"task,omitempty"` + Type *string `json:"type,omitempty"` + Variables *map[string]VariableValue `json:"variables,omitempty"` + WarningCount *int `json:"warningCount,omitempty"` + WorkerName *string `json:"workerName,omitempty"` +} + +type TimelineRecordFeedLinesWrapper struct { + Count *int `json:"count,omitempty"` + StepId *uuid.UUID `json:"stepId,omitempty"` + Value *[]string `json:"value,omitempty"` +} + +type TimelineRecordState string + +type timelineRecordStateValuesType struct { + Pending TimelineRecordState + InProgress TimelineRecordState + Completed TimelineRecordState +} + +var TimelineRecordStateValues = timelineRecordStateValuesType{ + Pending: "pending", + InProgress: "inProgress", + Completed: "completed", +} + +type TimelineReference struct { + ChangeId *int `json:"changeId,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Location *string `json:"location,omitempty"` +} + +type VariableValue struct { + IsSecret *bool `json:"isSecret,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/azuredevops/taskagent/client.go b/azuredevops/taskagent/client.go new file mode 100644 index 00000000..672ab3d2 --- /dev/null +++ b/azuredevops/taskagent/client.go @@ -0,0 +1,1757 @@ +// -------------------------------------------------------------------------------------------- +// 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 taskagent + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("a85b8835-c1a1-4aac-ae97-1c3d0ba72dbd") + +type Client interface { + // Adds an agent to a pool. You probably don't want to call this endpoint directly. Instead, [configure an agent](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) using the agent download package. + AddAgent(context.Context, AddAgentArgs) (*TaskAgent, error) + // [Preview API] + AddAgentCloud(context.Context, AddAgentCloudArgs) (*TaskAgentCloud, error) + // Create an agent pool. + AddAgentPool(context.Context, AddAgentPoolArgs) (*TaskAgentPool, error) + // [Preview API] Create a new agent queue to connect a project to an agent pool. + AddAgentQueue(context.Context, AddAgentQueueArgs) (*TaskAgentQueue, error) + // [Preview API] Create a deployment group. + AddDeploymentGroup(context.Context, AddDeploymentGroupArgs) (*DeploymentGroup, error) + // [Preview API] Create a task group. + AddTaskGroup(context.Context, AddTaskGroupArgs) (*TaskGroup, error) + // [Preview API] Add a variable group. + AddVariableGroup(context.Context, AddVariableGroupArgs) (*VariableGroup, error) + // Delete an agent. You probably don't want to call this endpoint directly. Instead, [use the agent configuration script](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) to remove an agent from your organization. + DeleteAgent(context.Context, DeleteAgentArgs) error + // [Preview API] + DeleteAgentCloud(context.Context, DeleteAgentCloudArgs) (*TaskAgentCloud, error) + // Delete an agent pool. + DeleteAgentPool(context.Context, DeleteAgentPoolArgs) error + // [Preview API] Removes an agent queue from a project. + DeleteAgentQueue(context.Context, DeleteAgentQueueArgs) error + // [Preview API] Delete a deployment group. + DeleteDeploymentGroup(context.Context, DeleteDeploymentGroupArgs) error + // [Preview API] Delete a deployment target in a deployment group. This deletes the agent from associated deployment pool too. + DeleteDeploymentTarget(context.Context, DeleteDeploymentTargetArgs) error + // [Preview API] Delete a task group. + DeleteTaskGroup(context.Context, DeleteTaskGroupArgs) error + // [Preview API] Delete a variable group + DeleteVariableGroup(context.Context, DeleteVariableGroupArgs) error + // Get information about an agent. + GetAgent(context.Context, GetAgentArgs) (*TaskAgent, error) + // [Preview API] + GetAgentCloud(context.Context, GetAgentCloudArgs) (*TaskAgentCloud, error) + // [Preview API] + GetAgentCloudRequests(context.Context, GetAgentCloudRequestsArgs) (*[]TaskAgentCloudRequest, error) + // [Preview API] + GetAgentClouds(context.Context, GetAgentCloudsArgs) (*[]TaskAgentCloud, error) + // [Preview API] Get agent cloud types. + GetAgentCloudTypes(context.Context, GetAgentCloudTypesArgs) (*[]TaskAgentCloudType, error) + // Get information about an agent pool. + GetAgentPool(context.Context, GetAgentPoolArgs) (*TaskAgentPool, error) + // Get a list of agent pools. + GetAgentPools(context.Context, GetAgentPoolsArgs) (*[]TaskAgentPool, error) + // Get a list of agent pools. + GetAgentPoolsByIds(context.Context, GetAgentPoolsByIdsArgs) (*[]TaskAgentPool, error) + // [Preview API] Get information about an agent queue. + GetAgentQueue(context.Context, GetAgentQueueArgs) (*TaskAgentQueue, error) + // [Preview API] Get a list of agent queues. + GetAgentQueues(context.Context, GetAgentQueuesArgs) (*[]TaskAgentQueue, error) + // [Preview API] Get a list of agent queues by their IDs + GetAgentQueuesByIds(context.Context, GetAgentQueuesByIdsArgs) (*[]TaskAgentQueue, error) + // [Preview API] Get a list of agent queues by their names + GetAgentQueuesByNames(context.Context, GetAgentQueuesByNamesArgs) (*[]TaskAgentQueue, error) + // Get a list of agents. + GetAgents(context.Context, GetAgentsArgs) (*[]TaskAgent, error) + // [Preview API] Get a deployment group by its ID. + GetDeploymentGroup(context.Context, GetDeploymentGroupArgs) (*DeploymentGroup, error) + // [Preview API] Get a list of deployment groups by name or IDs. + GetDeploymentGroups(context.Context, GetDeploymentGroupsArgs) (*GetDeploymentGroupsResponseValue, error) + // [Preview API] Get a deployment target by its ID in a deployment group + GetDeploymentTarget(context.Context, GetDeploymentTargetArgs) (*DeploymentMachine, error) + // [Preview API] Get a list of deployment targets in a deployment group. + GetDeploymentTargets(context.Context, GetDeploymentTargetsArgs) (*GetDeploymentTargetsResponseValue, error) + // [Preview API] List task groups. + GetTaskGroups(context.Context, GetTaskGroupsArgs) (*[]TaskGroup, error) + // [Preview API] Get a variable group. + GetVariableGroup(context.Context, GetVariableGroupArgs) (*VariableGroup, error) + // [Preview API] Get variable groups. + GetVariableGroups(context.Context, GetVariableGroupsArgs) (*[]VariableGroup, error) + // [Preview API] Get variable groups by ids. + GetVariableGroupsById(context.Context, GetVariableGroupsByIdArgs) (*[]VariableGroup, error) + GetYamlSchema(context.Context, GetYamlSchemaArgs) (interface{}, error) + // Replace an agent. You probably don't want to call this endpoint directly. Instead, [use the agent configuration script](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) to remove and reconfigure an agent from your organization. + ReplaceAgent(context.Context, ReplaceAgentArgs) (*TaskAgent, error) + // Update agent details. + UpdateAgent(context.Context, UpdateAgentArgs) (*TaskAgent, error) + // Update properties on an agent pool + UpdateAgentPool(context.Context, UpdateAgentPoolArgs) (*TaskAgentPool, error) + // [Preview API] Update a deployment group. + UpdateDeploymentGroup(context.Context, UpdateDeploymentGroupArgs) (*DeploymentGroup, error) + // [Preview API] Update tags of a list of deployment targets in a deployment group. + UpdateDeploymentTargets(context.Context, UpdateDeploymentTargetsArgs) (*[]DeploymentMachine, error) + // [Preview API] Update a task group. + UpdateTaskGroup(context.Context, UpdateTaskGroupArgs) (*TaskGroup, error) + // [Preview API] Update a variable group. + UpdateVariableGroup(context.Context, UpdateVariableGroupArgs) (*VariableGroup, 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 +} + +// Adds an agent to a pool. You probably don't want to call this endpoint directly. Instead, [configure an agent](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) using the agent download package. +func (client *ClientImpl) AddAgent(ctx context.Context, args AddAgentArgs) (*TaskAgent, error) { + if args.Agent == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Agent"} + } + routeValues := make(map[string]string) + if args.PoolId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"} + } + routeValues["poolId"] = strconv.Itoa(*args.PoolId) + + body, marshalErr := json.Marshal(*args.Agent) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e298ef32-5878-4cab-993c-043836571f42") + 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 TaskAgent + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddAgent function +type AddAgentArgs struct { + // (required) Details about the agent being added + Agent *TaskAgent + // (required) The agent pool in which to add the agent + PoolId *int +} + +// [Preview API] +func (client *ClientImpl) AddAgentCloud(ctx context.Context, args AddAgentCloudArgs) (*TaskAgentCloud, error) { + if args.AgentCloud == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentCloud"} + } + body, marshalErr := json.Marshal(*args.AgentCloud) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bfa72b3d-0fc6-43fb-932b-a7f6559f93b9") + 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 TaskAgentCloud + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddAgentCloud function +type AddAgentCloudArgs struct { + // (required) + AgentCloud *TaskAgentCloud +} + +// Create an agent pool. +func (client *ClientImpl) AddAgentPool(ctx context.Context, args AddAgentPoolArgs) (*TaskAgentPool, error) { + if args.Pool == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Pool"} + } + body, marshalErr := json.Marshal(*args.Pool) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a8c47e17-4d56-4a56-92bb-de7ea7dc65be") + 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 TaskAgentPool + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddAgentPool function +type AddAgentPoolArgs struct { + // (required) Details about the new agent pool + Pool *TaskAgentPool +} + +// [Preview API] Create a new agent queue to connect a project to an agent pool. +func (client *ClientImpl) AddAgentQueue(ctx context.Context, args AddAgentQueueArgs) (*TaskAgentQueue, error) { + if args.Queue == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Queue"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.AuthorizePipelines != nil { + queryParams.Add("authorizePipelines", strconv.FormatBool(*args.AuthorizePipelines)) + } + body, marshalErr := json.Marshal(*args.Queue) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("900fa995-c559-4923-aae7-f8424fe4fbea") + 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 TaskAgentQueue + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddAgentQueue function +type AddAgentQueueArgs struct { + // (required) Details about the queue to create + Queue *TaskAgentQueue + // (optional) Project ID or project name + Project *string + // (optional) Automatically authorize this queue when using YAML + AuthorizePipelines *bool +} + +// [Preview API] Create a deployment group. +func (client *ClientImpl) AddDeploymentGroup(ctx context.Context, args AddDeploymentGroupArgs) (*DeploymentGroup, error) { + if args.DeploymentGroup == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroup"} + } + 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.DeploymentGroup) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("083c4d89-ab35-45af-aa11-7cf66895c53e") + 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 DeploymentGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddDeploymentGroup function +type AddDeploymentGroupArgs struct { + // (required) Deployment group to create. + DeploymentGroup *DeploymentGroupCreateParameter + // (required) Project ID or project name + Project *string +} + +// [Preview API] Create a task group. +func (client *ClientImpl) AddTaskGroup(ctx context.Context, args AddTaskGroupArgs) (*TaskGroup, error) { + if args.TaskGroup == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TaskGroup"} + } + 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.TaskGroup) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("6c08ffbf-dbf1-4f9a-94e5-a1cbd47005e7") + 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 TaskGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddTaskGroup function +type AddTaskGroupArgs struct { + // (required) Task group object to create. + TaskGroup *TaskGroupCreateParameter + // (required) Project ID or project name + Project *string +} + +// [Preview API] Add a variable group. +func (client *ClientImpl) AddVariableGroup(ctx context.Context, args AddVariableGroupArgs) (*VariableGroup, error) { + if args.Group == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Group"} + } + 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.Group) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("f5b09dd5-9d54-45a1-8b5a-1c8287d634cc") + 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 VariableGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddVariableGroup function +type AddVariableGroupArgs struct { + // (required) Variable group to add. + Group *VariableGroupParameters + // (required) Project ID or project name + Project *string +} + +// Delete an agent. You probably don't want to call this endpoint directly. Instead, [use the agent configuration script](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) to remove an agent from your organization. +func (client *ClientImpl) DeleteAgent(ctx context.Context, args DeleteAgentArgs) error { + routeValues := make(map[string]string) + if args.PoolId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"} + } + routeValues["poolId"] = strconv.Itoa(*args.PoolId) + if args.AgentId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.AgentId"} + } + routeValues["agentId"] = strconv.Itoa(*args.AgentId) + + locationId, _ := uuid.Parse("e298ef32-5878-4cab-993c-043836571f42") + _, 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 DeleteAgent function +type DeleteAgentArgs struct { + // (required) The pool ID to remove the agent from + PoolId *int + // (required) The agent ID to remove + AgentId *int +} + +// [Preview API] +func (client *ClientImpl) DeleteAgentCloud(ctx context.Context, args DeleteAgentCloudArgs) (*TaskAgentCloud, error) { + routeValues := make(map[string]string) + if args.AgentCloudId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentCloudId"} + } + routeValues["agentCloudId"] = strconv.Itoa(*args.AgentCloudId) + + locationId, _ := uuid.Parse("bfa72b3d-0fc6-43fb-932b-a7f6559f93b9") + 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 TaskAgentCloud + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the DeleteAgentCloud function +type DeleteAgentCloudArgs struct { + // (required) + AgentCloudId *int +} + +// Delete an agent pool. +func (client *ClientImpl) DeleteAgentPool(ctx context.Context, args DeleteAgentPoolArgs) error { + routeValues := make(map[string]string) + if args.PoolId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"} + } + routeValues["poolId"] = strconv.Itoa(*args.PoolId) + + locationId, _ := uuid.Parse("a8c47e17-4d56-4a56-92bb-de7ea7dc65be") + _, 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 DeleteAgentPool function +type DeleteAgentPoolArgs struct { + // (required) ID of the agent pool to delete + PoolId *int +} + +// [Preview API] Removes an agent queue from a project. +func (client *ClientImpl) DeleteAgentQueue(ctx context.Context, args DeleteAgentQueueArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.QueueId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.QueueId"} + } + routeValues["queueId"] = strconv.Itoa(*args.QueueId) + + locationId, _ := uuid.Parse("900fa995-c559-4923-aae7-f8424fe4fbea") + _, 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 DeleteAgentQueue function +type DeleteAgentQueueArgs struct { + // (required) The agent queue to remove + QueueId *int + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Delete a deployment group. +func (client *ClientImpl) DeleteDeploymentGroup(ctx context.Context, args DeleteDeploymentGroupArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DeploymentGroupId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroupId"} + } + routeValues["deploymentGroupId"] = strconv.Itoa(*args.DeploymentGroupId) + + locationId, _ := uuid.Parse("083c4d89-ab35-45af-aa11-7cf66895c53e") + _, 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 DeleteDeploymentGroup function +type DeleteDeploymentGroupArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the deployment group to be deleted. + DeploymentGroupId *int +} + +// [Preview API] Delete a deployment target in a deployment group. This deletes the agent from associated deployment pool too. +func (client *ClientImpl) DeleteDeploymentTarget(ctx context.Context, args DeleteDeploymentTargetArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DeploymentGroupId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroupId"} + } + routeValues["deploymentGroupId"] = strconv.Itoa(*args.DeploymentGroupId) + if args.TargetId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.TargetId"} + } + routeValues["targetId"] = strconv.Itoa(*args.TargetId) + + locationId, _ := uuid.Parse("2f0aa599-c121-4256-a5fd-ba370e0ae7b6") + _, 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 DeleteDeploymentTarget function +type DeleteDeploymentTargetArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the deployment group in which deployment target is deleted. + DeploymentGroupId *int + // (required) ID of the deployment target to delete. + TargetId *int +} + +// [Preview API] Delete a task group. +func (client *ClientImpl) DeleteTaskGroup(ctx context.Context, args DeleteTaskGroupArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.TaskGroupId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.TaskGroupId"} + } + routeValues["taskGroupId"] = (*args.TaskGroupId).String() + + queryParams := url.Values{} + if args.Comment != nil { + queryParams.Add("comment", *args.Comment) + } + locationId, _ := uuid.Parse("6c08ffbf-dbf1-4f9a-94e5-a1cbd47005e7") + _, 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 DeleteTaskGroup function +type DeleteTaskGroupArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the task group to be deleted. + TaskGroupId *uuid.UUID + // (optional) Comments to delete. + Comment *string +} + +// [Preview API] Delete a variable group +func (client *ClientImpl) DeleteVariableGroup(ctx context.Context, args DeleteVariableGroupArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.GroupId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = strconv.Itoa(*args.GroupId) + + locationId, _ := uuid.Parse("f5b09dd5-9d54-45a1-8b5a-1c8287d634cc") + _, 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 DeleteVariableGroup function +type DeleteVariableGroupArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the variable group. + GroupId *int +} + +// Get information about an agent. +func (client *ClientImpl) GetAgent(ctx context.Context, args GetAgentArgs) (*TaskAgent, error) { + routeValues := make(map[string]string) + if args.PoolId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"} + } + routeValues["poolId"] = strconv.Itoa(*args.PoolId) + if args.AgentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentId"} + } + routeValues["agentId"] = strconv.Itoa(*args.AgentId) + + queryParams := url.Values{} + if args.IncludeCapabilities != nil { + queryParams.Add("includeCapabilities", strconv.FormatBool(*args.IncludeCapabilities)) + } + if args.IncludeAssignedRequest != nil { + queryParams.Add("includeAssignedRequest", strconv.FormatBool(*args.IncludeAssignedRequest)) + } + if args.IncludeLastCompletedRequest != nil { + queryParams.Add("includeLastCompletedRequest", strconv.FormatBool(*args.IncludeLastCompletedRequest)) + } + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + locationId, _ := uuid.Parse("e298ef32-5878-4cab-993c-043836571f42") + 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 TaskAgent + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgent function +type GetAgentArgs struct { + // (required) The agent pool containing the agent + PoolId *int + // (required) The agent ID to get information about + AgentId *int + // (optional) Whether to include the agent's capabilities in the response + IncludeCapabilities *bool + // (optional) Whether to include details about the agent's current work + IncludeAssignedRequest *bool + // (optional) Whether to include details about the agents' most recent completed work + IncludeLastCompletedRequest *bool + // (optional) Filter which custom properties will be returned + PropertyFilters *[]string +} + +// [Preview API] +func (client *ClientImpl) GetAgentCloud(ctx context.Context, args GetAgentCloudArgs) (*TaskAgentCloud, error) { + routeValues := make(map[string]string) + if args.AgentCloudId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentCloudId"} + } + routeValues["agentCloudId"] = strconv.Itoa(*args.AgentCloudId) + + locationId, _ := uuid.Parse("bfa72b3d-0fc6-43fb-932b-a7f6559f93b9") + 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 TaskAgentCloud + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgentCloud function +type GetAgentCloudArgs struct { + // (required) + AgentCloudId *int +} + +// [Preview API] +func (client *ClientImpl) GetAgentCloudRequests(ctx context.Context, args GetAgentCloudRequestsArgs) (*[]TaskAgentCloudRequest, error) { + routeValues := make(map[string]string) + if args.AgentCloudId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentCloudId"} + } + routeValues["agentCloudId"] = strconv.Itoa(*args.AgentCloudId) + + locationId, _ := uuid.Parse("20189bd7-5134-49c2-b8e9-f9e856eea2b2") + 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 []TaskAgentCloudRequest + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgentCloudRequests function +type GetAgentCloudRequestsArgs struct { + // (required) + AgentCloudId *int +} + +// [Preview API] +func (client *ClientImpl) GetAgentClouds(ctx context.Context, args GetAgentCloudsArgs) (*[]TaskAgentCloud, error) { + locationId, _ := uuid.Parse("bfa72b3d-0fc6-43fb-932b-a7f6559f93b9") + 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 []TaskAgentCloud + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgentClouds function +type GetAgentCloudsArgs struct { +} + +// [Preview API] Get agent cloud types. +func (client *ClientImpl) GetAgentCloudTypes(ctx context.Context, args GetAgentCloudTypesArgs) (*[]TaskAgentCloudType, error) { + locationId, _ := uuid.Parse("5932e193-f376-469d-9c3e-e5588ce12cb5") + 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 []TaskAgentCloudType + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgentCloudTypes function +type GetAgentCloudTypesArgs struct { +} + +// Get information about an agent pool. +func (client *ClientImpl) GetAgentPool(ctx context.Context, args GetAgentPoolArgs) (*TaskAgentPool, error) { + routeValues := make(map[string]string) + if args.PoolId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"} + } + routeValues["poolId"] = strconv.Itoa(*args.PoolId) + + queryParams := url.Values{} + if args.Properties != nil { + listAsString := strings.Join((*args.Properties)[:], ",") + queryParams.Add("properties", listAsString) + } + if args.ActionFilter != nil { + queryParams.Add("actionFilter", string(*args.ActionFilter)) + } + locationId, _ := uuid.Parse("a8c47e17-4d56-4a56-92bb-de7ea7dc65be") + 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 TaskAgentPool + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgentPool function +type GetAgentPoolArgs struct { + // (required) An agent pool ID + PoolId *int + // (optional) Agent pool properties (comma-separated) + Properties *[]string + // (optional) Filter by whether the calling user has use or manage permissions + ActionFilter *TaskAgentPoolActionFilter +} + +// Get a list of agent pools. +func (client *ClientImpl) GetAgentPools(ctx context.Context, args GetAgentPoolsArgs) (*[]TaskAgentPool, error) { + queryParams := url.Values{} + if args.PoolName != nil { + queryParams.Add("poolName", *args.PoolName) + } + if args.Properties != nil { + listAsString := strings.Join((*args.Properties)[:], ",") + queryParams.Add("properties", listAsString) + } + if args.PoolType != nil { + queryParams.Add("poolType", string(*args.PoolType)) + } + if args.ActionFilter != nil { + queryParams.Add("actionFilter", string(*args.ActionFilter)) + } + locationId, _ := uuid.Parse("a8c47e17-4d56-4a56-92bb-de7ea7dc65be") + 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 []TaskAgentPool + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgentPools function +type GetAgentPoolsArgs struct { + // (optional) Filter by name + PoolName *string + // (optional) Filter by agent pool properties (comma-separated) + Properties *[]string + // (optional) Filter by pool type + PoolType *TaskAgentPoolType + // (optional) Filter by whether the calling user has use or manage permissions + ActionFilter *TaskAgentPoolActionFilter +} + +// Get a list of agent pools. +func (client *ClientImpl) GetAgentPoolsByIds(ctx context.Context, args GetAgentPoolsByIdsArgs) (*[]TaskAgentPool, error) { + queryParams := url.Values{} + if args.PoolIds == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "poolIds"} + } + var stringList []string + for _, item := range *args.PoolIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("poolIds", listAsString) + if args.ActionFilter != nil { + queryParams.Add("actionFilter", string(*args.ActionFilter)) + } + locationId, _ := uuid.Parse("a8c47e17-4d56-4a56-92bb-de7ea7dc65be") + 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 []TaskAgentPool + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgentPoolsByIds function +type GetAgentPoolsByIdsArgs struct { + // (required) pool Ids to fetch + PoolIds *[]int + // (optional) Filter by whether the calling user has use or manage permissions + ActionFilter *TaskAgentPoolActionFilter +} + +// [Preview API] Get information about an agent queue. +func (client *ClientImpl) GetAgentQueue(ctx context.Context, args GetAgentQueueArgs) (*TaskAgentQueue, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.QueueId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.QueueId"} + } + routeValues["queueId"] = strconv.Itoa(*args.QueueId) + + queryParams := url.Values{} + if args.ActionFilter != nil { + queryParams.Add("actionFilter", string(*args.ActionFilter)) + } + locationId, _ := uuid.Parse("900fa995-c559-4923-aae7-f8424fe4fbea") + 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 TaskAgentQueue + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgentQueue function +type GetAgentQueueArgs struct { + // (required) The agent queue to get information about + QueueId *int + // (optional) Project ID or project name + Project *string + // (optional) Filter by whether the calling user has use or manage permissions + ActionFilter *TaskAgentQueueActionFilter +} + +// [Preview API] Get a list of agent queues. +func (client *ClientImpl) GetAgentQueues(ctx context.Context, args GetAgentQueuesArgs) (*[]TaskAgentQueue, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.QueueName != nil { + queryParams.Add("queueName", *args.QueueName) + } + if args.ActionFilter != nil { + queryParams.Add("actionFilter", string(*args.ActionFilter)) + } + locationId, _ := uuid.Parse("900fa995-c559-4923-aae7-f8424fe4fbea") + 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 []TaskAgentQueue + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgentQueues function +type GetAgentQueuesArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) Filter on the agent queue name + QueueName *string + // (optional) Filter by whether the calling user has use or manage permissions + ActionFilter *TaskAgentQueueActionFilter +} + +// [Preview API] Get a list of agent queues by their IDs +func (client *ClientImpl) GetAgentQueuesByIds(ctx context.Context, args GetAgentQueuesByIdsArgs) (*[]TaskAgentQueue, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.QueueIds == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "queueIds"} + } + var stringList []string + for _, item := range *args.QueueIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("queueIds", listAsString) + if args.ActionFilter != nil { + queryParams.Add("actionFilter", string(*args.ActionFilter)) + } + locationId, _ := uuid.Parse("900fa995-c559-4923-aae7-f8424fe4fbea") + 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 []TaskAgentQueue + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgentQueuesByIds function +type GetAgentQueuesByIdsArgs struct { + // (required) A comma-separated list of agent queue IDs to retrieve + QueueIds *[]int + // (optional) Project ID or project name + Project *string + // (optional) Filter by whether the calling user has use or manage permissions + ActionFilter *TaskAgentQueueActionFilter +} + +// [Preview API] Get a list of agent queues by their names +func (client *ClientImpl) GetAgentQueuesByNames(ctx context.Context, args GetAgentQueuesByNamesArgs) (*[]TaskAgentQueue, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.QueueNames == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "queueNames"} + } + listAsString := strings.Join((*args.QueueNames)[:], ",") + queryParams.Add("queueNames", listAsString) + if args.ActionFilter != nil { + queryParams.Add("actionFilter", string(*args.ActionFilter)) + } + locationId, _ := uuid.Parse("900fa995-c559-4923-aae7-f8424fe4fbea") + 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 []TaskAgentQueue + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgentQueuesByNames function +type GetAgentQueuesByNamesArgs struct { + // (required) A comma-separated list of agent names to retrieve + QueueNames *[]string + // (optional) Project ID or project name + Project *string + // (optional) Filter by whether the calling user has use or manage permissions + ActionFilter *TaskAgentQueueActionFilter +} + +// Get a list of agents. +func (client *ClientImpl) GetAgents(ctx context.Context, args GetAgentsArgs) (*[]TaskAgent, error) { + routeValues := make(map[string]string) + if args.PoolId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"} + } + routeValues["poolId"] = strconv.Itoa(*args.PoolId) + + queryParams := url.Values{} + if args.AgentName != nil { + queryParams.Add("agentName", *args.AgentName) + } + if args.IncludeCapabilities != nil { + queryParams.Add("includeCapabilities", strconv.FormatBool(*args.IncludeCapabilities)) + } + if args.IncludeAssignedRequest != nil { + queryParams.Add("includeAssignedRequest", strconv.FormatBool(*args.IncludeAssignedRequest)) + } + if args.IncludeLastCompletedRequest != nil { + queryParams.Add("includeLastCompletedRequest", strconv.FormatBool(*args.IncludeLastCompletedRequest)) + } + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + if args.Demands != nil { + listAsString := strings.Join((*args.Demands)[:], ",") + queryParams.Add("demands", listAsString) + } + locationId, _ := uuid.Parse("e298ef32-5878-4cab-993c-043836571f42") + 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 []TaskAgent + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAgents function +type GetAgentsArgs struct { + // (required) The agent pool containing the agents + PoolId *int + // (optional) Filter on agent name + AgentName *string + // (optional) Whether to include the agents' capabilities in the response + IncludeCapabilities *bool + // (optional) Whether to include details about the agents' current work + IncludeAssignedRequest *bool + // (optional) Whether to include details about the agents' most recent completed work + IncludeLastCompletedRequest *bool + // (optional) Filter which custom properties will be returned + PropertyFilters *[]string + // (optional) Filter by demands the agents can satisfy + Demands *[]string +} + +// [Preview API] Get a deployment group by its ID. +func (client *ClientImpl) GetDeploymentGroup(ctx context.Context, args GetDeploymentGroupArgs) (*DeploymentGroup, 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.DeploymentGroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroupId"} + } + routeValues["deploymentGroupId"] = strconv.Itoa(*args.DeploymentGroupId) + + queryParams := url.Values{} + if args.ActionFilter != nil { + queryParams.Add("actionFilter", string(*args.ActionFilter)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("083c4d89-ab35-45af-aa11-7cf66895c53e") + 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 DeploymentGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDeploymentGroup function +type GetDeploymentGroupArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the deployment group. + DeploymentGroupId *int + // (optional) Get the deployment group only if this action can be performed on it. + ActionFilter *DeploymentGroupActionFilter + // (optional) Include these additional details in the returned object. + Expand *DeploymentGroupExpands +} + +// [Preview API] Get a list of deployment groups by name or IDs. +func (client *ClientImpl) GetDeploymentGroups(ctx context.Context, args GetDeploymentGroupsArgs) (*GetDeploymentGroupsResponseValue, 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.Name != nil { + queryParams.Add("name", *args.Name) + } + if args.ActionFilter != nil { + queryParams.Add("actionFilter", string(*args.ActionFilter)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Ids != nil { + var stringList []string + for _, item := range *args.Ids { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("ids", listAsString) + } + locationId, _ := uuid.Parse("083c4d89-ab35-45af-aa11-7cf66895c53e") + 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 GetDeploymentGroupsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetDeploymentGroups function +type GetDeploymentGroupsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Name of the deployment group. + Name *string + // (optional) Get only deployment groups on which this action can be performed. + ActionFilter *DeploymentGroupActionFilter + // (optional) Include these additional details in the returned objects. + Expand *DeploymentGroupExpands + // (optional) Get deployment groups with names greater than this continuationToken lexicographically. + ContinuationToken *string + // (optional) Maximum number of deployment groups to return. Default is **1000**. + Top *int + // (optional) Comma separated list of IDs of the deployment groups. + Ids *[]int +} + +// Return type for the GetDeploymentGroups function +type GetDeploymentGroupsResponseValue struct { + Value []DeploymentGroup + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get a deployment target by its ID in a deployment group +func (client *ClientImpl) GetDeploymentTarget(ctx context.Context, args GetDeploymentTargetArgs) (*DeploymentMachine, 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.DeploymentGroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroupId"} + } + routeValues["deploymentGroupId"] = strconv.Itoa(*args.DeploymentGroupId) + if args.TargetId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TargetId"} + } + routeValues["targetId"] = strconv.Itoa(*args.TargetId) + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("2f0aa599-c121-4256-a5fd-ba370e0ae7b6") + 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 DeploymentMachine + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDeploymentTarget function +type GetDeploymentTargetArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the deployment group to which deployment target belongs. + DeploymentGroupId *int + // (required) ID of the deployment target to return. + TargetId *int + // (optional) Include these additional details in the returned objects. + Expand *DeploymentTargetExpands +} + +// [Preview API] Get a list of deployment targets in a deployment group. +func (client *ClientImpl) GetDeploymentTargets(ctx context.Context, args GetDeploymentTargetsArgs) (*GetDeploymentTargetsResponseValue, 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.DeploymentGroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroupId"} + } + routeValues["deploymentGroupId"] = strconv.Itoa(*args.DeploymentGroupId) + + queryParams := url.Values{} + if args.Tags != nil { + listAsString := strings.Join((*args.Tags)[:], ",") + queryParams.Add("tags", listAsString) + } + if args.Name != nil { + queryParams.Add("name", *args.Name) + } + if args.PartialNameMatch != nil { + queryParams.Add("partialNameMatch", strconv.FormatBool(*args.PartialNameMatch)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.AgentStatus != nil { + queryParams.Add("agentStatus", string(*args.AgentStatus)) + } + if args.AgentJobResult != nil { + queryParams.Add("agentJobResult", string(*args.AgentJobResult)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Enabled != nil { + queryParams.Add("enabled", strconv.FormatBool(*args.Enabled)) + } + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + locationId, _ := uuid.Parse("2f0aa599-c121-4256-a5fd-ba370e0ae7b6") + 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 GetDeploymentTargetsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetDeploymentTargets function +type GetDeploymentTargetsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the deployment group. + DeploymentGroupId *int + // (optional) Get only the deployment targets that contain all these comma separted list of tags. + Tags *[]string + // (optional) Name pattern of the deployment targets to return. + Name *string + // (optional) When set to true, treats **name** as pattern. Else treats it as absolute match. Default is **false**. + PartialNameMatch *bool + // (optional) Include these additional details in the returned objects. + Expand *DeploymentTargetExpands + // (optional) Get only deployment targets that have this status. + AgentStatus *TaskAgentStatusFilter + // (optional) Get only deployment targets that have this last job result. + AgentJobResult *TaskAgentJobResultFilter + // (optional) Get deployment targets with names greater than this continuationToken lexicographically. + ContinuationToken *string + // (optional) Maximum number of deployment targets to return. Default is **1000**. + Top *int + // (optional) Get only deployment targets that are enabled or disabled. Default is 'null' which returns all the targets. + Enabled *bool + // (optional) + PropertyFilters *[]string +} + +// Return type for the GetDeploymentTargets function +type GetDeploymentTargetsResponseValue struct { + Value []DeploymentMachine + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] List task groups. +func (client *ClientImpl) GetTaskGroups(ctx context.Context, args GetTaskGroupsArgs) (*[]TaskGroup, 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.TaskGroupId != nil { + routeValues["taskGroupId"] = (*args.TaskGroupId).String() + } + + queryParams := url.Values{} + if args.Expanded != nil { + queryParams.Add("expanded", strconv.FormatBool(*args.Expanded)) + } + if args.TaskIdFilter != nil { + queryParams.Add("taskIdFilter", (*args.TaskIdFilter).String()) + } + if args.Deleted != nil { + queryParams.Add("deleted", strconv.FormatBool(*args.Deleted)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", (*args.ContinuationToken).String()) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + locationId, _ := uuid.Parse("6c08ffbf-dbf1-4f9a-94e5-a1cbd47005e7") + 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 []TaskGroup + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTaskGroups function +type GetTaskGroupsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Id of the task group. + TaskGroupId *uuid.UUID + // (optional) 'true' to recursively expand task groups. Default is 'false'. + Expanded *bool + // (optional) Guid of the taskId to filter. + TaskIdFilter *uuid.UUID + // (optional) 'true'to include deleted task groups. Default is 'false'. + Deleted *bool + // (optional) Number of task groups to get. + Top *int + // (optional) Gets the task groups after the continuation token provided. + ContinuationToken *azuredevops.Time + // (optional) Gets the results in the defined order. Default is 'CreatedOnDescending'. + QueryOrder *TaskGroupQueryOrder +} + +// [Preview API] Get a variable group. +func (client *ClientImpl) GetVariableGroup(ctx context.Context, args GetVariableGroupArgs) (*VariableGroup, 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.GroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = strconv.Itoa(*args.GroupId) + + locationId, _ := uuid.Parse("f5b09dd5-9d54-45a1-8b5a-1c8287d634cc") + 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 VariableGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetVariableGroup function +type GetVariableGroupArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the variable group. + GroupId *int +} + +// [Preview API] Get variable groups. +func (client *ClientImpl) GetVariableGroups(ctx context.Context, args GetVariableGroupsArgs) (*[]VariableGroup, 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.GroupName != nil { + queryParams.Add("groupName", *args.GroupName) + } + if args.ActionFilter != nil { + queryParams.Add("actionFilter", string(*args.ActionFilter)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken)) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + locationId, _ := uuid.Parse("f5b09dd5-9d54-45a1-8b5a-1c8287d634cc") + 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 []VariableGroup + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetVariableGroups function +type GetVariableGroupsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Name of variable group. + GroupName *string + // (optional) Action filter for the variable group. It specifies the action which can be performed on the variable groups. + ActionFilter *VariableGroupActionFilter + // (optional) Number of variable groups to get. + Top *int + // (optional) Gets the variable groups after the continuation token provided. + ContinuationToken *int + // (optional) Gets the results in the defined order. Default is 'IdDescending'. + QueryOrder *VariableGroupQueryOrder +} + +// [Preview API] Get variable groups by ids. +func (client *ClientImpl) GetVariableGroupsById(ctx context.Context, args GetVariableGroupsByIdArgs) (*[]VariableGroup, 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.GroupIds == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "groupIds"} + } + var stringList []string + for _, item := range *args.GroupIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("groupIds", listAsString) + locationId, _ := uuid.Parse("f5b09dd5-9d54-45a1-8b5a-1c8287d634cc") + 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 []VariableGroup + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetVariableGroupsById function +type GetVariableGroupsByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) Comma separated list of Ids of variable groups. + GroupIds *[]int +} + +func (client *ClientImpl) GetYamlSchema(ctx context.Context, args GetYamlSchemaArgs) (interface{}, error) { + locationId, _ := uuid.Parse("1f9990b9-1dba-441f-9c2e-6485888c42b6") + 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 interface{} + err = client.Client.UnmarshalBody(resp, responseValue) + return responseValue, err +} + +// Arguments for the GetYamlSchema function +type GetYamlSchemaArgs struct { +} + +// Replace an agent. You probably don't want to call this endpoint directly. Instead, [use the agent configuration script](https://docs.microsoft.com/azure/devops/pipelines/agents/agents) to remove and reconfigure an agent from your organization. +func (client *ClientImpl) ReplaceAgent(ctx context.Context, args ReplaceAgentArgs) (*TaskAgent, error) { + if args.Agent == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Agent"} + } + routeValues := make(map[string]string) + if args.PoolId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"} + } + routeValues["poolId"] = strconv.Itoa(*args.PoolId) + if args.AgentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentId"} + } + routeValues["agentId"] = strconv.Itoa(*args.AgentId) + + body, marshalErr := json.Marshal(*args.Agent) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e298ef32-5878-4cab-993c-043836571f42") + 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 TaskAgent + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReplaceAgent function +type ReplaceAgentArgs struct { + // (required) Updated details about the replacing agent + Agent *TaskAgent + // (required) The agent pool to use + PoolId *int + // (required) The agent to replace + AgentId *int +} + +// Update agent details. +func (client *ClientImpl) UpdateAgent(ctx context.Context, args UpdateAgentArgs) (*TaskAgent, error) { + if args.Agent == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Agent"} + } + routeValues := make(map[string]string) + if args.PoolId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"} + } + routeValues["poolId"] = strconv.Itoa(*args.PoolId) + if args.AgentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AgentId"} + } + routeValues["agentId"] = strconv.Itoa(*args.AgentId) + + body, marshalErr := json.Marshal(*args.Agent) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e298ef32-5878-4cab-993c-043836571f42") + 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 TaskAgent + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateAgent function +type UpdateAgentArgs struct { + // (required) Updated details about the agent + Agent *TaskAgent + // (required) The agent pool to use + PoolId *int + // (required) The agent to update + AgentId *int +} + +// Update properties on an agent pool +func (client *ClientImpl) UpdateAgentPool(ctx context.Context, args UpdateAgentPoolArgs) (*TaskAgentPool, error) { + if args.Pool == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Pool"} + } + routeValues := make(map[string]string) + if args.PoolId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PoolId"} + } + routeValues["poolId"] = strconv.Itoa(*args.PoolId) + + body, marshalErr := json.Marshal(*args.Pool) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a8c47e17-4d56-4a56-92bb-de7ea7dc65be") + 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 TaskAgentPool + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateAgentPool function +type UpdateAgentPoolArgs struct { + // (required) Updated agent pool details + Pool *TaskAgentPool + // (required) The agent pool to update + PoolId *int +} + +// [Preview API] Update a deployment group. +func (client *ClientImpl) UpdateDeploymentGroup(ctx context.Context, args UpdateDeploymentGroupArgs) (*DeploymentGroup, error) { + if args.DeploymentGroup == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroup"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DeploymentGroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroupId"} + } + routeValues["deploymentGroupId"] = strconv.Itoa(*args.DeploymentGroupId) + + body, marshalErr := json.Marshal(*args.DeploymentGroup) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("083c4d89-ab35-45af-aa11-7cf66895c53e") + 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 DeploymentGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateDeploymentGroup function +type UpdateDeploymentGroupArgs struct { + // (required) Deployment group to update. + DeploymentGroup *DeploymentGroupUpdateParameter + // (required) Project ID or project name + Project *string + // (required) ID of the deployment group. + DeploymentGroupId *int +} + +// [Preview API] Update tags of a list of deployment targets in a deployment group. +func (client *ClientImpl) UpdateDeploymentTargets(ctx context.Context, args UpdateDeploymentTargetsArgs) (*[]DeploymentMachine, error) { + if args.Machines == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Machines"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DeploymentGroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DeploymentGroupId"} + } + routeValues["deploymentGroupId"] = strconv.Itoa(*args.DeploymentGroupId) + + body, marshalErr := json.Marshal(*args.Machines) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2f0aa599-c121-4256-a5fd-ba370e0ae7b6") + 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 []DeploymentMachine + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateDeploymentTargets function +type UpdateDeploymentTargetsArgs struct { + // (required) Deployment targets with tags to udpdate. + Machines *[]DeploymentTargetUpdateParameter + // (required) Project ID or project name + Project *string + // (required) ID of the deployment group in which deployment targets are updated. + DeploymentGroupId *int +} + +// [Preview API] Update a task group. +func (client *ClientImpl) UpdateTaskGroup(ctx context.Context, args UpdateTaskGroupArgs) (*TaskGroup, error) { + if args.TaskGroup == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TaskGroup"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.TaskGroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TaskGroupId"} + } + routeValues["taskGroupId"] = (*args.TaskGroupId).String() + + body, marshalErr := json.Marshal(*args.TaskGroup) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("6c08ffbf-dbf1-4f9a-94e5-a1cbd47005e7") + resp, 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 nil, err + } + + var responseValue TaskGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTaskGroup function +type UpdateTaskGroupArgs struct { + // (required) Task group to update. + TaskGroup *TaskGroupUpdateParameter + // (required) Project ID or project name + Project *string + // (required) Id of the task group to update. + TaskGroupId *uuid.UUID +} + +// [Preview API] Update a variable group. +func (client *ClientImpl) UpdateVariableGroup(ctx context.Context, args UpdateVariableGroupArgs) (*VariableGroup, error) { + if args.Group == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Group"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.GroupId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = strconv.Itoa(*args.GroupId) + + body, marshalErr := json.Marshal(*args.Group) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("f5b09dd5-9d54-45a1-8b5a-1c8287d634cc") + resp, 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 nil, err + } + + var responseValue VariableGroup + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateVariableGroup function +type UpdateVariableGroupArgs struct { + // (required) Variable group to update. + Group *VariableGroupParameters + // (required) Project ID or project name + Project *string + // (required) Id of the variable group to update. + GroupId *int +} diff --git a/azuredevops/taskagent/models.go b/azuredevops/taskagent/models.go new file mode 100644 index 00000000..defe9b39 --- /dev/null +++ b/azuredevops/taskagent/models.go @@ -0,0 +1,2633 @@ +// -------------------------------------------------------------------------------------------- +// 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 taskagent + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/distributedtaskcommon" + "github.com/microsoft/azure-devops-go-api/azuredevops/forminput" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type AadLoginPromptOption string + +type aadLoginPromptOptionValuesType struct { + NoOption AadLoginPromptOption + Login AadLoginPromptOption + SelectAccount AadLoginPromptOption + FreshLogin AadLoginPromptOption + FreshLoginWithMfa AadLoginPromptOption +} + +var AadLoginPromptOptionValues = aadLoginPromptOptionValuesType{ + // Do not provide a prompt option + NoOption: "noOption", + // Force the user to login again. + Login: "login", + // Force the user to select which account they are logging in with instead of automatically picking the user up from the session state. NOTE: This does not work for switching between the variants of a dual-homed user. + SelectAccount: "selectAccount", + // Force the user to login again. Ignore current authentication state and force the user to authenticate again. This option should be used instead of Login. + FreshLogin: "freshLogin", + // Force the user to login again with mfa. Ignore current authentication state and force the user to authenticate again. This option should be used instead of Login, if MFA is required. + FreshLoginWithMfa: "freshLoginWithMfa", +} + +type AadOauthTokenRequest struct { + Refresh *bool `json:"refresh,omitempty"` + Resource *string `json:"resource,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + Token *string `json:"token,omitempty"` +} + +type AadOauthTokenResult struct { + AccessToken *string `json:"accessToken,omitempty"` + RefreshTokenCache *string `json:"refreshTokenCache,omitempty"` +} + +type AgentChangeEvent struct { + Agent *TaskAgent `json:"agent,omitempty"` + EventType *string `json:"eventType,omitempty"` + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + // Deprecated: + PoolId *int `json:"poolId,omitempty"` + // Deprecated: + TimeStamp *azuredevops.Time `json:"timeStamp,omitempty"` +} + +type AgentJobRequestMessage struct { + Environment *JobEnvironment `json:"environment,omitempty"` + JobId *uuid.UUID `json:"jobId,omitempty"` + JobName *string `json:"jobName,omitempty"` + JobRefName *string `json:"jobRefName,omitempty"` + MessageType *string `json:"messageType,omitempty"` + Plan *TaskOrchestrationPlanReference `json:"plan,omitempty"` + Timeline *TimelineReference `json:"timeline,omitempty"` + LockedUntil *azuredevops.Time `json:"lockedUntil,omitempty"` + LockToken *uuid.UUID `json:"lockToken,omitempty"` + RequestId *uint64 `json:"requestId,omitempty"` + Tasks *[]TaskInstance `json:"tasks,omitempty"` +} + +type AgentMigrationMessage struct { + AccessToken *string `json:"accessToken,omitempty"` +} + +type AgentPoolEvent struct { + EventType *string `json:"eventType,omitempty"` + Pool *TaskAgentPool `json:"pool,omitempty"` +} + +type AgentQueueEvent struct { + EventType *string `json:"eventType,omitempty"` + Queue *TaskAgentQueue `json:"queue,omitempty"` +} + +type AgentQueuesEvent struct { + EventType *string `json:"eventType,omitempty"` + Queues *[]TaskAgentQueue `json:"queues,omitempty"` +} + +type AgentRefreshMessage struct { + AgentId *int `json:"agentId,omitempty"` + TargetVersion *string `json:"targetVersion,omitempty"` + Timeout interface{} `json:"timeout,omitempty"` +} + +type AuditAction string + +type auditActionValuesType struct { + Add AuditAction + Update AuditAction + Delete AuditAction + Undelete AuditAction +} + +var AuditActionValues = auditActionValuesType{ + Add: "add", + Update: "update", + Delete: "delete", + Undelete: "undelete", +} + +type AuthenticationSchemeReference struct { + Inputs *map[string]string `json:"inputs,omitempty"` + Type *string `json:"type,omitempty"` +} + +type AuthorizationHeader struct { + // Gets or sets the name of authorization header. + Name *string `json:"name,omitempty"` + // Gets or sets the value of authorization header. + Value *string `json:"value,omitempty"` +} + +type AzureKeyVaultPermission struct { + Provisioned *bool `json:"provisioned,omitempty"` + ResourceProvider *string `json:"resourceProvider,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + Vault *string `json:"vault,omitempty"` +} + +type AzureKeyVaultVariableGroupProviderData struct { + LastRefreshedOn *azuredevops.Time `json:"lastRefreshedOn,omitempty"` + ServiceEndpointId *uuid.UUID `json:"serviceEndpointId,omitempty"` + Vault *string `json:"vault,omitempty"` +} + +type AzureKeyVaultVariableValue struct { + IsSecret *bool `json:"isSecret,omitempty"` + Value *string `json:"value,omitempty"` + ContentType *string `json:"contentType,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Expires *azuredevops.Time `json:"expires,omitempty"` +} + +// Azure Management Group +type AzureManagementGroup struct { + // Display name of azure management group + DisplayName *string `json:"displayName,omitempty"` + // Id of azure management group + Id *string `json:"id,omitempty"` + // Azure management group name + Name *string `json:"name,omitempty"` + // Id of tenant from which azure management group belongs + TenantId *string `json:"tenantId,omitempty"` +} + +// Azure management group query result +type AzureManagementGroupQueryResult struct { + // Error message in case of an exception + ErrorMessage *string `json:"errorMessage,omitempty"` + // List of azure management groups + Value *[]AzureManagementGroup `json:"value,omitempty"` +} + +type AzurePermission struct { + Provisioned *bool `json:"provisioned,omitempty"` + ResourceProvider *string `json:"resourceProvider,omitempty"` +} + +type AzureResourcePermission struct { + Provisioned *bool `json:"provisioned,omitempty"` + ResourceProvider *string `json:"resourceProvider,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` +} + +type AzureRoleAssignmentPermission struct { + Provisioned *bool `json:"provisioned,omitempty"` + ResourceProvider *string `json:"resourceProvider,omitempty"` + RoleAssignmentId *uuid.UUID `json:"roleAssignmentId,omitempty"` +} + +type AzureSpnOperationStatus struct { + State *string `json:"state,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} + +type AzureSubscription struct { + DisplayName *string `json:"displayName,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + SubscriptionTenantId *string `json:"subscriptionTenantId,omitempty"` + SubscriptionTenantName *string `json:"subscriptionTenantName,omitempty"` +} + +type AzureSubscriptionQueryResult struct { + ErrorMessage *string `json:"errorMessage,omitempty"` + Value *[]AzureSubscription `json:"value,omitempty"` +} + +type ClientCertificate struct { + // Gets or sets the value of client certificate. + Value *string `json:"value,omitempty"` +} + +type CounterVariable struct { + Prefix *string `json:"prefix,omitempty"` + Seed *int `json:"seed,omitempty"` + Value *int `json:"value,omitempty"` +} + +type DataSource struct { + AuthenticationScheme *AuthenticationSchemeReference `json:"authenticationScheme,omitempty"` + EndpointUrl *string `json:"endpointUrl,omitempty"` + Headers *[]AuthorizationHeader `json:"headers,omitempty"` + Name *string `json:"name,omitempty"` + ResourceUrl *string `json:"resourceUrl,omitempty"` + ResultSelector *string `json:"resultSelector,omitempty"` +} + +type DataSourceBinding struct { + // Pagination format supported by this data source(ContinuationToken/SkipTop). + CallbackContextTemplate *string `json:"callbackContextTemplate,omitempty"` + // Subsequent calls needed? + CallbackRequiredTemplate *string `json:"callbackRequiredTemplate,omitempty"` + // Gets or sets the name of the data source. + DataSourceName *string `json:"dataSourceName,omitempty"` + // Gets or sets the endpoint Id. + EndpointId *string `json:"endpointId,omitempty"` + // Gets or sets the url of the service endpoint. + EndpointUrl *string `json:"endpointUrl,omitempty"` + // Gets or sets the authorization headers. + Headers *[]distributedtaskcommon.AuthorizationHeader `json:"headers,omitempty"` + // Defines the initial value of the query params + InitialContextTemplate *string `json:"initialContextTemplate,omitempty"` + // Gets or sets the parameters for the data source. + Parameters *map[string]string `json:"parameters,omitempty"` + // Gets or sets http request body + RequestContent *string `json:"requestContent,omitempty"` + // Gets or sets http request verb + RequestVerb *string `json:"requestVerb,omitempty"` + // Gets or sets the result selector. + ResultSelector *string `json:"resultSelector,omitempty"` + // Gets or sets the result template. + ResultTemplate *string `json:"resultTemplate,omitempty"` + // Gets or sets the target of the data source. + Target *string `json:"target,omitempty"` +} + +type DataSourceDetails struct { + DataSourceName *string `json:"dataSourceName,omitempty"` + DataSourceUrl *string `json:"dataSourceUrl,omitempty"` + Headers *[]AuthorizationHeader `json:"headers,omitempty"` + Parameters *map[string]string `json:"parameters,omitempty"` + ResourceUrl *string `json:"resourceUrl,omitempty"` + ResultSelector *string `json:"resultSelector,omitempty"` +} + +type Demand struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +type DemandEquals struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +type DemandExists struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +type DemandMinimumVersion struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +type DependencyBinding struct { + Key *string `json:"key,omitempty"` + Value *string `json:"value,omitempty"` +} + +type DependencyData struct { + Input *string `json:"input,omitempty"` + Map *[]azuredevops.KeyValuePair `json:"map,omitempty"` +} + +type DependsOn struct { + Input *string `json:"input,omitempty"` + Map *[]DependencyBinding `json:"map,omitempty"` +} + +type DeploymentGatesChangeEvent struct { + GateNames *[]string `json:"gateNames,omitempty"` +} + +// Deployment group. +type DeploymentGroup struct { + // Deployment group identifier. + Id *int `json:"id,omitempty"` + // Name of the deployment group. + Name *string `json:"name,omitempty"` + // Deployment pool in which deployment agents are registered. + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + // Project to which the deployment group belongs. + Project *ProjectReference `json:"project,omitempty"` + // Description of the deployment group. + Description *string `json:"description,omitempty"` + // Number of deployment targets in the deployment group. + MachineCount *int `json:"machineCount,omitempty"` + // List of deployment targets in the deployment group. + Machines *[]DeploymentMachine `json:"machines,omitempty"` + // List of unique tags across all deployment targets in the deployment group. + MachineTags *[]string `json:"machineTags,omitempty"` +} + +// [Flags] This is useful in getting a list of deployment groups, filtered for which caller has permissions to take a particular action. +type DeploymentGroupActionFilter string + +type deploymentGroupActionFilterValuesType struct { + None DeploymentGroupActionFilter + Manage DeploymentGroupActionFilter + Use DeploymentGroupActionFilter +} + +var DeploymentGroupActionFilterValues = deploymentGroupActionFilterValuesType{ + // All deployment groups. + None: "none", + // Only deployment groups for which caller has **manage** permission. + Manage: "manage", + // Only deployment groups for which caller has **use** permission. + Use: "use", +} + +// Properties to create Deployment group. +type DeploymentGroupCreateParameter struct { + // Description of the deployment group. + Description *string `json:"description,omitempty"` + // Name of the deployment group. + Name *string `json:"name,omitempty"` + // Identifier of the deployment pool in which deployment agents are registered. + PoolId *int `json:"poolId,omitempty"` +} + +// Properties of Deployment pool to create Deployment group. +type DeploymentGroupCreateParameterPoolProperty struct { + // Deployment pool identifier. + Id *int `json:"id,omitempty"` +} + +// [Flags] Properties to be included or expanded in deployment group objects. This is useful when getting a single or list of deployment grouops. +type DeploymentGroupExpands string + +type deploymentGroupExpandsValuesType struct { + None DeploymentGroupExpands + Machines DeploymentGroupExpands + Tags DeploymentGroupExpands +} + +var DeploymentGroupExpandsValues = deploymentGroupExpandsValuesType{ + // No additional properties. + None: "none", + // Deprecated: Include all the deployment targets. + Machines: "machines", + // Include unique list of tags across all deployment targets. + Tags: "tags", +} + +// Deployment group metrics. +type DeploymentGroupMetrics struct { + // List of deployment group properties. And types of metrics provided for those properties. + ColumnsHeader *MetricsColumnsHeader `json:"columnsHeader,omitempty"` + // Deployment group. + DeploymentGroup *DeploymentGroupReference `json:"deploymentGroup,omitempty"` + // Values of properties and the metrics. E.g. 1: total count of deployment targets for which 'TargetState' is 'offline'. E.g. 2: Average time of deployment to the deployment targets for which 'LastJobStatus' is 'passed' and 'TargetState' is 'online'. + Rows *[]MetricsRow `json:"rows,omitempty"` +} + +// Deployment group reference. This is useful for referring a deployment group in another object. +type DeploymentGroupReference struct { + // Deployment group identifier. + Id *int `json:"id,omitempty"` + // Name of the deployment group. + Name *string `json:"name,omitempty"` + // Deployment pool in which deployment agents are registered. + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + // Project to which the deployment group belongs. + Project *ProjectReference `json:"project,omitempty"` +} + +// Deployment group update parameter. +type DeploymentGroupUpdateParameter struct { + // Description of the deployment group. + Description *string `json:"description,omitempty"` + // Name of the deployment group. + Name *string `json:"name,omitempty"` +} + +// Deployment target. +type DeploymentMachine struct { + // Deployment agent. + Agent *TaskAgent `json:"agent,omitempty"` + // Deployment target Identifier. + Id *int `json:"id,omitempty"` + // Properties of the deployment target. + Properties interface{} `json:"properties,omitempty"` + // Tags of the deployment target. + Tags *[]string `json:"tags,omitempty"` +} + +type DeploymentMachineChangedData struct { + // Deployment agent. + Agent *TaskAgent `json:"agent,omitempty"` + // Deployment target Identifier. + Id *int `json:"id,omitempty"` + // Properties of the deployment target. + Properties interface{} `json:"properties,omitempty"` + // Tags of the deployment target. + Tags *[]string `json:"tags,omitempty"` + AddedTags *[]string `json:"addedTags,omitempty"` + DeletedTags *[]string `json:"deletedTags,omitempty"` +} + +// [Flags] +type DeploymentMachineExpands string + +type deploymentMachineExpandsValuesType struct { + None DeploymentMachineExpands + Capabilities DeploymentMachineExpands + AssignedRequest DeploymentMachineExpands +} + +var DeploymentMachineExpandsValues = deploymentMachineExpandsValuesType{ + None: "none", + Capabilities: "capabilities", + AssignedRequest: "assignedRequest", +} + +type DeploymentMachineGroup struct { + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + Machines *[]DeploymentMachine `json:"machines,omitempty"` + Size *int `json:"size,omitempty"` +} + +type DeploymentMachineGroupReference struct { + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + Project *ProjectReference `json:"project,omitempty"` +} + +type DeploymentMachinesChangeEvent struct { + MachineGroupReference *DeploymentGroupReference `json:"machineGroupReference,omitempty"` + Machines *[]DeploymentMachineChangedData `json:"machines,omitempty"` +} + +// Deployment pool summary. +type DeploymentPoolSummary struct { + // List of deployment groups referring to the deployment pool. + DeploymentGroups *[]DeploymentGroupReference `json:"deploymentGroups,omitempty"` + // Number of deployment agents that are offline. + OfflineAgentsCount *int `json:"offlineAgentsCount,omitempty"` + // Number of deployment agents that are online. + OnlineAgentsCount *int `json:"onlineAgentsCount,omitempty"` + // Deployment pool. + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + // Virtual machine Resource referring in pool. + Resource *EnvironmentResourceReference `json:"resource,omitempty"` +} + +// [Flags] Properties to be included or expanded in deployment pool summary objects. This is useful when getting a single or list of deployment pool summaries. +type DeploymentPoolSummaryExpands string + +type deploymentPoolSummaryExpandsValuesType struct { + None DeploymentPoolSummaryExpands + DeploymentGroups DeploymentPoolSummaryExpands + Resource DeploymentPoolSummaryExpands +} + +var DeploymentPoolSummaryExpandsValues = deploymentPoolSummaryExpandsValuesType{ + // No additional properties + None: "none", + // Include deployment groups referring to the deployment pool. + DeploymentGroups: "deploymentGroups", + // Include Resource referring to the deployment pool. + Resource: "resource", +} + +// [Flags] Properties to be included or expanded in deployment target objects. This is useful when getting a single or list of deployment targets. +type DeploymentTargetExpands string + +type deploymentTargetExpandsValuesType struct { + None DeploymentTargetExpands + Capabilities DeploymentTargetExpands + AssignedRequest DeploymentTargetExpands + LastCompletedRequest DeploymentTargetExpands +} + +var DeploymentTargetExpandsValues = deploymentTargetExpandsValuesType{ + // No additional properties. + None: "none", + // Include capabilities of the deployment agent. + Capabilities: "capabilities", + // Include the job request assigned to the deployment agent. + AssignedRequest: "assignedRequest", + // Include the last completed job request of the deployment agent. + LastCompletedRequest: "lastCompletedRequest", +} + +// Deployment target update parameter. +type DeploymentTargetUpdateParameter struct { + // Identifier of the deployment target. + Id *int `json:"id,omitempty"` + Tags *[]string `json:"tags,omitempty"` +} + +type DiagnosticLogMetadata struct { + AgentId *int `json:"agentId,omitempty"` + AgentName *string `json:"agentName,omitempty"` + FileName *string `json:"fileName,omitempty"` + PhaseName *string `json:"phaseName,omitempty"` + PhaseResult *string `json:"phaseResult,omitempty"` + PoolId *int `json:"poolId,omitempty"` +} + +type EndpointAuthorization struct { + // Gets or sets the parameters for the selected authorization scheme. + Parameters *map[string]string `json:"parameters,omitempty"` + // Gets or sets the scheme used for service endpoint authentication. + Scheme *string `json:"scheme,omitempty"` +} + +// Represents url of the service endpoint. +type EndpointUrl struct { + // Gets or sets the dependency bindings. + DependsOn *DependsOn `json:"dependsOn,omitempty"` + // Gets or sets the display name of service endpoint url. + DisplayName *string `json:"displayName,omitempty"` + // Gets or sets the help text of service endpoint url. + HelpText *string `json:"helpText,omitempty"` + // Gets or sets the visibility of service endpoint url. + IsVisible *string `json:"isVisible,omitempty"` + // Gets or sets the value of service endpoint url. + Value *string `json:"value,omitempty"` +} + +// [Flags] This is useful in getting a list of Environments, filtered for which caller has permissions to take a particular action. +type EnvironmentActionFilter string + +type environmentActionFilterValuesType struct { + None EnvironmentActionFilter + Manage EnvironmentActionFilter + Use EnvironmentActionFilter +} + +var EnvironmentActionFilterValues = environmentActionFilterValuesType{ + // All environments for which user has **view** permission. + None: "none", + // Only environments for which caller has **manage** permission. + Manage: "manage", + // Only environments for which caller has **use** permission. + Use: "use", +} + +// Properties to create Environment. +type EnvironmentCreateParameter struct { + // Description of the environment. + Description *string `json:"description,omitempty"` + // Name of the environment. + Name *string `json:"name,omitempty"` +} + +// EnvironmentDeploymentExecutionRecord. +type EnvironmentDeploymentExecutionRecord struct { + // Definition of the environment deployment execution owner + Definition *TaskOrchestrationOwner `json:"definition,omitempty"` + // Id of the Environment + EnvironmentId *int `json:"environmentId,omitempty"` + // Finish time of the environment deployment execution + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + // Id of the Environment deployment execution history record + Id *uint64 `json:"id,omitempty"` + // Job Attempt + JobAttempt *int `json:"jobAttempt,omitempty"` + // Job name + JobName *string `json:"jobName,omitempty"` + // Owner of the environment deployment execution record + Owner *TaskOrchestrationOwner `json:"owner,omitempty"` + // Plan Id + PlanId *uuid.UUID `json:"planId,omitempty"` + // Plan type of the environment deployment execution record + PlanType *string `json:"planType,omitempty"` + // Queue time of the environment deployment execution + QueueTime *azuredevops.Time `json:"queueTime,omitempty"` + // Request identifier of the Environment deployment execution history record + RequestIdentifier *string `json:"requestIdentifier,omitempty"` + // Resource Id + ResourceId *int `json:"resourceId,omitempty"` + // Result of the environment deployment execution + Result *TaskResult `json:"result,omitempty"` + // Project Id + ScopeId *uuid.UUID `json:"scopeId,omitempty"` + // Service owner Id + ServiceOwner *uuid.UUID `json:"serviceOwner,omitempty"` + // Stage Attempt + StageAttempt *int `json:"stageAttempt,omitempty"` + // Stage name + StageName *string `json:"stageName,omitempty"` + // Start time of the environment deployment execution + StartTime *azuredevops.Time `json:"startTime,omitempty"` +} + +// [Flags] Properties to be included or expanded in environment objects. This is useful when getting a single environment. +type EnvironmentExpands string + +type environmentExpandsValuesType struct { + None EnvironmentExpands + ResourceReferences EnvironmentExpands +} + +var EnvironmentExpandsValues = environmentExpandsValuesType{ + // No additional properties + None: "none", + // Include resource references referring to the environment. + ResourceReferences: "resourceReferences", +} + +// Environment. +type EnvironmentInstance struct { + // Identity reference of the user who created the Environment. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Creation time of the Environment + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Description of the Environment. + Description *string `json:"description,omitempty"` + // Id of the Environment + Id *int `json:"id,omitempty"` + // Identity reference of the user who last modified the Environment. + LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` + // Last modified time of the Environment + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + // Name of the Environment. + Name *string `json:"name,omitempty"` + Resources *[]EnvironmentResourceReference `json:"resources,omitempty"` +} + +// EnvironmentLinkedResourceReference. +type EnvironmentLinkedResourceReference struct { + // Id of the resource. + Id *string `json:"id,omitempty"` + // Type of resource. + TypeName *string `json:"typeName,omitempty"` +} + +type EnvironmentReference struct { + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type EnvironmentResource struct { + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + EnvironmentReference *EnvironmentReference `json:"environmentReference,omitempty"` + Id *int `json:"id,omitempty"` + LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + Name *string `json:"name,omitempty"` + // Environment resource type + Type *EnvironmentResourceType `json:"type,omitempty"` +} + +// EnvironmentResourceReference. +type EnvironmentResourceReference struct { + // Id of the resource. + Id *int `json:"id,omitempty"` + // Name of the resource. + Name *string `json:"name,omitempty"` + // Type of the resource. + Type *EnvironmentResourceType `json:"type,omitempty"` +} + +// [Flags] EnvironmentResourceType. +type EnvironmentResourceType string + +type environmentResourceTypeValuesType struct { + Undefined EnvironmentResourceType + Generic EnvironmentResourceType + VirtualMachine EnvironmentResourceType + Kubernetes EnvironmentResourceType +} + +var EnvironmentResourceTypeValues = environmentResourceTypeValuesType{ + Undefined: "undefined", + // Unknown resource type + Generic: "generic", + // Virtual machine resource type + VirtualMachine: "virtualMachine", + // Kubernetes resource type + Kubernetes: "kubernetes", +} + +// Properties to update Environment. +type EnvironmentUpdateParameter struct { + // Description of the environment. + Description *string `json:"description,omitempty"` + // Name of the environment. + Name *string `json:"name,omitempty"` +} + +type EventsConfig struct { +} + +type ExpressionValidationItem struct { + // Tells whether the current input is valid or not + IsValid *bool `json:"isValid,omitempty"` + // Reason for input validation failure + Reason *string `json:"reason,omitempty"` + // Type of validation item + Type *string `json:"type,omitempty"` + // Value to validate. The conditional expression to validate for the input for "expression" type Eg:eq(variables['Build.SourceBranch'], 'refs/heads/master');eq(value, 'refs/heads/master') + Value *string `json:"value,omitempty"` +} + +type HelpLink struct { + Text *string `json:"text,omitempty"` + Url *string `json:"url,omitempty"` +} + +type InputBindingContext struct { + // Value of the input + Value *string `json:"value,omitempty"` +} + +type InputValidationItem struct { + // Tells whether the current input is valid or not + IsValid *bool `json:"isValid,omitempty"` + // Reason for input validation failure + Reason *string `json:"reason,omitempty"` + // Type of validation item + Type *string `json:"type,omitempty"` + // Value to validate. The conditional expression to validate for the input for "expression" type Eg:eq(variables['Build.SourceBranch'], 'refs/heads/master');eq(value, 'refs/heads/master') + Value *string `json:"value,omitempty"` + // Provides binding context for the expression to evaluate + Context *InputBindingContext `json:"context,omitempty"` +} + +type InputValidationRequest struct { + Inputs *map[string]ValidationItem `json:"inputs,omitempty"` +} + +type Issue struct { + Category *string `json:"category,omitempty"` + Data *map[string]string `json:"data,omitempty"` + Message *string `json:"message,omitempty"` + Type *IssueType `json:"type,omitempty"` +} + +type IssueType string + +type issueTypeValuesType struct { + Error IssueType + Warning IssueType +} + +var IssueTypeValues = issueTypeValuesType{ + Error: "error", + Warning: "warning", +} + +type JobAssignedEvent struct { + JobId *uuid.UUID `json:"jobId,omitempty"` + Name *string `json:"name,omitempty"` + Request *TaskAgentJobRequest `json:"request,omitempty"` +} + +type JobCancelMessage struct { + JobId *uuid.UUID `json:"jobId,omitempty"` + Timeout interface{} `json:"timeout,omitempty"` +} + +type JobCompletedEvent struct { + JobId *uuid.UUID `json:"jobId,omitempty"` + Name *string `json:"name,omitempty"` + RequestId *uint64 `json:"requestId,omitempty"` + Result *TaskResult `json:"result,omitempty"` +} + +// Represents the context of variables and vectors for a job request. +type JobEnvironment struct { + Endpoints *[]ServiceEndpoint `json:"endpoints,omitempty"` + Mask *[]MaskHint `json:"mask,omitempty"` + Options *map[uuid.UUID]JobOption `json:"options,omitempty"` + SecureFiles *[]SecureFile `json:"secureFiles,omitempty"` + // Gets or sets the endpoint used for communicating back to the calling service. + SystemConnection *ServiceEndpoint `json:"systemConnection,omitempty"` + Variables *map[string]string `json:"variables,omitempty"` +} + +type JobEvent struct { + JobId *uuid.UUID `json:"jobId,omitempty"` + Name *string `json:"name,omitempty"` +} + +type JobEventConfig struct { + Timeout *string `json:"timeout,omitempty"` +} + +type JobEventsConfig struct { + JobAssigned *JobEventConfig `json:"jobAssigned,omitempty"` + JobCompleted *JobEventConfig `json:"jobCompleted,omitempty"` + JobStarted *JobEventConfig `json:"jobStarted,omitempty"` +} + +// Represents an option that may affect the way an agent runs the job. +type JobOption struct { + Data *map[string]string `json:"data,omitempty"` + // Gets the id of the option. + Id *uuid.UUID `json:"id,omitempty"` +} + +type JobRequestMessage struct { + Environment *JobEnvironment `json:"environment,omitempty"` + JobId *uuid.UUID `json:"jobId,omitempty"` + JobName *string `json:"jobName,omitempty"` + JobRefName *string `json:"jobRefName,omitempty"` + MessageType *string `json:"messageType,omitempty"` + Plan *TaskOrchestrationPlanReference `json:"plan,omitempty"` + Timeline *TimelineReference `json:"timeline,omitempty"` +} + +type JobStartedEvent struct { + JobId *uuid.UUID `json:"jobId,omitempty"` + Name *string `json:"name,omitempty"` +} + +type KubernetesResource struct { + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + EnvironmentReference *EnvironmentReference `json:"environmentReference,omitempty"` + Id *int `json:"id,omitempty"` + LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + Name *string `json:"name,omitempty"` + // Environment resource type + Type *EnvironmentResourceType `json:"type,omitempty"` + ClusterName *string `json:"clusterName,omitempty"` + Namespace *string `json:"namespace,omitempty"` + ServiceEndpointId *uuid.UUID `json:"serviceEndpointId,omitempty"` +} + +type KubernetesResourceCreateParameters struct { + ClusterName *string `json:"clusterName,omitempty"` + Name *string `json:"name,omitempty"` + Namespace *string `json:"namespace,omitempty"` + ServiceEndpointId *uuid.UUID `json:"serviceEndpointId,omitempty"` +} + +// [Flags] +type MachineGroupActionFilter string + +type machineGroupActionFilterValuesType struct { + None MachineGroupActionFilter + Manage MachineGroupActionFilter + Use MachineGroupActionFilter +} + +var MachineGroupActionFilterValues = machineGroupActionFilterValuesType{ + None: "none", + Manage: "manage", + Use: "use", +} + +// Represents a purchase of resource units in a secondary marketplace. +type MarketplacePurchasedLicense struct { + // The Marketplace display name. + MarketplaceName *string `json:"marketplaceName,omitempty"` + // The name of the identity making the purchase as seen by the marketplace + PurchaserName *string `json:"purchaserName,omitempty"` + // The quantity purchased. + PurchaseUnitCount *int `json:"purchaseUnitCount,omitempty"` +} + +type MaskHint struct { + Type *MaskType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +type MaskType string + +type maskTypeValuesType struct { + Variable MaskType + Regex MaskType +} + +var MaskTypeValues = maskTypeValuesType{ + Variable: "variable", + Regex: "regex", +} + +// Meta data for a metrics column. +type MetricsColumnMetaData struct { + // Name. + ColumnName *string `json:"columnName,omitempty"` + // Data type. + ColumnValueType *string `json:"columnValueType,omitempty"` +} + +// Metrics columns header +type MetricsColumnsHeader struct { + // Properties of deployment group for which metrics are provided. E.g. 1: LastJobStatus E.g. 2: TargetState + Dimensions *[]MetricsColumnMetaData `json:"dimensions,omitempty"` + // The types of metrics. E.g. 1: total count of deployment targets. E.g. 2: Average time of deployment to the deployment targets. + Metrics *[]MetricsColumnMetaData `json:"metrics,omitempty"` +} + +// Metrics row. +type MetricsRow struct { + // The values of the properties mentioned as 'Dimensions' in column header. E.g. 1: For a property 'LastJobStatus' - metrics will be provided for 'passed', 'failed', etc. E.g. 2: For a property 'TargetState' - metrics will be provided for 'online', 'offline' targets. + Dimensions *[]string `json:"dimensions,omitempty"` + // Metrics in serialized format. Should be deserialized based on the data type provided in header. + Metrics *[]string `json:"metrics,omitempty"` +} + +// Represents a downloadable package. +type PackageMetadata struct { + // The date the package was created + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // A direct link to download the package. + DownloadUrl *string `json:"downloadUrl,omitempty"` + // The UI uses this to display instructions, i.e. "unzip MyAgent.zip" + Filename *string `json:"filename,omitempty"` + // MD5 hash as a base64 string + HashValue *string `json:"hashValue,omitempty"` + // A link to documentation + InfoUrl *string `json:"infoUrl,omitempty"` + // The platform (win7, linux, etc.) + Platform *string `json:"platform,omitempty"` + // The type of package (e.g. "agent") + Type *string `json:"type,omitempty"` + // The package version. + Version *PackageVersion `json:"version,omitempty"` +} + +type PackageVersion struct { + Major *int `json:"major,omitempty"` + Minor *int `json:"minor,omitempty"` + Patch *int `json:"patch,omitempty"` +} + +type PlanEnvironment struct { + Mask *[]MaskHint `json:"mask,omitempty"` + Options *map[uuid.UUID]JobOption `json:"options,omitempty"` + Variables *map[string]string `json:"variables,omitempty"` +} + +// [Flags] +type PlanGroupStatus string + +type planGroupStatusValuesType struct { + Running PlanGroupStatus + Queued PlanGroupStatus + All PlanGroupStatus +} + +var PlanGroupStatusValues = planGroupStatusValuesType{ + Running: "running", + Queued: "queued", + All: "all", +} + +// [Flags] +type PlanGroupStatusFilter string + +type planGroupStatusFilterValuesType struct { + Running PlanGroupStatusFilter + Queued PlanGroupStatusFilter + All PlanGroupStatusFilter +} + +var PlanGroupStatusFilterValues = planGroupStatusFilterValuesType{ + Running: "running", + Queued: "queued", + All: "all", +} + +type ProjectReference struct { + Id *uuid.UUID `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type PublishTaskGroupMetadata struct { + Comment *string `json:"comment,omitempty"` + ParentDefinitionRevision *int `json:"parentDefinitionRevision,omitempty"` + Preview *bool `json:"preview,omitempty"` + TaskGroupId *uuid.UUID `json:"taskGroupId,omitempty"` + TaskGroupRevision *int `json:"taskGroupRevision,omitempty"` +} + +type ResourceFilterOptions struct { + Identities *[]webapi.IdentityRef `json:"identities,omitempty"` + ResourceTypes *[]string `json:"resourceTypes,omitempty"` +} + +type ResourceFilters struct { + CreatedBy *[]uuid.UUID `json:"createdBy,omitempty"` + ResourceType *[]string `json:"resourceType,omitempty"` + SearchText *string `json:"searchText,omitempty"` +} + +// Resources include Service Connections, Variable Groups and Secure Files. +type ResourceItem struct { + // Gets or sets the identity who created the resource. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets or sets description of the resource. + Description *string `json:"description,omitempty"` + // Gets or sets icon url of the resource. + IconUrl *string `json:"iconUrl,omitempty"` + // Gets or sets Id of the resource. + Id *string `json:"id,omitempty"` + // Indicates whether resource is shared with other projects or not. + IsShared *bool `json:"isShared,omitempty"` + // Gets or sets name of the resource. + Name *string `json:"name,omitempty"` + // Gets or sets internal properties of the resource. + Properties *map[string]string `json:"properties,omitempty"` + // Gets or sets resource type. + ResourceType *string `json:"resourceType,omitempty"` +} + +type ResourceLimit struct { + FailedToReachAllProviders *bool `json:"failedToReachAllProviders,omitempty"` + HostId *uuid.UUID `json:"hostId,omitempty"` + IsHosted *bool `json:"isHosted,omitempty"` + IsPremium *bool `json:"isPremium,omitempty"` + ParallelismTag *string `json:"parallelismTag,omitempty"` + ResourceLimitsData *map[string]string `json:"resourceLimitsData,omitempty"` + TotalCount *int `json:"totalCount,omitempty"` + TotalMinutes *int `json:"totalMinutes,omitempty"` +} + +type ResourcesHubData struct { + ContinuationToken *string `json:"continuationToken,omitempty"` + ResourceFilterOptions *ResourceFilterOptions `json:"resourceFilterOptions,omitempty"` + ResourceFilters *ResourceFilters `json:"resourceFilters,omitempty"` + ResourceItems *[]ResourceItem `json:"resourceItems,omitempty"` +} + +type ResourceUsage struct { + ResourceLimit *ResourceLimit `json:"resourceLimit,omitempty"` + RunningRequests *[]TaskAgentJobRequest `json:"runningRequests,omitempty"` + UsedCount *int `json:"usedCount,omitempty"` + UsedMinutes *int `json:"usedMinutes,omitempty"` +} + +type ResultTransformationDetails struct { + ResultTemplate *string `json:"resultTemplate,omitempty"` +} + +type SecureFile struct { + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Ticket *string `json:"ticket,omitempty"` +} + +// [Flags] +type SecureFileActionFilter string + +type secureFileActionFilterValuesType struct { + None SecureFileActionFilter + Manage SecureFileActionFilter + Use SecureFileActionFilter +} + +var SecureFileActionFilterValues = secureFileActionFilterValuesType{ + None: "none", + Manage: "manage", + Use: "use", +} + +type SecureFileEvent struct { + EventType *string `json:"eventType,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + SecureFiles *[]SecureFile `json:"secureFiles,omitempty"` +} + +type SendJobResponse struct { + Events *JobEventsConfig `json:"events,omitempty"` + Variables *map[string]string `json:"variables,omitempty"` +} + +type ServerExecutionDefinition struct { + Events *EventsConfig `json:"events,omitempty"` + HandlerName *string `json:"handlerName,omitempty"` +} + +type ServerTaskRequestMessage struct { + Environment *JobEnvironment `json:"environment,omitempty"` + JobId *uuid.UUID `json:"jobId,omitempty"` + JobName *string `json:"jobName,omitempty"` + JobRefName *string `json:"jobRefName,omitempty"` + MessageType *string `json:"messageType,omitempty"` + Plan *TaskOrchestrationPlanReference `json:"plan,omitempty"` + Timeline *TimelineReference `json:"timeline,omitempty"` + TaskDefinition *TaskDefinition `json:"taskDefinition,omitempty"` + TaskInstance *TaskInstance `json:"taskInstance,omitempty"` +} + +// Represents an endpoint which may be used by an orchestration job. +type ServiceEndpoint struct { + // Gets or sets the identity reference for the administrators group of the service endpoint. + AdministratorsGroup *webapi.IdentityRef `json:"administratorsGroup,omitempty"` + // Gets or sets the authorization data for talking to the endpoint. + Authorization *EndpointAuthorization `json:"authorization,omitempty"` + // Gets or sets the identity reference for the user who created the Service endpoint. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + Data *map[string]string `json:"data,omitempty"` + // Gets or sets the description of endpoint. + Description *string `json:"description,omitempty"` + GroupScopeId *uuid.UUID `json:"groupScopeId,omitempty"` + // Gets or sets the identifier of this endpoint. + Id *uuid.UUID `json:"id,omitempty"` + // EndPoint state indicator + IsReady *bool `json:"isReady,omitempty"` + // Indicates whether service endpoint is shared with other projects or not. + IsShared *bool `json:"isShared,omitempty"` + // Gets or sets the friendly name of the endpoint. + Name *string `json:"name,omitempty"` + // Error message during creation/deletion of endpoint + OperationStatus interface{} `json:"operationStatus,omitempty"` + // Gets or sets the owner of the endpoint. + Owner *string `json:"owner,omitempty"` + // Gets or sets the identity reference for the readers group of the service endpoint. + ReadersGroup *webapi.IdentityRef `json:"readersGroup,omitempty"` + // Gets or sets the type of the endpoint. + Type *string `json:"type,omitempty"` + // Gets or sets the url of the endpoint. + Url *string `json:"url,omitempty"` +} + +type ServiceEndpointAuthenticationScheme struct { + // Gets or sets the authorization headers of service endpoint authentication scheme. + AuthorizationHeaders *[]AuthorizationHeader `json:"authorizationHeaders,omitempty"` + // Gets or sets the certificates of service endpoint authentication scheme. + ClientCertificates *[]ClientCertificate `json:"clientCertificates,omitempty"` + // Gets or sets the display name for the service endpoint authentication scheme. + DisplayName *string `json:"displayName,omitempty"` + // Gets or sets the input descriptors for the service endpoint authentication scheme. + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + // Gets or sets the scheme for service endpoint authentication. + Scheme *string `json:"scheme,omitempty"` +} + +type ServiceEndpointDetails struct { + Authorization *EndpointAuthorization `json:"authorization,omitempty"` + Data *map[string]string `json:"data,omitempty"` + Type *string `json:"type,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Represents service endpoint execution data. +type ServiceEndpointExecutionData struct { + // Gets the definition of service endpoint execution owner. + Definition *TaskOrchestrationOwner `json:"definition,omitempty"` + // Gets the finish time of service endpoint execution. + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + // Gets the Id of service endpoint execution data. + Id *uint64 `json:"id,omitempty"` + // Gets the owner of service endpoint execution data. + Owner *TaskOrchestrationOwner `json:"owner,omitempty"` + // Gets the plan type of service endpoint execution data. + PlanType *string `json:"planType,omitempty"` + // Gets the result of service endpoint execution. + Result *TaskResult `json:"result,omitempty"` + // Gets the start time of service endpoint execution. + StartTime *azuredevops.Time `json:"startTime,omitempty"` +} + +type ServiceEndpointExecutionRecord struct { + // Gets the execution data of service endpoint execution. + Data *ServiceEndpointExecutionData `json:"data,omitempty"` + // Gets the Id of service endpoint. + EndpointId *uuid.UUID `json:"endpointId,omitempty"` +} + +type ServiceEndpointExecutionRecordsInput struct { + Data *ServiceEndpointExecutionData `json:"data,omitempty"` + EndpointIds *[]uuid.UUID `json:"endpointIds,omitempty"` +} + +type ServiceEndpointRequest struct { + DataSourceDetails *DataSourceDetails `json:"dataSourceDetails,omitempty"` + ResultTransformationDetails *ResultTransformationDetails `json:"resultTransformationDetails,omitempty"` + ServiceEndpointDetails *ServiceEndpointDetails `json:"serviceEndpointDetails,omitempty"` +} + +type ServiceEndpointRequestResult struct { + ErrorMessage *string `json:"errorMessage,omitempty"` + Result interface{} `json:"result,omitempty"` + StatusCode *string `json:"statusCode,omitempty"` +} + +// Represents type of the service endpoint. +type ServiceEndpointType struct { + // Authentication scheme of service endpoint type. + AuthenticationSchemes *[]ServiceEndpointAuthenticationScheme `json:"authenticationSchemes,omitempty"` + // Data sources of service endpoint type. + DataSources *[]DataSource `json:"dataSources,omitempty"` + // Dependency data of service endpoint type. + DependencyData *[]DependencyData `json:"dependencyData,omitempty"` + // Gets or sets the description of service endpoint type. + Description *string `json:"description,omitempty"` + // Gets or sets the display name of service endpoint type. + DisplayName *string `json:"displayName,omitempty"` + // Gets or sets the endpoint url of service endpoint type. + EndpointUrl *EndpointUrl `json:"endpointUrl,omitempty"` + // Gets or sets the help link of service endpoint type. + HelpLink *HelpLink `json:"helpLink,omitempty"` + HelpMarkDown *string `json:"helpMarkDown,omitempty"` + // Gets or sets the icon url of service endpoint type. + IconUrl *string `json:"iconUrl,omitempty"` + // Input descriptor of service endpoint type. + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + // Gets or sets the name of service endpoint type. + Name *string `json:"name,omitempty"` + // Trusted hosts of a service endpoint type. + TrustedHosts *[]string `json:"trustedHosts,omitempty"` + // Gets or sets the ui contribution id of service endpoint type. + UiContributionId *string `json:"uiContributionId,omitempty"` +} + +// A task agent. +type TaskAgent struct { + Links interface{} `json:"_links,omitempty"` + // This agent's access point. + AccessPoint *string `json:"accessPoint,omitempty"` + // Whether or not this agent should run jobs. + Enabled *bool `json:"enabled,omitempty"` + // Identifier of the agent. + Id *int `json:"id,omitempty"` + // Name of the agent. + Name *string `json:"name,omitempty"` + // Agent OS. + OsDescription *string `json:"osDescription,omitempty"` + // Provisioning state of this agent. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Whether or not the agent is online. + Status *TaskAgentStatus `json:"status,omitempty"` + // Agent version. + Version *string `json:"version,omitempty"` + // The agent cloud request that's currently associated with this agent. + AssignedAgentCloudRequest *TaskAgentCloudRequest `json:"assignedAgentCloudRequest,omitempty"` + // The request which is currently assigned to this agent. + AssignedRequest *TaskAgentJobRequest `json:"assignedRequest,omitempty"` + // Authorization information for this agent. + Authorization *TaskAgentAuthorization `json:"authorization,omitempty"` + // Date on which this agent was created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // The last request which was completed by this agent. + LastCompletedRequest *TaskAgentJobRequest `json:"lastCompletedRequest,omitempty"` + // Maximum job parallelism allowed for this agent. + MaxParallelism *int `json:"maxParallelism,omitempty"` + // Pending update for this agent. + PendingUpdate *TaskAgentUpdate `json:"pendingUpdate,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // Date on which the last connectivity status change occurred. + StatusChangedOn *azuredevops.Time `json:"statusChangedOn,omitempty"` + SystemCapabilities *map[string]string `json:"systemCapabilities,omitempty"` + UserCapabilities *map[string]string `json:"userCapabilities,omitempty"` +} + +// Provides data necessary for authorizing the agent using OAuth 2.0 authentication flows. +type TaskAgentAuthorization struct { + // Endpoint used to obtain access tokens from the configured token service. + AuthorizationUrl *string `json:"authorizationUrl,omitempty"` + // Client identifier for this agent. + ClientId *uuid.UUID `json:"clientId,omitempty"` + // Public key used to verify the identity of this agent. + PublicKey *TaskAgentPublicKey `json:"publicKey,omitempty"` +} + +type TaskAgentCloud struct { + // Gets or sets a AcquireAgentEndpoint using which a request can be made to acquire new agent + AcquireAgentEndpoint *string `json:"acquireAgentEndpoint,omitempty"` + AcquisitionTimeout *int `json:"acquisitionTimeout,omitempty"` + AgentCloudId *int `json:"agentCloudId,omitempty"` + GetAccountParallelismEndpoint *string `json:"getAccountParallelismEndpoint,omitempty"` + GetAgentDefinitionEndpoint *string `json:"getAgentDefinitionEndpoint,omitempty"` + GetAgentRequestStatusEndpoint *string `json:"getAgentRequestStatusEndpoint,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + // Signifies that this Agent Cloud is internal and should not be user-manageable + Internal *bool `json:"internal,omitempty"` + MaxParallelism *int `json:"maxParallelism,omitempty"` + Name *string `json:"name,omitempty"` + ReleaseAgentEndpoint *string `json:"releaseAgentEndpoint,omitempty"` + SharedSecret *string `json:"sharedSecret,omitempty"` + // Gets or sets the type of the endpoint. + Type *string `json:"type,omitempty"` +} + +type TaskAgentCloudRequest struct { + Agent *TaskAgentReference `json:"agent,omitempty"` + AgentCloudId *int `json:"agentCloudId,omitempty"` + AgentConnectedTime *azuredevops.Time `json:"agentConnectedTime,omitempty"` + AgentData interface{} `json:"agentData,omitempty"` + AgentSpecification interface{} `json:"agentSpecification,omitempty"` + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + ProvisionedTime *azuredevops.Time `json:"provisionedTime,omitempty"` + ProvisionRequestTime *azuredevops.Time `json:"provisionRequestTime,omitempty"` + ReleaseRequestTime *azuredevops.Time `json:"releaseRequestTime,omitempty"` + RequestId *uuid.UUID `json:"requestId,omitempty"` +} + +type TaskAgentCloudType struct { + // Gets or sets the display name of agent cloud type. + DisplayName *string `json:"displayName,omitempty"` + // Gets or sets the input descriptors + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + // Gets or sets the name of agent cloud type. + Name *string `json:"name,omitempty"` +} + +type TaskAgentDelaySource struct { + Delays *[]interface{} `json:"delays,omitempty"` + TaskAgent *TaskAgentReference `json:"taskAgent,omitempty"` +} + +type TaskAgentJob struct { + Container *string `json:"container,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + SidecarContainers *map[string]string `json:"sidecarContainers,omitempty"` + Steps *[]TaskAgentJobStep `json:"steps,omitempty"` + Variables *[]TaskAgentJobVariable `json:"variables,omitempty"` +} + +// A job request for an agent. +type TaskAgentJobRequest struct { + AgentDelays *[]TaskAgentDelaySource `json:"agentDelays,omitempty"` + AgentSpecification interface{} `json:"agentSpecification,omitempty"` + // The date/time this request was assigned. + AssignTime *azuredevops.Time `json:"assignTime,omitempty"` + // Additional data about the request. + Data *map[string]string `json:"data,omitempty"` + // The pipeline definition associated with this request + Definition *TaskOrchestrationOwner `json:"definition,omitempty"` + // A list of demands required to fulfill this request. + Demands *[]interface{} `json:"demands,omitempty"` + ExpectedDuration interface{} `json:"expectedDuration,omitempty"` + // The date/time this request was finished. + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + // The host which triggered this request. + HostId *uuid.UUID `json:"hostId,omitempty"` + // ID of the job resulting from this request. + JobId *uuid.UUID `json:"jobId,omitempty"` + // Name of the job resulting from this request. + JobName *string `json:"jobName,omitempty"` + // The deadline for the agent to renew the lock. + LockedUntil *azuredevops.Time `json:"lockedUntil,omitempty"` + MatchedAgents *[]TaskAgentReference `json:"matchedAgents,omitempty"` + MatchesAllAgentsInPool *bool `json:"matchesAllAgentsInPool,omitempty"` + OrchestrationId *string `json:"orchestrationId,omitempty"` + // The pipeline associated with this request + Owner *TaskOrchestrationOwner `json:"owner,omitempty"` + PlanGroup *string `json:"planGroup,omitempty"` + // Internal ID for the orchestration plan connected with this request. + PlanId *uuid.UUID `json:"planId,omitempty"` + // Internal detail representing the type of orchestration plan. + PlanType *string `json:"planType,omitempty"` + // The ID of the pool this request targets + PoolId *int `json:"poolId,omitempty"` + // The ID of the queue this request targets + QueueId *int `json:"queueId,omitempty"` + // The date/time this request was queued. + QueueTime *azuredevops.Time `json:"queueTime,omitempty"` + // The date/time this request was receieved by an agent. + ReceiveTime *azuredevops.Time `json:"receiveTime,omitempty"` + // ID of the request. + RequestId *uint64 `json:"requestId,omitempty"` + // The agent allocated for this request. + ReservedAgent *TaskAgentReference `json:"reservedAgent,omitempty"` + // The result of this request. + Result *TaskResult `json:"result,omitempty"` + // Scope of the pipeline; matches the project ID. + ScopeId *uuid.UUID `json:"scopeId,omitempty"` + // The service which owns this request. + ServiceOwner *uuid.UUID `json:"serviceOwner,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` + UserDelayed *bool `json:"userDelayed,omitempty"` +} + +// [Flags] This is useful in getting a list of deployment targets, filtered by the result of their last job. +type TaskAgentJobResultFilter string + +type taskAgentJobResultFilterValuesType struct { + Failed TaskAgentJobResultFilter + Passed TaskAgentJobResultFilter + NeverDeployed TaskAgentJobResultFilter + All TaskAgentJobResultFilter +} + +var TaskAgentJobResultFilterValues = taskAgentJobResultFilterValuesType{ + // Only those deployment targets on which last job failed (**Abandoned**, **Canceled**, **Failed**, **Skipped**). + Failed: "failed", + // Only those deployment targets on which last job Passed (**Succeeded**, **Succeeded with issues**). + Passed: "passed", + // Only those deployment targets that never executed a job. + NeverDeployed: "neverDeployed", + // All deployment targets. + All: "all", +} + +type TaskAgentJobStep struct { + Condition *string `json:"condition,omitempty"` + ContinueOnError *bool `json:"continueOnError,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Env *map[string]string `json:"env,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Inputs *map[string]string `json:"inputs,omitempty"` + Name *string `json:"name,omitempty"` + Task *TaskAgentJobTask `json:"task,omitempty"` + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + Type *TaskAgentJobStepType `json:"type,omitempty"` +} + +type TaskAgentJobStepType string + +type taskAgentJobStepTypeValuesType struct { + Task TaskAgentJobStepType + Action TaskAgentJobStepType +} + +var TaskAgentJobStepTypeValues = taskAgentJobStepTypeValuesType{ + Task: "task", + Action: "action", +} + +type TaskAgentJobTask struct { + Id *uuid.UUID `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +type TaskAgentJobVariable struct { + Name *string `json:"name,omitempty"` + Secret *bool `json:"secret,omitempty"` + Value *string `json:"value,omitempty"` +} + +type TaskAgentManualUpdate struct { + Code *TaskAgentUpdateReasonType `json:"code,omitempty"` +} + +// Provides a contract for receiving messages from the task orchestrator. +type TaskAgentMessage struct { + // Gets or sets the body of the message. If the IV property is provided the body will need to be decrypted using the TaskAgentSession.EncryptionKey value in addition to the IV. + Body *string `json:"body,omitempty"` + // Gets or sets the initialization vector used to encrypt this message. + Iv *[]byte `json:"iv,omitempty"` + // Gets or sets the message identifier. + MessageId *uint64 `json:"messageId,omitempty"` + // Gets or sets the message type, describing the data contract found in TaskAgentMessage.Body. + MessageType *string `json:"messageType,omitempty"` +} + +type TaskAgentMinAgentVersionRequiredUpdate struct { + Code *TaskAgentUpdateReasonType `json:"code,omitempty"` + JobDefinition *TaskOrchestrationOwner `json:"jobDefinition,omitempty"` + JobOwner *TaskOrchestrationOwner `json:"jobOwner,omitempty"` + MinAgentVersion interface{} `json:"minAgentVersion,omitempty"` +} + +// An organization-level grouping of agents. +type TaskAgentPool struct { + Id *int `json:"id,omitempty"` + // Gets or sets a value indicating whether or not this pool is managed by the service. + IsHosted *bool `json:"isHosted,omitempty"` + // Determines whether the pool is legacy. + IsLegacy *bool `json:"isLegacy,omitempty"` + Name *string `json:"name,omitempty"` + // Gets or sets the type of the pool + PoolType *TaskAgentPoolType `json:"poolType,omitempty"` + Scope *uuid.UUID `json:"scope,omitempty"` + // Gets the current size of the pool. + Size *int `json:"size,omitempty"` + // The ID of the associated agent cloud. + AgentCloudId *int `json:"agentCloudId,omitempty"` + // Whether or not a queue should be automatically provisioned for each project collection. + AutoProvision *bool `json:"autoProvision,omitempty"` + // Whether or not the pool should autosize itself based on the Agent Cloud Provider settings. + AutoSize *bool `json:"autoSize,omitempty"` + // Creator of the pool. The creator of the pool is automatically added into the administrators group for the pool on creation. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // The date/time of the pool creation. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Owner or administrator of the pool. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // Target parallelism. + TargetSize *int `json:"targetSize,omitempty"` +} + +// [Flags] Filters pools based on whether the calling user has permission to use or manage the pool. +type TaskAgentPoolActionFilter string + +type taskAgentPoolActionFilterValuesType struct { + None TaskAgentPoolActionFilter + Manage TaskAgentPoolActionFilter + Use TaskAgentPoolActionFilter +} + +var TaskAgentPoolActionFilterValues = taskAgentPoolActionFilterValuesType{ + None: "none", + Manage: "manage", + Use: "use", +} + +type TaskAgentPoolMaintenanceDefinition struct { + // Enable maintenance + Enabled *bool `json:"enabled,omitempty"` + // Id + Id *int `json:"id,omitempty"` + // Maintenance job timeout per agent + JobTimeoutInMinutes *int `json:"jobTimeoutInMinutes,omitempty"` + // Max percentage of agents within a pool running maintenance job at given time + MaxConcurrentAgentsPercentage *int `json:"maxConcurrentAgentsPercentage,omitempty"` + Options *TaskAgentPoolMaintenanceOptions `json:"options,omitempty"` + // Pool reference for the maintenance definition + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + RetentionPolicy *TaskAgentPoolMaintenanceRetentionPolicy `json:"retentionPolicy,omitempty"` + ScheduleSetting *TaskAgentPoolMaintenanceSchedule `json:"scheduleSetting,omitempty"` +} + +type TaskAgentPoolMaintenanceJob struct { + // The maintenance definition for the maintenance job + DefinitionId *int `json:"definitionId,omitempty"` + // The total error counts during the maintenance job + ErrorCount *int `json:"errorCount,omitempty"` + // Time that the maintenance job was completed + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + // Id of the maintenance job + JobId *int `json:"jobId,omitempty"` + // The log download url for the maintenance job + LogsDownloadUrl *string `json:"logsDownloadUrl,omitempty"` + // Orchestration/Plan Id for the maintenance job + OrchestrationId *uuid.UUID `json:"orchestrationId,omitempty"` + // Pool reference for the maintenance job + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + // Time that the maintenance job was queued + QueueTime *azuredevops.Time `json:"queueTime,omitempty"` + // The identity that queued the maintenance job + RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` + // The maintenance job result + Result *TaskAgentPoolMaintenanceJobResult `json:"result,omitempty"` + // Time that the maintenance job was started + StartTime *azuredevops.Time `json:"startTime,omitempty"` + // Status of the maintenance job + Status *TaskAgentPoolMaintenanceJobStatus `json:"status,omitempty"` + TargetAgents *[]TaskAgentPoolMaintenanceJobTargetAgent `json:"targetAgents,omitempty"` + // The total warning counts during the maintenance job + WarningCount *int `json:"warningCount,omitempty"` +} + +type TaskAgentPoolMaintenanceJobResult string + +type taskAgentPoolMaintenanceJobResultValuesType struct { + Succeeded TaskAgentPoolMaintenanceJobResult + Failed TaskAgentPoolMaintenanceJobResult + Canceled TaskAgentPoolMaintenanceJobResult +} + +var TaskAgentPoolMaintenanceJobResultValues = taskAgentPoolMaintenanceJobResultValuesType{ + Succeeded: "succeeded", + Failed: "failed", + Canceled: "canceled", +} + +type TaskAgentPoolMaintenanceJobStatus string + +type taskAgentPoolMaintenanceJobStatusValuesType struct { + InProgress TaskAgentPoolMaintenanceJobStatus + Completed TaskAgentPoolMaintenanceJobStatus + Cancelling TaskAgentPoolMaintenanceJobStatus + Queued TaskAgentPoolMaintenanceJobStatus +} + +var TaskAgentPoolMaintenanceJobStatusValues = taskAgentPoolMaintenanceJobStatusValuesType{ + InProgress: "inProgress", + Completed: "completed", + Cancelling: "cancelling", + Queued: "queued", +} + +type TaskAgentPoolMaintenanceJobTargetAgent struct { + Agent *TaskAgentReference `json:"agent,omitempty"` + JobId *int `json:"jobId,omitempty"` + Result *TaskAgentPoolMaintenanceJobResult `json:"result,omitempty"` + Status *TaskAgentPoolMaintenanceJobStatus `json:"status,omitempty"` +} + +type TaskAgentPoolMaintenanceOptions struct { + // time to consider a System.DefaultWorkingDirectory is stale + WorkingDirectoryExpirationInDays *int `json:"workingDirectoryExpirationInDays,omitempty"` +} + +type TaskAgentPoolMaintenanceRetentionPolicy struct { + // Number of records to keep for maintenance job executed with this definition. + NumberOfHistoryRecordsToKeep *int `json:"numberOfHistoryRecordsToKeep,omitempty"` +} + +type TaskAgentPoolMaintenanceSchedule struct { + // Days for a build (flags enum for days of the week) + DaysToBuild *TaskAgentPoolMaintenanceScheduleDays `json:"daysToBuild,omitempty"` + // The Job Id of the Scheduled job that will queue the pool maintenance job. + ScheduleJobId *uuid.UUID `json:"scheduleJobId,omitempty"` + // Local timezone hour to start + StartHours *int `json:"startHours,omitempty"` + // Local timezone minute to start + StartMinutes *int `json:"startMinutes,omitempty"` + // Time zone of the build schedule (string representation of the time zone id) + TimeZoneId *string `json:"timeZoneId,omitempty"` +} + +type TaskAgentPoolMaintenanceScheduleDays string + +type taskAgentPoolMaintenanceScheduleDaysValuesType struct { + None TaskAgentPoolMaintenanceScheduleDays + Monday TaskAgentPoolMaintenanceScheduleDays + Tuesday TaskAgentPoolMaintenanceScheduleDays + Wednesday TaskAgentPoolMaintenanceScheduleDays + Thursday TaskAgentPoolMaintenanceScheduleDays + Friday TaskAgentPoolMaintenanceScheduleDays + Saturday TaskAgentPoolMaintenanceScheduleDays + Sunday TaskAgentPoolMaintenanceScheduleDays + All TaskAgentPoolMaintenanceScheduleDays +} + +var TaskAgentPoolMaintenanceScheduleDaysValues = taskAgentPoolMaintenanceScheduleDaysValuesType{ + // Do not run. + None: "none", + // Run on Monday. + Monday: "monday", + // Run on Tuesday. + Tuesday: "tuesday", + // Run on Wednesday. + Wednesday: "wednesday", + // Run on Thursday. + Thursday: "thursday", + // Run on Friday. + Friday: "friday", + // Run on Saturday. + Saturday: "saturday", + // Run on Sunday. + Sunday: "sunday", + // Run on all days of the week. + All: "all", +} + +type TaskAgentPoolReference struct { + Id *int `json:"id,omitempty"` + // Gets or sets a value indicating whether or not this pool is managed by the service. + IsHosted *bool `json:"isHosted,omitempty"` + // Determines whether the pool is legacy. + IsLegacy *bool `json:"isLegacy,omitempty"` + Name *string `json:"name,omitempty"` + // Gets or sets the type of the pool + PoolType *TaskAgentPoolType `json:"poolType,omitempty"` + Scope *uuid.UUID `json:"scope,omitempty"` + // Gets the current size of the pool. + Size *int `json:"size,omitempty"` +} + +type TaskAgentPoolStatus struct { + Id *int `json:"id,omitempty"` + // Gets or sets a value indicating whether or not this pool is managed by the service. + IsHosted *bool `json:"isHosted,omitempty"` + // Determines whether the pool is legacy. + IsLegacy *bool `json:"isLegacy,omitempty"` + Name *string `json:"name,omitempty"` + // Gets or sets the type of the pool + PoolType *TaskAgentPoolType `json:"poolType,omitempty"` + Scope *uuid.UUID `json:"scope,omitempty"` + // Gets the current size of the pool. + Size *int `json:"size,omitempty"` + // Number of requests queued and assigned to an agent. Not running yet. + AssignedRequestCount *int `json:"assignedRequestCount,omitempty"` + // Number of queued requests which are not assigned to any agents + QueuedRequestCount *int `json:"queuedRequestCount,omitempty"` + // Number of currently running requests + RunningRequestCount *int `json:"runningRequestCount,omitempty"` +} + +type TaskAgentPoolSummary struct { + ColumnsHeader *MetricsColumnsHeader `json:"columnsHeader,omitempty"` + DeploymentGroups *[]DeploymentGroupReference `json:"deploymentGroups,omitempty"` + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + Queues *[]TaskAgentQueue `json:"queues,omitempty"` + Rows *[]MetricsRow `json:"rows,omitempty"` +} + +// The type of agent pool. +type TaskAgentPoolType string + +type taskAgentPoolTypeValuesType struct { + Automation TaskAgentPoolType + Deployment TaskAgentPoolType +} + +var TaskAgentPoolTypeValues = taskAgentPoolTypeValuesType{ + // A typical pool of task agents + Automation: "automation", + // A deployment pool + Deployment: "deployment", +} + +// Represents the public key portion of an RSA asymmetric key. +type TaskAgentPublicKey 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"` +} + +// An agent queue. +type TaskAgentQueue struct { + // ID of the queue + Id *int `json:"id,omitempty"` + // Name of the queue + Name *string `json:"name,omitempty"` + // Pool reference for this queue + Pool *TaskAgentPoolReference `json:"pool,omitempty"` + // Project ID + ProjectId *uuid.UUID `json:"projectId,omitempty"` +} + +// [Flags] Filters queues based on whether the calling user has permission to use or manage the queue. +type TaskAgentQueueActionFilter string + +type taskAgentQueueActionFilterValuesType struct { + None TaskAgentQueueActionFilter + Manage TaskAgentQueueActionFilter + Use TaskAgentQueueActionFilter +} + +var TaskAgentQueueActionFilterValues = taskAgentQueueActionFilterValuesType{ + None: "none", + Manage: "manage", + Use: "use", +} + +// A reference to an agent. +type TaskAgentReference struct { + Links interface{} `json:"_links,omitempty"` + // This agent's access point. + AccessPoint *string `json:"accessPoint,omitempty"` + // Whether or not this agent should run jobs. + Enabled *bool `json:"enabled,omitempty"` + // Identifier of the agent. + Id *int `json:"id,omitempty"` + // Name of the agent. + Name *string `json:"name,omitempty"` + // Agent OS. + OsDescription *string `json:"osDescription,omitempty"` + // Provisioning state of this agent. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Whether or not the agent is online. + Status *TaskAgentStatus `json:"status,omitempty"` + // Agent version. + Version *string `json:"version,omitempty"` +} + +// Represents a session for performing message exchanges from an agent. +type TaskAgentSession struct { + // Gets or sets the agent which is the target of the session. + Agent *TaskAgentReference `json:"agent,omitempty"` + // Gets the key used to encrypt message traffic for this session. + EncryptionKey *TaskAgentSessionKey `json:"encryptionKey,omitempty"` + // Gets or sets the owner name of this session. Generally this will be the machine of origination. + OwnerName *string `json:"ownerName,omitempty"` + // Gets the unique identifier for this session. + SessionId *uuid.UUID `json:"sessionId,omitempty"` + SystemCapabilities *map[string]string `json:"systemCapabilities,omitempty"` +} + +// Represents a symmetric key used for message-level encryption for communication sent to an agent. +type TaskAgentSessionKey struct { + // Gets or sets a value indicating whether or not the key value is encrypted. If this value is true, the Value property should be decrypted using the RSA key exchanged with the server during registration. + Encrypted *bool `json:"encrypted,omitempty"` + // Gets or sets the symmetric key value. + Value *[]byte `json:"value,omitempty"` +} + +type TaskAgentStatus string + +type taskAgentStatusValuesType struct { + Offline TaskAgentStatus + Online TaskAgentStatus +} + +var TaskAgentStatusValues = taskAgentStatusValuesType{ + Offline: "offline", + Online: "online", +} + +// [Flags] This is useful in getting a list of deployment targets, filtered by the deployment agent status. +type TaskAgentStatusFilter string + +type taskAgentStatusFilterValuesType struct { + Offline TaskAgentStatusFilter + Online TaskAgentStatusFilter + All TaskAgentStatusFilter +} + +var TaskAgentStatusFilterValues = taskAgentStatusFilterValuesType{ + // Only deployment targets that are offline. + Offline: "offline", + // Only deployment targets that are online. + Online: "online", + // All deployment targets. + All: "all", +} + +// Details about an agent update. +type TaskAgentUpdate struct { + // Current state of this agent update. + CurrentState *string `json:"currentState,omitempty"` + // Reason for this update. + Reason *TaskAgentUpdateReason `json:"reason,omitempty"` + // Identity which requested this update. + RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` + // Date on which this update was requested. + RequestTime *azuredevops.Time `json:"requestTime,omitempty"` + // Source agent version of the update. + SourceVersion *PackageVersion `json:"sourceVersion,omitempty"` + // Target agent version of the update. + TargetVersion *PackageVersion `json:"targetVersion,omitempty"` +} + +type TaskAgentUpdateReason struct { + Code *TaskAgentUpdateReasonType `json:"code,omitempty"` +} + +type TaskAgentUpdateReasonType string + +type taskAgentUpdateReasonTypeValuesType struct { + Manual TaskAgentUpdateReasonType + MinAgentVersionRequired TaskAgentUpdateReasonType +} + +var TaskAgentUpdateReasonTypeValues = taskAgentUpdateReasonTypeValuesType{ + Manual: "manual", + MinAgentVersionRequired: "minAgentVersionRequired", +} + +type TaskAssignedEvent struct { + JobId *uuid.UUID `json:"jobId,omitempty"` + Name *string `json:"name,omitempty"` + TaskId *uuid.UUID `json:"taskId,omitempty"` +} + +type TaskAttachment struct { + Links interface{} `json:"_links,omitempty"` + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + LastChangedBy *uuid.UUID `json:"lastChangedBy,omitempty"` + LastChangedOn *azuredevops.Time `json:"lastChangedOn,omitempty"` + Name *string `json:"name,omitempty"` + RecordId *uuid.UUID `json:"recordId,omitempty"` + TimelineId *uuid.UUID `json:"timelineId,omitempty"` + Type *string `json:"type,omitempty"` +} + +type TaskCompletedEvent struct { + JobId *uuid.UUID `json:"jobId,omitempty"` + Name *string `json:"name,omitempty"` + TaskId *uuid.UUID `json:"taskId,omitempty"` + Result *TaskResult `json:"result,omitempty"` +} + +type TaskDefinition struct { + AgentExecution *TaskExecution `json:"agentExecution,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + ContentsUploaded *bool `json:"contentsUploaded,omitempty"` + ContributionIdentifier *string `json:"contributionIdentifier,omitempty"` + ContributionVersion *string `json:"contributionVersion,omitempty"` + DataSourceBindings *[]DataSourceBinding `json:"dataSourceBindings,omitempty"` + DefinitionType *string `json:"definitionType,omitempty"` + Demands *[]interface{} `json:"demands,omitempty"` + Deprecated *bool `json:"deprecated,omitempty"` + Description *string `json:"description,omitempty"` + Disabled *bool `json:"disabled,omitempty"` + // Deprecated: Ecosystem property is not currently supported. + Ecosystem *string `json:"ecosystem,omitempty"` + Execution *map[string]interface{} `json:"execution,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Groups *[]TaskGroupDefinition `json:"groups,omitempty"` + HelpMarkDown *string `json:"helpMarkDown,omitempty"` + HelpUrl *string `json:"helpUrl,omitempty"` + HostType *string `json:"hostType,omitempty"` + IconUrl *string `json:"iconUrl,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Inputs *[]TaskInputDefinition `json:"inputs,omitempty"` + InstanceNameFormat *string `json:"instanceNameFormat,omitempty"` + MinimumAgentVersion *string `json:"minimumAgentVersion,omitempty"` + Name *string `json:"name,omitempty"` + OutputVariables *[]TaskOutputVariable `json:"outputVariables,omitempty"` + PackageLocation *string `json:"packageLocation,omitempty"` + PackageType *string `json:"packageType,omitempty"` + PostJobExecution *map[string]interface{} `json:"postJobExecution,omitempty"` + PreJobExecution *map[string]interface{} `json:"preJobExecution,omitempty"` + Preview *bool `json:"preview,omitempty"` + ReleaseNotes *string `json:"releaseNotes,omitempty"` + RunsOn *[]string `json:"runsOn,omitempty"` + Satisfies *[]string `json:"satisfies,omitempty"` + ServerOwned *bool `json:"serverOwned,omitempty"` + ShowEnvironmentVariables *bool `json:"showEnvironmentVariables,omitempty"` + SourceDefinitions *[]TaskSourceDefinition `json:"sourceDefinitions,omitempty"` + SourceLocation *string `json:"sourceLocation,omitempty"` + Version *TaskVersion `json:"version,omitempty"` + Visibility *[]string `json:"visibility,omitempty"` +} + +type TaskDefinitionEndpoint struct { + // An ID that identifies a service connection to be used for authenticating endpoint requests. + ConnectionId *string `json:"connectionId,omitempty"` + // An Json based keyselector to filter response returned by fetching the endpoint Url.A Json based keyselector must be prefixed with "jsonpath:". KeySelector can be used to specify the filter to get the keys for the values specified with Selector. The following keyselector defines an Json for extracting nodes named 'ServiceName'. endpoint.KeySelector = "jsonpath://ServiceName"; + KeySelector *string `json:"keySelector,omitempty"` + // The scope as understood by Connected Services. Essentially, a project-id for now. + Scope *string `json:"scope,omitempty"` + // An XPath/Json based selector to filter response returned by fetching the endpoint Url. An XPath based selector must be prefixed with the string "xpath:". A Json based selector must be prefixed with "jsonpath:". The following selector defines an XPath for extracting nodes named 'ServiceName'. endpoint.Selector = "xpath://ServiceName"; + Selector *string `json:"selector,omitempty"` + // TaskId that this endpoint belongs to. + TaskId *string `json:"taskId,omitempty"` + // URL to GET. + Url *string `json:"url,omitempty"` +} + +type TaskDefinitionReference struct { + // Gets or sets the definition type. Values can be 'task' or 'metaTask'. + DefinitionType *string `json:"definitionType,omitempty"` + // Gets or sets the unique identifier of task. + Id *uuid.UUID `json:"id,omitempty"` + // Gets or sets the version specification of task. + VersionSpec *string `json:"versionSpec,omitempty"` +} + +type TaskDefinitionStatus string + +type taskDefinitionStatusValuesType struct { + Preinstalled TaskDefinitionStatus + ReceivedInstallOrUpdate TaskDefinitionStatus + Installed TaskDefinitionStatus + ReceivedUninstall TaskDefinitionStatus + Uninstalled TaskDefinitionStatus + RequestedUpdate TaskDefinitionStatus + Updated TaskDefinitionStatus + AlreadyUpToDate TaskDefinitionStatus + InlineUpdateReceived TaskDefinitionStatus +} + +var TaskDefinitionStatusValues = taskDefinitionStatusValuesType{ + Preinstalled: "preinstalled", + ReceivedInstallOrUpdate: "receivedInstallOrUpdate", + Installed: "installed", + ReceivedUninstall: "receivedUninstall", + Uninstalled: "uninstalled", + RequestedUpdate: "requestedUpdate", + Updated: "updated", + AlreadyUpToDate: "alreadyUpToDate", + InlineUpdateReceived: "inlineUpdateReceived", +} + +type TaskEvent struct { + JobId *uuid.UUID `json:"jobId,omitempty"` + Name *string `json:"name,omitempty"` + TaskId *uuid.UUID `json:"taskId,omitempty"` +} + +type TaskExecution struct { + // The utility task to run. Specifying this means that this task definition is simply a meta task to call another task. This is useful for tasks that call utility tasks like powershell and commandline + ExecTask *TaskReference `json:"execTask,omitempty"` + // If a task is going to run code, then this provides the type/script etc... information by platform. For example, it might look like. net45: { typeName: "Microsoft.TeamFoundation.Automation.Tasks.PowerShellTask", assemblyName: "Microsoft.TeamFoundation.Automation.Tasks.PowerShell.dll" } net20: { typeName: "Microsoft.TeamFoundation.Automation.Tasks.PowerShellTask", assemblyName: "Microsoft.TeamFoundation.Automation.Tasks.PowerShell.dll" } java: { jar: "powershelltask.tasks.automation.teamfoundation.microsoft.com", } node: { script: "powershellhost.js", } + PlatformInstructions *map[string]map[string]string `json:"platformInstructions,omitempty"` +} + +type TaskGroup struct { + AgentExecution *TaskExecution `json:"agentExecution,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + ContentsUploaded *bool `json:"contentsUploaded,omitempty"` + ContributionIdentifier *string `json:"contributionIdentifier,omitempty"` + ContributionVersion *string `json:"contributionVersion,omitempty"` + DataSourceBindings *[]DataSourceBinding `json:"dataSourceBindings,omitempty"` + DefinitionType *string `json:"definitionType,omitempty"` + Demands *[]interface{} `json:"demands,omitempty"` + Deprecated *bool `json:"deprecated,omitempty"` + Description *string `json:"description,omitempty"` + Disabled *bool `json:"disabled,omitempty"` + Ecosystem *string `json:"ecosystem,omitempty"` + Execution *map[string]interface{} `json:"execution,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Groups *[]TaskGroupDefinition `json:"groups,omitempty"` + HelpMarkDown *string `json:"helpMarkDown,omitempty"` + HelpUrl *string `json:"helpUrl,omitempty"` + HostType *string `json:"hostType,omitempty"` + IconUrl *string `json:"iconUrl,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Inputs *[]TaskInputDefinition `json:"inputs,omitempty"` + InstanceNameFormat *string `json:"instanceNameFormat,omitempty"` + MinimumAgentVersion *string `json:"minimumAgentVersion,omitempty"` + Name *string `json:"name,omitempty"` + OutputVariables *[]TaskOutputVariable `json:"outputVariables,omitempty"` + PackageLocation *string `json:"packageLocation,omitempty"` + PackageType *string `json:"packageType,omitempty"` + PostJobExecution *map[string]interface{} `json:"postJobExecution,omitempty"` + PreJobExecution *map[string]interface{} `json:"preJobExecution,omitempty"` + Preview *bool `json:"preview,omitempty"` + ReleaseNotes *string `json:"releaseNotes,omitempty"` + RunsOn *[]string `json:"runsOn,omitempty"` + Satisfies *[]string `json:"satisfies,omitempty"` + ServerOwned *bool `json:"serverOwned,omitempty"` + ShowEnvironmentVariables *bool `json:"showEnvironmentVariables,omitempty"` + SourceDefinitions *[]TaskSourceDefinition `json:"sourceDefinitions,omitempty"` + SourceLocation *string `json:"sourceLocation,omitempty"` + Version *TaskVersion `json:"version,omitempty"` + Visibility *[]string `json:"visibility,omitempty"` + // Gets or sets comment. + Comment *string `json:"comment,omitempty"` + // Gets or sets the identity who created. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets or sets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets or sets as 'true' to indicate as deleted, 'false' otherwise. + Deleted *bool `json:"deleted,omitempty"` + // Gets or sets the identity who modified. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets or sets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets the owner. + Owner *string `json:"owner,omitempty"` + // Gets or sets parent task group Id. This is used while creating a draft task group. + ParentDefinitionId *uuid.UUID `json:"parentDefinitionId,omitempty"` + // Gets or sets revision. + Revision *int `json:"revision,omitempty"` + // Gets or sets the tasks. + Tasks *[]TaskGroupStep `json:"tasks,omitempty"` +} + +type TaskGroupCreateParameter struct { + // Sets author name of the task group. + Author *string `json:"author,omitempty"` + // Sets category of the task group. + Category *string `json:"category,omitempty"` + // Sets description of the task group. + Description *string `json:"description,omitempty"` + // Sets friendly name of the task group. + FriendlyName *string `json:"friendlyName,omitempty"` + // Sets url icon of the task group. + IconUrl *string `json:"iconUrl,omitempty"` + // Sets input for the task group. + Inputs *[]TaskInputDefinition `json:"inputs,omitempty"` + // Sets display name of the task group. + InstanceNameFormat *string `json:"instanceNameFormat,omitempty"` + // Sets name of the task group. + Name *string `json:"name,omitempty"` + // Sets parent task group Id. This is used while creating a draft task group. + ParentDefinitionId *uuid.UUID `json:"parentDefinitionId,omitempty"` + // Sets RunsOn of the task group. Value can be 'Agent', 'Server' or 'DeploymentGroup'. + RunsOn *[]string `json:"runsOn,omitempty"` + // Sets tasks for the task group. + Tasks *[]TaskGroupStep `json:"tasks,omitempty"` + // Sets version of the task group. + Version *TaskVersion `json:"version,omitempty"` +} + +type TaskGroupDefinition struct { + DisplayName *string `json:"displayName,omitempty"` + IsExpanded *bool `json:"isExpanded,omitempty"` + Name *string `json:"name,omitempty"` + Tags *[]string `json:"tags,omitempty"` + VisibleRule *string `json:"visibleRule,omitempty"` +} + +// [Flags] +type TaskGroupExpands string + +type taskGroupExpandsValuesType struct { + None TaskGroupExpands + Tasks TaskGroupExpands +} + +var TaskGroupExpandsValues = taskGroupExpandsValuesType{ + None: "none", + Tasks: "tasks", +} + +// Specifies the desired ordering of taskGroups. +type TaskGroupQueryOrder string + +type taskGroupQueryOrderValuesType struct { + CreatedOnAscending TaskGroupQueryOrder + CreatedOnDescending TaskGroupQueryOrder +} + +var TaskGroupQueryOrderValues = taskGroupQueryOrderValuesType{ + // Order by createdon ascending. + CreatedOnAscending: "createdOnAscending", + // Order by createdon descending. + CreatedOnDescending: "createdOnDescending", +} + +type TaskGroupRevision struct { + ChangedBy *webapi.IdentityRef `json:"changedBy,omitempty"` + ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` + ChangeType *AuditAction `json:"changeType,omitempty"` + Comment *string `json:"comment,omitempty"` + FileId *int `json:"fileId,omitempty"` + MajorVersion *int `json:"majorVersion,omitempty"` + Revision *int `json:"revision,omitempty"` + TaskGroupId *uuid.UUID `json:"taskGroupId,omitempty"` +} + +// Represents tasks in the task group. +type TaskGroupStep struct { + // Gets or sets as 'true' to run the task always, 'false' otherwise. + AlwaysRun *bool `json:"alwaysRun,omitempty"` + // Gets or sets condition for the task. + Condition *string `json:"condition,omitempty"` + // Gets or sets as 'true' to continue on error, 'false' otherwise. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // Gets or sets the display name. + DisplayName *string `json:"displayName,omitempty"` + // Gets or sets as task is enabled or not. + Enabled *bool `json:"enabled,omitempty"` + // Gets dictionary of environment variables. + Environment *map[string]string `json:"environment,omitempty"` + // Gets or sets dictionary of inputs. + Inputs *map[string]string `json:"inputs,omitempty"` + // Gets or sets the reference of the task. + Task *TaskDefinitionReference `json:"task,omitempty"` + // Gets or sets the maximum time, in minutes, that a task is allowed to execute on agent before being cancelled by server. A zero value indicates an infinite timeout. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` +} + +type TaskGroupUpdateParameter struct { + // Sets author name of the task group. + Author *string `json:"author,omitempty"` + // Sets category of the task group. + Category *string `json:"category,omitempty"` + // Sets comment of the task group. + Comment *string `json:"comment,omitempty"` + // Sets description of the task group. + Description *string `json:"description,omitempty"` + // Sets friendly name of the task group. + FriendlyName *string `json:"friendlyName,omitempty"` + // Sets url icon of the task group. + IconUrl *string `json:"iconUrl,omitempty"` + // Sets the unique identifier of this field. + Id *uuid.UUID `json:"id,omitempty"` + // Sets input for the task group. + Inputs *[]TaskInputDefinition `json:"inputs,omitempty"` + // Sets display name of the task group. + InstanceNameFormat *string `json:"instanceNameFormat,omitempty"` + // Sets name of the task group. + Name *string `json:"name,omitempty"` + // Gets or sets parent task group Id. This is used while creating a draft task group. + ParentDefinitionId *uuid.UUID `json:"parentDefinitionId,omitempty"` + // Sets revision of the task group. + Revision *int `json:"revision,omitempty"` + // Sets RunsOn of the task group. Value can be 'Agent', 'Server' or 'DeploymentGroup'. + RunsOn *[]string `json:"runsOn,omitempty"` + // Sets tasks for the task group. + Tasks *[]TaskGroupStep `json:"tasks,omitempty"` + // Sets version of the task group. + Version *TaskVersion `json:"version,omitempty"` +} + +type TaskHubLicenseDetails struct { + EnterpriseUsersCount *int `json:"enterpriseUsersCount,omitempty"` + FailedToReachAllProviders *bool `json:"failedToReachAllProviders,omitempty"` + FreeHostedLicenseCount *int `json:"freeHostedLicenseCount,omitempty"` + FreeLicenseCount *int `json:"freeLicenseCount,omitempty"` + HasLicenseCountEverUpdated *bool `json:"hasLicenseCountEverUpdated,omitempty"` + HostedAgentMinutesFreeCount *int `json:"hostedAgentMinutesFreeCount,omitempty"` + HostedAgentMinutesUsedCount *int `json:"hostedAgentMinutesUsedCount,omitempty"` + HostedLicensesArePremium *bool `json:"hostedLicensesArePremium,omitempty"` + MarketplacePurchasedHostedLicenses *[]MarketplacePurchasedLicense `json:"marketplacePurchasedHostedLicenses,omitempty"` + MsdnUsersCount *int `json:"msdnUsersCount,omitempty"` + // Microsoft-hosted licenses purchased from VSTS directly. + PurchasedHostedLicenseCount *int `json:"purchasedHostedLicenseCount,omitempty"` + // Self-hosted licenses purchased from VSTS directly. + PurchasedLicenseCount *int `json:"purchasedLicenseCount,omitempty"` + TotalHostedLicenseCount *int `json:"totalHostedLicenseCount,omitempty"` + TotalLicenseCount *int `json:"totalLicenseCount,omitempty"` + TotalPrivateLicenseCount *int `json:"totalPrivateLicenseCount,omitempty"` +} + +type TaskInputDefinition struct { + Aliases *[]string `json:"aliases,omitempty"` + DefaultValue *string `json:"defaultValue,omitempty"` + GroupName *string `json:"groupName,omitempty"` + HelpMarkDown *string `json:"helpMarkDown,omitempty"` + Label *string `json:"label,omitempty"` + Name *string `json:"name,omitempty"` + Options *map[string]string `json:"options,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Required *bool `json:"required,omitempty"` + Type *string `json:"type,omitempty"` + Validation *distributedtaskcommon.TaskInputValidation `json:"validation,omitempty"` + VisibleRule *string `json:"visibleRule,omitempty"` +} + +type TaskInstance struct { + Id *uuid.UUID `json:"id,omitempty"` + Inputs *map[string]string `json:"inputs,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` + AlwaysRun *bool `json:"alwaysRun,omitempty"` + Condition *string `json:"condition,omitempty"` + ContinueOnError *bool `json:"continueOnError,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Environment *map[string]string `json:"environment,omitempty"` + InstanceId *uuid.UUID `json:"instanceId,omitempty"` + RefName *string `json:"refName,omitempty"` + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` +} + +type TaskLog struct { + Id *int `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + IndexLocation *string `json:"indexLocation,omitempty"` + LastChangedOn *azuredevops.Time `json:"lastChangedOn,omitempty"` + LineCount *uint64 `json:"lineCount,omitempty"` + Path *string `json:"path,omitempty"` +} + +type TaskLogReference struct { + Id *int `json:"id,omitempty"` + Location *string `json:"location,omitempty"` +} + +type TaskOrchestrationContainer struct { + ItemType *TaskOrchestrationItemType `json:"itemType,omitempty"` + Children *[]TaskOrchestrationItem `json:"children,omitempty"` + ContinueOnError *bool `json:"continueOnError,omitempty"` + Data *map[string]string `json:"data,omitempty"` + MaxConcurrency *int `json:"maxConcurrency,omitempty"` + Parallel *bool `json:"parallel,omitempty"` + Rollback *TaskOrchestrationContainer `json:"rollback,omitempty"` +} + +type TaskOrchestrationItem struct { + ItemType *TaskOrchestrationItemType `json:"itemType,omitempty"` +} + +type TaskOrchestrationItemType string + +type taskOrchestrationItemTypeValuesType struct { + Container TaskOrchestrationItemType + Job TaskOrchestrationItemType +} + +var TaskOrchestrationItemTypeValues = taskOrchestrationItemTypeValuesType{ + Container: "container", + Job: "job", +} + +type TaskOrchestrationJob struct { + ItemType *TaskOrchestrationItemType `json:"itemType,omitempty"` + Demands *[]interface{} `json:"demands,omitempty"` + ExecuteAs *webapi.IdentityRef `json:"executeAs,omitempty"` + ExecutionMode *string `json:"executionMode,omitempty"` + ExecutionTimeout interface{} `json:"executionTimeout,omitempty"` + InstanceId *uuid.UUID `json:"instanceId,omitempty"` + Name *string `json:"name,omitempty"` + RefName *string `json:"refName,omitempty"` + Tasks *[]TaskInstance `json:"tasks,omitempty"` + Variables *map[string]string `json:"variables,omitempty"` +} + +type TaskOrchestrationOwner struct { + Links interface{} `json:"_links,omitempty"` + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type TaskOrchestrationPlan struct { + ArtifactLocation *string `json:"artifactLocation,omitempty"` + ArtifactUri *string `json:"artifactUri,omitempty"` + Definition *TaskOrchestrationOwner `json:"definition,omitempty"` + Owner *TaskOrchestrationOwner `json:"owner,omitempty"` + PlanGroup *string `json:"planGroup,omitempty"` + PlanId *uuid.UUID `json:"planId,omitempty"` + PlanType *string `json:"planType,omitempty"` + ScopeIdentifier *uuid.UUID `json:"scopeIdentifier,omitempty"` + Version *int `json:"version,omitempty"` + Environment *PlanEnvironment `json:"environment,omitempty"` + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + Implementation *TaskOrchestrationContainer `json:"implementation,omitempty"` + InitializationLog *TaskLogReference `json:"initializationLog,omitempty"` + RequestedById *uuid.UUID `json:"requestedById,omitempty"` + RequestedForId *uuid.UUID `json:"requestedForId,omitempty"` + Result *TaskResult `json:"result,omitempty"` + ResultCode *string `json:"resultCode,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + State *TaskOrchestrationPlanState `json:"state,omitempty"` + Timeline *TimelineReference `json:"timeline,omitempty"` +} + +type TaskOrchestrationPlanGroup struct { + PlanGroup *string `json:"planGroup,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + RunningRequests *[]TaskAgentJobRequest `json:"runningRequests,omitempty"` +} + +type TaskOrchestrationPlanGroupsQueueMetrics struct { + Count *int `json:"count,omitempty"` + Status *PlanGroupStatus `json:"status,omitempty"` +} + +type TaskOrchestrationPlanReference struct { + ArtifactLocation *string `json:"artifactLocation,omitempty"` + ArtifactUri *string `json:"artifactUri,omitempty"` + Definition *TaskOrchestrationOwner `json:"definition,omitempty"` + Owner *TaskOrchestrationOwner `json:"owner,omitempty"` + PlanGroup *string `json:"planGroup,omitempty"` + PlanId *uuid.UUID `json:"planId,omitempty"` + PlanType *string `json:"planType,omitempty"` + ScopeIdentifier *uuid.UUID `json:"scopeIdentifier,omitempty"` + Version *int `json:"version,omitempty"` +} + +type TaskOrchestrationPlanState string + +type taskOrchestrationPlanStateValuesType struct { + InProgress TaskOrchestrationPlanState + Queued TaskOrchestrationPlanState + Completed TaskOrchestrationPlanState + Throttled TaskOrchestrationPlanState +} + +var TaskOrchestrationPlanStateValues = taskOrchestrationPlanStateValuesType{ + InProgress: "inProgress", + Queued: "queued", + Completed: "completed", + Throttled: "throttled", +} + +type TaskOrchestrationQueuedPlan struct { + AssignTime *azuredevops.Time `json:"assignTime,omitempty"` + Definition *TaskOrchestrationOwner `json:"definition,omitempty"` + Owner *TaskOrchestrationOwner `json:"owner,omitempty"` + PlanGroup *string `json:"planGroup,omitempty"` + PlanId *uuid.UUID `json:"planId,omitempty"` + PoolId *int `json:"poolId,omitempty"` + QueuePosition *int `json:"queuePosition,omitempty"` + QueueTime *azuredevops.Time `json:"queueTime,omitempty"` + ScopeIdentifier *uuid.UUID `json:"scopeIdentifier,omitempty"` +} + +type TaskOrchestrationQueuedPlanGroup struct { + Definition *TaskOrchestrationOwner `json:"definition,omitempty"` + Owner *TaskOrchestrationOwner `json:"owner,omitempty"` + PlanGroup *string `json:"planGroup,omitempty"` + Plans *[]TaskOrchestrationQueuedPlan `json:"plans,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + QueuePosition *int `json:"queuePosition,omitempty"` +} + +type TaskOutputVariable struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` +} + +type TaskPackageMetadata struct { + // Gets the name of the package. + Type *string `json:"type,omitempty"` + // Gets the url of the package. + Url *string `json:"url,omitempty"` + // Gets the version of the package. + Version *string `json:"version,omitempty"` +} + +type TaskReference struct { + Id *uuid.UUID `json:"id,omitempty"` + Inputs *map[string]string `json:"inputs,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +type TaskResult string + +type taskResultValuesType struct { + Succeeded TaskResult + SucceededWithIssues TaskResult + Failed TaskResult + Canceled TaskResult + Skipped TaskResult + Abandoned TaskResult +} + +var TaskResultValues = taskResultValuesType{ + Succeeded: "succeeded", + SucceededWithIssues: "succeededWithIssues", + Failed: "failed", + Canceled: "canceled", + Skipped: "skipped", + Abandoned: "abandoned", +} + +type TaskSourceDefinition struct { + AuthKey *string `json:"authKey,omitempty"` + Endpoint *string `json:"endpoint,omitempty"` + KeySelector *string `json:"keySelector,omitempty"` + Selector *string `json:"selector,omitempty"` + Target *string `json:"target,omitempty"` +} + +type TaskStartedEvent struct { + JobId *uuid.UUID `json:"jobId,omitempty"` + Name *string `json:"name,omitempty"` + TaskId *uuid.UUID `json:"taskId,omitempty"` +} + +type TaskVersion struct { + IsTest *bool `json:"isTest,omitempty"` + Major *int `json:"major,omitempty"` + Minor *int `json:"minor,omitempty"` + Patch *int `json:"patch,omitempty"` +} + +type Timeline struct { + ChangeId *int `json:"changeId,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + LastChangedBy *uuid.UUID `json:"lastChangedBy,omitempty"` + LastChangedOn *azuredevops.Time `json:"lastChangedOn,omitempty"` + Records *[]TimelineRecord `json:"records,omitempty"` +} + +type TimelineAttempt struct { + // Gets or sets the attempt of the record. + Attempt *int `json:"attempt,omitempty"` + // Gets or sets the unique identifier for the record. + Identifier *string `json:"identifier,omitempty"` + // Gets or sets the record identifier located within the specified timeline. + RecordId *uuid.UUID `json:"recordId,omitempty"` + // Gets or sets the timeline identifier which owns the record representing this attempt. + TimelineId *uuid.UUID `json:"timelineId,omitempty"` +} + +type TimelineRecord struct { + Attempt *int `json:"attempt,omitempty"` + ChangeId *int `json:"changeId,omitempty"` + CurrentOperation *string `json:"currentOperation,omitempty"` + Details *TimelineReference `json:"details,omitempty"` + ErrorCount *int `json:"errorCount,omitempty"` + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Identifier *string `json:"identifier,omitempty"` + Issues *[]Issue `json:"issues,omitempty"` + LastModified *azuredevops.Time `json:"lastModified,omitempty"` + Location *string `json:"location,omitempty"` + Log *TaskLogReference `json:"log,omitempty"` + Name *string `json:"name,omitempty"` + Order *int `json:"order,omitempty"` + ParentId *uuid.UUID `json:"parentId,omitempty"` + PercentComplete *int `json:"percentComplete,omitempty"` + PreviousAttempts *[]TimelineAttempt `json:"previousAttempts,omitempty"` + RefName *string `json:"refName,omitempty"` + Result *TaskResult `json:"result,omitempty"` + ResultCode *string `json:"resultCode,omitempty"` + StartTime *azuredevops.Time `json:"startTime,omitempty"` + State *TimelineRecordState `json:"state,omitempty"` + Task *TaskReference `json:"task,omitempty"` + Type *string `json:"type,omitempty"` + Variables *map[string]VariableValue `json:"variables,omitempty"` + WarningCount *int `json:"warningCount,omitempty"` + WorkerName *string `json:"workerName,omitempty"` +} + +type TimelineRecordFeedLinesWrapper struct { + Count *int `json:"count,omitempty"` + StepId *uuid.UUID `json:"stepId,omitempty"` + Value *[]string `json:"value,omitempty"` +} + +type TimelineRecordState string + +type timelineRecordStateValuesType struct { + Pending TimelineRecordState + InProgress TimelineRecordState + Completed TimelineRecordState +} + +var TimelineRecordStateValues = timelineRecordStateValuesType{ + Pending: "pending", + InProgress: "inProgress", + Completed: "completed", +} + +type TimelineReference struct { + ChangeId *int `json:"changeId,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Location *string `json:"location,omitempty"` +} + +type ValidationItem struct { + // Tells whether the current input is valid or not + IsValid *bool `json:"isValid,omitempty"` + // Reason for input validation failure + Reason *string `json:"reason,omitempty"` + // Type of validation item + Type *string `json:"type,omitempty"` + // Value to validate. The conditional expression to validate for the input for "expression" type Eg:eq(variables['Build.SourceBranch'], 'refs/heads/master');eq(value, 'refs/heads/master') + Value *string `json:"value,omitempty"` +} + +// A variable group is a collection of related variables. +type VariableGroup struct { + // Gets or sets the identity who created the variable group. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets or sets the time when variable group was created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets or sets description of the variable group. + Description *string `json:"description,omitempty"` + // Gets or sets id of the variable group. + Id *int `json:"id,omitempty"` + // Indicates whether variable group is shared with other projects or not. + IsShared *bool `json:"isShared,omitempty"` + // Gets or sets the identity who modified the variable group. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets or sets the time when variable group was modified + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets name of the variable group. + Name *string `json:"name,omitempty"` + // Gets or sets provider data. + ProviderData *VariableGroupProviderData `json:"providerData,omitempty"` + // Gets or sets type of the variable group. + Type *string `json:"type,omitempty"` + // Gets or sets variables contained in the variable group. + Variables *map[string]VariableValue `json:"variables,omitempty"` +} + +// [Flags] +type VariableGroupActionFilter string + +type variableGroupActionFilterValuesType struct { + None VariableGroupActionFilter + Manage VariableGroupActionFilter + Use VariableGroupActionFilter +} + +var VariableGroupActionFilterValues = variableGroupActionFilterValuesType{ + None: "none", + Manage: "manage", + Use: "use", +} + +type VariableGroupParameters struct { + // Sets description of the variable group. + Description *string `json:"description,omitempty"` + // Sets name of the variable group. + Name *string `json:"name,omitempty"` + // Sets provider data. + ProviderData *VariableGroupProviderData `json:"providerData,omitempty"` + // Sets type of the variable group. + Type *string `json:"type,omitempty"` + // Sets variables contained in the variable group. + Variables *map[string]VariableValue `json:"variables,omitempty"` +} + +// Defines provider data of the variable group. +type VariableGroupProviderData struct { +} + +// Specifies the desired ordering of variableGroups. +type VariableGroupQueryOrder string + +type variableGroupQueryOrderValuesType struct { + IdAscending VariableGroupQueryOrder + IdDescending VariableGroupQueryOrder +} + +var VariableGroupQueryOrderValues = variableGroupQueryOrderValuesType{ + // Order by id ascending. + IdAscending: "idAscending", + // Order by id descending. + IdDescending: "idDescending", +} + +type VariableValue struct { + IsSecret *bool `json:"isSecret,omitempty"` + Value *string `json:"value,omitempty"` +} + +type VirtualMachine struct { + Agent *TaskAgent `json:"agent,omitempty"` + Id *int `json:"id,omitempty"` + Tags *[]string `json:"tags,omitempty"` +} + +type VirtualMachineGroup struct { + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + EnvironmentReference *EnvironmentReference `json:"environmentReference,omitempty"` + Id *int `json:"id,omitempty"` + LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + Name *string `json:"name,omitempty"` + // Environment resource type + Type *EnvironmentResourceType `json:"type,omitempty"` + PoolId *int `json:"poolId,omitempty"` +} + +type VirtualMachineGroupCreateParameters struct { + Name *string `json:"name,omitempty"` +} diff --git a/azuredevops/test/client.go b/azuredevops/test/client.go new file mode 100644 index 00000000..908f6be9 --- /dev/null +++ b/azuredevops/test/client.go @@ -0,0 +1,2159 @@ +// -------------------------------------------------------------------------------------------- +// 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 test + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "io" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("c2aa639c-3ccc-4740-b3b6-ce2a1e1d984e") + +type Client interface { + // Add test cases to suite. + AddTestCasesToSuite(context.Context, AddTestCasesToSuiteArgs) (*[]SuiteTestCase, error) + // Add test results to a test run. + AddTestResultsToTestRun(context.Context, AddTestResultsToTestRunArgs) (*[]TestCaseResult, error) + // [Preview API] Attach a file to a test result. + CreateTestResultAttachment(context.Context, CreateTestResultAttachmentArgs) (*TestAttachmentReference, error) + // Create new test run. + CreateTestRun(context.Context, CreateTestRunArgs) (*TestRun, error) + // [Preview API] Attach a file to a test run. + CreateTestRunAttachment(context.Context, CreateTestRunAttachmentArgs) (*TestAttachmentReference, error) + // [Preview API] Create a test session + CreateTestSession(context.Context, CreateTestSessionArgs) (*TestSession, error) + // [Preview API] Attach a file to a test result + CreateTestSubResultAttachment(context.Context, CreateTestSubResultAttachmentArgs) (*TestAttachmentReference, error) + // [Preview API] Delete a test case. + DeleteTestCase(context.Context, DeleteTestCaseArgs) error + // Delete a test run by its ID. + DeleteTestRun(context.Context, DeleteTestRunArgs) error + // Gets the action results for an iteration in a test result. + GetActionResults(context.Context, GetActionResultsArgs) (*[]TestActionResultModel, error) + // [Preview API] Get code coverage data for a build. + GetBuildCodeCoverage(context.Context, GetBuildCodeCoverageArgs) (*[]BuildCoverage, error) + // Get a test point. + GetPoint(context.Context, GetPointArgs) (*TestPoint, error) + // Get a list of test points. + GetPoints(context.Context, GetPointsArgs) (*[]TestPoint, error) + // [Preview API] Get test points using query. + GetPointsByQuery(context.Context, GetPointsByQueryArgs) (*TestPointsQuery, error) + // Get a list of parameterized results + GetResultParameters(context.Context, GetResultParametersArgs) (*[]TestResultParameterModel, error) + // [Preview API] Get test result retention settings + GetResultRetentionSettings(context.Context, GetResultRetentionSettingsArgs) (*ResultRetentionSettings, error) + // Get a specific test case in a test suite with test case id. + GetTestCaseById(context.Context, GetTestCaseByIdArgs) (*SuiteTestCase, error) + // Get all test cases in a suite. + GetTestCases(context.Context, GetTestCasesArgs) (*[]SuiteTestCase, error) + // Get iteration for a result + GetTestIteration(context.Context, GetTestIterationArgs) (*TestIterationDetailsModel, error) + // Get iterations for a result + GetTestIterations(context.Context, GetTestIterationsArgs) (*[]TestIterationDetailsModel, error) + // [Preview API] Download a test result attachment by its ID. + GetTestResultAttachmentContent(context.Context, GetTestResultAttachmentContentArgs) (io.ReadCloser, error) + // [Preview API] Get list of test result attachments reference. + GetTestResultAttachments(context.Context, GetTestResultAttachmentsArgs) (*[]TestAttachment, error) + // [Preview API] Download a test result attachment by its ID. + GetTestResultAttachmentZip(context.Context, GetTestResultAttachmentZipArgs) (io.ReadCloser, error) + // Get a test result for a test run. + GetTestResultById(context.Context, GetTestResultByIdArgs) (*TestCaseResult, error) + // Get test results for a test run. + GetTestResults(context.Context, GetTestResultsArgs) (*[]TestCaseResult, error) + // [Preview API] Download a test run attachment by its ID. + GetTestRunAttachmentContent(context.Context, GetTestRunAttachmentContentArgs) (io.ReadCloser, error) + // [Preview API] Get list of test run attachments reference. + GetTestRunAttachments(context.Context, GetTestRunAttachmentsArgs) (*[]TestAttachment, error) + // [Preview API] Download a test run attachment by its ID. + GetTestRunAttachmentZip(context.Context, GetTestRunAttachmentZipArgs) (io.ReadCloser, error) + // Get a test run by its ID. + GetTestRunById(context.Context, GetTestRunByIdArgs) (*TestRun, error) + // [Preview API] Get code coverage data for a test run + GetTestRunCodeCoverage(context.Context, GetTestRunCodeCoverageArgs) (*[]TestRunCoverage, error) + // Get a list of test runs. + GetTestRuns(context.Context, GetTestRunsArgs) (*[]TestRun, error) + // Get test run statistics , used when we want to get summary of a run by outcome. + GetTestRunStatistics(context.Context, GetTestRunStatisticsArgs) (*TestRunStatistic, error) + // [Preview API] Get a list of test sessions + GetTestSessions(context.Context, GetTestSessionsArgs) (*[]TestSession, error) + // [Preview API] Download a test sub result attachment + GetTestSubResultAttachmentContent(context.Context, GetTestSubResultAttachmentContentArgs) (io.ReadCloser, error) + // [Preview API] Get list of test sub result attachments + GetTestSubResultAttachments(context.Context, GetTestSubResultAttachmentsArgs) (*[]TestAttachment, error) + // [Preview API] Download a test sub result attachment + GetTestSubResultAttachmentZip(context.Context, GetTestSubResultAttachmentZipArgs) (io.ReadCloser, error) + // [Preview API] Get history of a test method using TestHistoryQuery + QueryTestHistory(context.Context, QueryTestHistoryArgs) (*TestHistoryQuery, error) + // Query Test Runs based on filters. Mandatory fields are minLastUpdatedDate and maxLastUpdatedDate. + QueryTestRuns(context.Context, QueryTestRunsArgs) (*QueryTestRunsResponseValue, error) + // The test points associated with the test cases are removed from the test suite. The test case work item is not deleted from the system. See test cases resource to delete a test case permanently. + RemoveTestCasesFromSuiteUrl(context.Context, RemoveTestCasesFromSuiteUrlArgs) error + // [Preview API] Update test result retention settings + UpdateResultRetentionSettings(context.Context, UpdateResultRetentionSettingsArgs) (*ResultRetentionSettings, error) + // Updates the properties of the test case association in a suite. + UpdateSuiteTestCases(context.Context, UpdateSuiteTestCasesArgs) (*[]SuiteTestCase, error) + // Update test points. + UpdateTestPoints(context.Context, UpdateTestPointsArgs) (*[]TestPoint, error) + // Update test results in a test run. + UpdateTestResults(context.Context, UpdateTestResultsArgs) (*[]TestCaseResult, error) + // Update test run by its ID. + UpdateTestRun(context.Context, UpdateTestRunArgs) (*TestRun, error) + // [Preview API] Update a test session + UpdateTestSession(context.Context, UpdateTestSessionArgs) (*TestSession, 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 +} + +// Add test cases to suite. +func (client *ClientImpl) AddTestCasesToSuite(ctx context.Context, args AddTestCasesToSuiteArgs) (*[]SuiteTestCase, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + if args.TestCaseIds == nil || *args.TestCaseIds == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestCaseIds"} + } + routeValues["testCaseIds"] = *args.TestCaseIds + routeValues["action"] = "TestCases" + + locationId, _ := uuid.Parse("a4a1ec1c-b03f-41ca-8857-704594ecf58e") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []SuiteTestCase + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddTestCasesToSuite function +type AddTestCasesToSuiteArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan that contains the suite. + PlanId *int + // (required) ID of the test suite to which the test cases must be added. + SuiteId *int + // (required) IDs of the test cases to add to the suite. Ids are specified in comma separated format. + TestCaseIds *string +} + +// Add test results to a test run. +func (client *ClientImpl) AddTestResultsToTestRun(ctx context.Context, args AddTestResultsToTestRunArgs) (*[]TestCaseResult, error) { + if args.Results == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Results"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + body, marshalErr := json.Marshal(*args.Results) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4637d869-3a76-4468-8057-0bb02aa385cf") + 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 []TestCaseResult + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddTestResultsToTestRun function +type AddTestResultsToTestRunArgs struct { + // (required) List of test results to add. + Results *[]TestCaseResult + // (required) Project ID or project name + Project *string + // (required) Test run ID into which test results to add. + RunId *int +} + +// [Preview API] Attach a file to a test result. +func (client *ClientImpl) CreateTestResultAttachment(ctx context.Context, args CreateTestResultAttachmentArgs) (*TestAttachmentReference, error) { + if args.AttachmentRequestModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentRequestModel"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + body, marshalErr := json.Marshal(*args.AttachmentRequestModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2bffebe9-2f0f-4639-9af8-56129e9fed2d") + 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 TestAttachmentReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestResultAttachment function +type CreateTestResultAttachmentArgs struct { + // (required) Attachment details TestAttachmentRequestModel + AttachmentRequestModel *TestAttachmentRequestModel + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the result. + RunId *int + // (required) ID of the test result against which attachment has to be uploaded. + TestCaseResultId *int +} + +// Create new test run. +func (client *ClientImpl) CreateTestRun(ctx context.Context, args CreateTestRunArgs) (*TestRun, error) { + if args.TestRun == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestRun"} + } + 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.TestRun) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("cadb3810-d47d-4a3c-a234-fe5f3be50138") + 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 TestRun + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestRun function +type CreateTestRunArgs struct { + // (required) Run details RunCreateModel + TestRun *RunCreateModel + // (required) Project ID or project name + Project *string +} + +// [Preview API] Attach a file to a test run. +func (client *ClientImpl) CreateTestRunAttachment(ctx context.Context, args CreateTestRunAttachmentArgs) (*TestAttachmentReference, error) { + if args.AttachmentRequestModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentRequestModel"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + body, marshalErr := json.Marshal(*args.AttachmentRequestModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4f004af4-a507-489c-9b13-cb62060beb11") + 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 TestAttachmentReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestRunAttachment function +type CreateTestRunAttachmentArgs struct { + // (required) Attachment details TestAttachmentRequestModel + AttachmentRequestModel *TestAttachmentRequestModel + // (required) Project ID or project name + Project *string + // (required) ID of the test run against which attachment has to be uploaded. + RunId *int +} + +// [Preview API] Create a test session +func (client *ClientImpl) CreateTestSession(ctx context.Context, args CreateTestSessionArgs) (*TestSession, error) { + if args.TestSession == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestSession"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + body, marshalErr := json.Marshal(*args.TestSession) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1500b4b4-6c69-4ca6-9b18-35e9e97fe2ac") + 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 TestSession + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestSession function +type CreateTestSessionArgs struct { + // (required) Test session details for creation + TestSession *TestSession + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Attach a file to a test result +func (client *ClientImpl) CreateTestSubResultAttachment(ctx context.Context, args CreateTestSubResultAttachmentArgs) (*TestAttachmentReference, error) { + if args.AttachmentRequestModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentRequestModel"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + queryParams := url.Values{} + if args.TestSubResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testSubResultId"} + } + queryParams.Add("testSubResultId", strconv.Itoa(*args.TestSubResultId)) + body, marshalErr := json.Marshal(*args.AttachmentRequestModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2bffebe9-2f0f-4639-9af8-56129e9fed2d") + 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 TestAttachmentReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestSubResultAttachment function +type CreateTestSubResultAttachmentArgs struct { + // (required) Attachment Request Model. + AttachmentRequestModel *TestAttachmentRequestModel + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the result. + RunId *int + // (required) ID of the test results that contains sub result. + TestCaseResultId *int + // (required) ID of the test sub results against which attachment has to be uploaded. + TestSubResultId *int +} + +// [Preview API] Delete a test case. +func (client *ClientImpl) DeleteTestCase(ctx context.Context, args DeleteTestCaseArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.TestCaseId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseId"} + } + routeValues["testCaseId"] = strconv.Itoa(*args.TestCaseId) + + locationId, _ := uuid.Parse("4d472e0f-e32c-4ef8-adf4-a4078772889c") + _, 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 DeleteTestCase function +type DeleteTestCaseArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of test case to delete. + TestCaseId *int +} + +// Delete a test run by its ID. +func (client *ClientImpl) DeleteTestRun(ctx context.Context, args DeleteTestRunArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + locationId, _ := uuid.Parse("cadb3810-d47d-4a3c-a234-fe5f3be50138") + _, 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 DeleteTestRun function +type DeleteTestRunArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the run to delete. + RunId *int +} + +// Gets the action results for an iteration in a test result. +func (client *ClientImpl) GetActionResults(ctx context.Context, args GetActionResultsArgs) (*[]TestActionResultModel, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = strconv.Itoa(*args.IterationId) + if args.ActionPath != nil && *args.ActionPath != "" { + routeValues["actionPath"] = *args.ActionPath + } + + locationId, _ := uuid.Parse("eaf40c31-ff84-4062-aafd-d5664be11a37") + 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 []TestActionResultModel + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetActionResults function +type GetActionResultsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the result. + RunId *int + // (required) ID of the test result that contains the iterations. + TestCaseResultId *int + // (required) ID of the iteration that contains the actions. + IterationId *int + // (optional) Path of a specific action, used to get just that action. + ActionPath *string +} + +// [Preview API] Get code coverage data for a build. +func (client *ClientImpl) GetBuildCodeCoverage(ctx context.Context, args GetBuildCodeCoverageArgs) (*[]BuildCoverage, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "buildId"} + } + queryParams.Add("buildId", strconv.Itoa(*args.BuildId)) + if args.Flags == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "flags"} + } + queryParams.Add("flags", strconv.Itoa(*args.Flags)) + locationId, _ := uuid.Parse("77560e8a-4e8c-4d59-894e-a5f264c24444") + 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 []BuildCoverage + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildCodeCoverage function +type GetBuildCodeCoverageArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the build for which code coverage data needs to be fetched. + BuildId *int + // (required) Value of flags determine the level of code coverage details to be fetched. Flags are additive. Expected Values are 1 for Modules, 2 for Functions, 4 for BlockData. + Flags *int +} + +// Get a test point. +func (client *ClientImpl) GetPoint(ctx context.Context, args GetPointArgs) (*TestPoint, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + if args.PointIds == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PointIds"} + } + routeValues["pointIds"] = strconv.Itoa(*args.PointIds) + + queryParams := url.Values{} + if args.WitFields != nil { + queryParams.Add("witFields", *args.WitFields) + } + locationId, _ := uuid.Parse("3bcfd5c8-be62-488e-b1da-b8289ce9299c") + 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 TestPoint + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPoint function +type GetPointArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan. + PlanId *int + // (required) ID of the suite that contains the point. + SuiteId *int + // (required) ID of the test point to get. + PointIds *int + // (optional) Comma-separated list of work item field names. + WitFields *string +} + +// Get a list of test points. +func (client *ClientImpl) GetPoints(ctx context.Context, args GetPointsArgs) (*[]TestPoint, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + + queryParams := url.Values{} + if args.WitFields != nil { + queryParams.Add("witFields", *args.WitFields) + } + if args.ConfigurationId != nil { + queryParams.Add("configurationId", *args.ConfigurationId) + } + if args.TestCaseId != nil { + queryParams.Add("testCaseId", *args.TestCaseId) + } + if args.TestPointIds != nil { + queryParams.Add("testPointIds", *args.TestPointIds) + } + if args.IncludePointDetails != nil { + queryParams.Add("includePointDetails", strconv.FormatBool(*args.IncludePointDetails)) + } + 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("3bcfd5c8-be62-488e-b1da-b8289ce9299c") + 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 []TestPoint + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPoints function +type GetPointsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan. + PlanId *int + // (required) ID of the suite that contains the points. + SuiteId *int + // (optional) Comma-separated list of work item field names. + WitFields *string + // (optional) Get test points for specific configuration. + ConfigurationId *string + // (optional) Get test points for a specific test case, valid when configurationId is not set. + TestCaseId *string + // (optional) Get test points for comma-separated list of test point IDs, valid only when configurationId and testCaseId are not set. + TestPointIds *string + // (optional) Include all properties for the test point. + IncludePointDetails *bool + // (optional) Number of test points to skip.. + Skip *int + // (optional) Number of test points to return. + Top *int +} + +// [Preview API] Get test points using query. +func (client *ClientImpl) GetPointsByQuery(ctx context.Context, args GetPointsByQueryArgs) (*TestPointsQuery, error) { + if args.Query == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"} + } + 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.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + body, marshalErr := json.Marshal(*args.Query) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b4264fd0-a5d1-43e2-82a5-b9c46b7da9ce") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue TestPointsQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPointsByQuery function +type GetPointsByQueryArgs struct { + // (required) TestPointsQuery to get test points. + Query *TestPointsQuery + // (required) Project ID or project name + Project *string + // (optional) Number of test points to skip.. + Skip *int + // (optional) Number of test points to return. + Top *int +} + +// Get a list of parameterized results +func (client *ClientImpl) GetResultParameters(ctx context.Context, args GetResultParametersArgs) (*[]TestResultParameterModel, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = strconv.Itoa(*args.IterationId) + + queryParams := url.Values{} + if args.ParamName != nil { + queryParams.Add("paramName", *args.ParamName) + } + locationId, _ := uuid.Parse("7c69810d-3354-4af3-844a-180bd25db08a") + 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 []TestResultParameterModel + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetResultParameters function +type GetResultParametersArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the result. + RunId *int + // (required) ID of the test result that contains the iterations. + TestCaseResultId *int + // (required) ID of the iteration that contains the parameterized results. + IterationId *int + // (optional) Name of the parameter. + ParamName *string +} + +// [Preview API] Get test result retention settings +func (client *ClientImpl) GetResultRetentionSettings(ctx context.Context, args GetResultRetentionSettingsArgs) (*ResultRetentionSettings, 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("a3206d9e-fa8d-42d3-88cb-f75c51e69cde") + 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 ResultRetentionSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetResultRetentionSettings function +type GetResultRetentionSettingsArgs struct { + // (required) Project ID or project name + Project *string +} + +// Get a specific test case in a test suite with test case id. +func (client *ClientImpl) GetTestCaseById(ctx context.Context, args GetTestCaseByIdArgs) (*SuiteTestCase, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + if args.TestCaseIds == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseIds"} + } + routeValues["testCaseIds"] = strconv.Itoa(*args.TestCaseIds) + routeValues["action"] = "TestCases" + + locationId, _ := uuid.Parse("a4a1ec1c-b03f-41ca-8857-704594ecf58e") + 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 SuiteTestCase + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestCaseById function +type GetTestCaseByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan that contains the suites. + PlanId *int + // (required) ID of the suite that contains the test case. + SuiteId *int + // (required) ID of the test case to get. + TestCaseIds *int +} + +// Get all test cases in a suite. +func (client *ClientImpl) GetTestCases(ctx context.Context, args GetTestCasesArgs) (*[]SuiteTestCase, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + routeValues["action"] = "TestCases" + + locationId, _ := uuid.Parse("a4a1ec1c-b03f-41ca-8857-704594ecf58e") + 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 []SuiteTestCase + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestCases function +type GetTestCasesArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan that contains the suites. + PlanId *int + // (required) ID of the suite to get. + SuiteId *int +} + +// Get iteration for a result +func (client *ClientImpl) GetTestIteration(ctx context.Context, args GetTestIterationArgs) (*TestIterationDetailsModel, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = strconv.Itoa(*args.IterationId) + + queryParams := url.Values{} + if args.IncludeActionResults != nil { + queryParams.Add("includeActionResults", strconv.FormatBool(*args.IncludeActionResults)) + } + locationId, _ := uuid.Parse("73eb9074-3446-4c44-8296-2f811950ff8d") + 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 TestIterationDetailsModel + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestIteration function +type GetTestIterationArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the result. + RunId *int + // (required) ID of the test result that contains the iterations. + TestCaseResultId *int + // (required) Id of the test results Iteration. + IterationId *int + // (optional) Include result details for each action performed in the test iteration. ActionResults refer to outcome (pass/fail) of test steps that are executed as part of a running a manual test. Including the ActionResults flag gets the outcome of test steps in the actionResults section and test parameters in the parameters section for each test iteration. + IncludeActionResults *bool +} + +// Get iterations for a result +func (client *ClientImpl) GetTestIterations(ctx context.Context, args GetTestIterationsArgs) (*[]TestIterationDetailsModel, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + queryParams := url.Values{} + if args.IncludeActionResults != nil { + queryParams.Add("includeActionResults", strconv.FormatBool(*args.IncludeActionResults)) + } + locationId, _ := uuid.Parse("73eb9074-3446-4c44-8296-2f811950ff8d") + 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 []TestIterationDetailsModel + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestIterations function +type GetTestIterationsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the result. + RunId *int + // (required) ID of the test result that contains the iterations. + TestCaseResultId *int + // (optional) Include result details for each action performed in the test iteration. ActionResults refer to outcome (pass/fail) of test steps that are executed as part of a running a manual test. Including the ActionResults flag gets the outcome of test steps in the actionResults section and test parameters in the parameters section for each test iteration. + IncludeActionResults *bool +} + +// [Preview API] Download a test result attachment by its ID. +func (client *ClientImpl) GetTestResultAttachmentContent(ctx context.Context, args GetTestResultAttachmentContentArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + locationId, _ := uuid.Parse("2bffebe9-2f0f-4639-9af8-56129e9fed2d") + 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 GetTestResultAttachmentContent function +type GetTestResultAttachmentContentArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the testCaseResultId. + RunId *int + // (required) ID of the test result whose attachment has to be downloaded. + TestCaseResultId *int + // (required) ID of the test result attachment to be downloaded. + AttachmentId *int +} + +// [Preview API] Get list of test result attachments reference. +func (client *ClientImpl) GetTestResultAttachments(ctx context.Context, args GetTestResultAttachmentsArgs) (*[]TestAttachment, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + locationId, _ := uuid.Parse("2bffebe9-2f0f-4639-9af8-56129e9fed2d") + 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 []TestAttachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestResultAttachments function +type GetTestResultAttachmentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the result. + RunId *int + // (required) ID of the test result. + TestCaseResultId *int +} + +// [Preview API] Download a test result attachment by its ID. +func (client *ClientImpl) GetTestResultAttachmentZip(ctx context.Context, args GetTestResultAttachmentZipArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + locationId, _ := uuid.Parse("2bffebe9-2f0f-4639-9af8-56129e9fed2d") + 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 GetTestResultAttachmentZip function +type GetTestResultAttachmentZipArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the testCaseResultId. + RunId *int + // (required) ID of the test result whose attachment has to be downloaded. + TestCaseResultId *int + // (required) ID of the test result attachment to be downloaded. + AttachmentId *int +} + +// Get a test result for a test run. +func (client *ClientImpl) GetTestResultById(ctx context.Context, args GetTestResultByIdArgs) (*TestCaseResult, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + queryParams := url.Values{} + if args.DetailsToInclude != nil { + queryParams.Add("detailsToInclude", string(*args.DetailsToInclude)) + } + locationId, _ := uuid.Parse("4637d869-3a76-4468-8057-0bb02aa385cf") + 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 TestCaseResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestResultById function +type GetTestResultByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) Test run ID of a test result to fetch. + RunId *int + // (required) Test result ID. + TestCaseResultId *int + // (optional) Details to include with test results. Default is None. Other values are Iterations, WorkItems and SubResults. + DetailsToInclude *ResultDetails +} + +// Get test results for a test run. +func (client *ClientImpl) GetTestResults(ctx context.Context, args GetTestResultsArgs) (*[]TestCaseResult, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + queryParams := url.Values{} + if args.DetailsToInclude != nil { + queryParams.Add("detailsToInclude", string(*args.DetailsToInclude)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Outcomes != nil { + var stringList []string + for _, item := range *args.Outcomes { + stringList = append(stringList, string(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("outcomes", listAsString) + } + locationId, _ := uuid.Parse("4637d869-3a76-4468-8057-0bb02aa385cf") + 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 []TestCaseResult + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestResults function +type GetTestResultsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Test run ID of test results to fetch. + RunId *int + // (optional) Details to include with test results. Default is None. Other values are Iterations and WorkItems. + DetailsToInclude *ResultDetails + // (optional) Number of test results to skip from beginning. + Skip *int + // (optional) Number of test results to return. Maximum is 1000 when detailsToInclude is None and 200 otherwise. + Top *int + // (optional) Comma separated list of test outcomes to filter test results. + Outcomes *[]TestOutcome +} + +// [Preview API] Download a test run attachment by its ID. +func (client *ClientImpl) GetTestRunAttachmentContent(ctx context.Context, args GetTestRunAttachmentContentArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + locationId, _ := uuid.Parse("4f004af4-a507-489c-9b13-cb62060beb11") + 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 GetTestRunAttachmentContent function +type GetTestRunAttachmentContentArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run whose attachment has to be downloaded. + RunId *int + // (required) ID of the test run attachment to be downloaded. + AttachmentId *int +} + +// [Preview API] Get list of test run attachments reference. +func (client *ClientImpl) GetTestRunAttachments(ctx context.Context, args GetTestRunAttachmentsArgs) (*[]TestAttachment, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + locationId, _ := uuid.Parse("4f004af4-a507-489c-9b13-cb62060beb11") + 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 []TestAttachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRunAttachments function +type GetTestRunAttachmentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run. + RunId *int +} + +// [Preview API] Download a test run attachment by its ID. +func (client *ClientImpl) GetTestRunAttachmentZip(ctx context.Context, args GetTestRunAttachmentZipArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + locationId, _ := uuid.Parse("4f004af4-a507-489c-9b13-cb62060beb11") + 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 GetTestRunAttachmentZip function +type GetTestRunAttachmentZipArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run whose attachment has to be downloaded. + RunId *int + // (required) ID of the test run attachment to be downloaded. + AttachmentId *int +} + +// Get a test run by its ID. +func (client *ClientImpl) GetTestRunById(ctx context.Context, args GetTestRunByIdArgs) (*TestRun, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + queryParams := url.Values{} + if args.IncludeDetails != nil { + queryParams.Add("includeDetails", strconv.FormatBool(*args.IncludeDetails)) + } + locationId, _ := uuid.Parse("cadb3810-d47d-4a3c-a234-fe5f3be50138") + 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 TestRun + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRunById function +type GetTestRunByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the run to get. + RunId *int + // (optional) Default value is true. It includes details like run statistics, release, build, test environment, post process state, and more. + IncludeDetails *bool +} + +// [Preview API] Get code coverage data for a test run +func (client *ClientImpl) GetTestRunCodeCoverage(ctx context.Context, args GetTestRunCodeCoverageArgs) (*[]TestRunCoverage, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + queryParams := url.Values{} + if args.Flags == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "flags"} + } + queryParams.Add("flags", strconv.Itoa(*args.Flags)) + locationId, _ := uuid.Parse("9629116f-3b89-4ed8-b358-d4694efda160") + 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 []TestRunCoverage + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRunCodeCoverage function +type GetTestRunCodeCoverageArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run for which code coverage data needs to be fetched. + RunId *int + // (required) Value of flags determine the level of code coverage details to be fetched. Flags are additive. Expected Values are 1 for Modules, 2 for Functions, 4 for BlockData. + Flags *int +} + +// Get a list of test runs. +func (client *ClientImpl) GetTestRuns(ctx context.Context, args GetTestRunsArgs) (*[]TestRun, 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.BuildUri != nil { + queryParams.Add("buildUri", *args.BuildUri) + } + if args.Owner != nil { + queryParams.Add("owner", *args.Owner) + } + if args.TmiRunId != nil { + queryParams.Add("tmiRunId", *args.TmiRunId) + } + if args.PlanId != nil { + queryParams.Add("planId", strconv.Itoa(*args.PlanId)) + } + if args.IncludeRunDetails != nil { + queryParams.Add("includeRunDetails", strconv.FormatBool(*args.IncludeRunDetails)) + } + if args.Automated != nil { + queryParams.Add("automated", strconv.FormatBool(*args.Automated)) + } + 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("cadb3810-d47d-4a3c-a234-fe5f3be50138") + 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 []TestRun + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRuns function +type GetTestRunsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) URI of the build that the runs used. + BuildUri *string + // (optional) Team foundation ID of the owner of the runs. + Owner *string + // (optional) + TmiRunId *string + // (optional) ID of the test plan that the runs are a part of. + PlanId *int + // (optional) If true, include all the properties of the runs. + IncludeRunDetails *bool + // (optional) If true, only returns automated runs. + Automated *bool + // (optional) Number of test runs to skip. + Skip *int + // (optional) Number of test runs to return. + Top *int +} + +// Get test run statistics , used when we want to get summary of a run by outcome. +func (client *ClientImpl) GetTestRunStatistics(ctx context.Context, args GetTestRunStatisticsArgs) (*TestRunStatistic, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + locationId, _ := uuid.Parse("0a42c424-d764-4a16-a2d5-5c85f87d0ae8") + 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 TestRunStatistic + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRunStatistics function +type GetTestRunStatisticsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the run to get. + RunId *int +} + +// [Preview API] Get a list of test sessions +func (client *ClientImpl) GetTestSessions(ctx context.Context, args GetTestSessionsArgs) (*[]TestSession, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + queryParams := url.Values{} + if args.Period != nil { + queryParams.Add("period", strconv.Itoa(*args.Period)) + } + if args.AllSessions != nil { + queryParams.Add("allSessions", strconv.FormatBool(*args.AllSessions)) + } + if args.IncludeAllProperties != nil { + queryParams.Add("includeAllProperties", strconv.FormatBool(*args.IncludeAllProperties)) + } + if args.Source != nil { + queryParams.Add("source", string(*args.Source)) + } + if args.IncludeOnlyCompletedSessions != nil { + queryParams.Add("includeOnlyCompletedSessions", strconv.FormatBool(*args.IncludeOnlyCompletedSessions)) + } + locationId, _ := uuid.Parse("1500b4b4-6c69-4ca6-9b18-35e9e97fe2ac") + 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 []TestSession + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestSessions function +type GetTestSessionsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string + // (optional) Period in days from now, for which test sessions are fetched. + Period *int + // (optional) If false, returns test sessions for current user. Otherwise, it returns test sessions for all users + AllSessions *bool + // (optional) If true, it returns all properties of the test sessions. Otherwise, it returns the skinny version. + IncludeAllProperties *bool + // (optional) Source of the test session. + Source *TestSessionSource + // (optional) If true, it returns test sessions in completed state. Otherwise, it returns test sessions for all states + IncludeOnlyCompletedSessions *bool +} + +// [Preview API] Download a test sub result attachment +func (client *ClientImpl) GetTestSubResultAttachmentContent(ctx context.Context, args GetTestSubResultAttachmentContentArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + queryParams := url.Values{} + if args.TestSubResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testSubResultId"} + } + queryParams.Add("testSubResultId", strconv.Itoa(*args.TestSubResultId)) + locationId, _ := uuid.Parse("2bffebe9-2f0f-4639-9af8-56129e9fed2d") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/octet-stream", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetTestSubResultAttachmentContent function +type GetTestSubResultAttachmentContentArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the result. + RunId *int + // (required) ID of the test results that contains sub result. + TestCaseResultId *int + // (required) ID of the test result attachment to be downloaded + AttachmentId *int + // (required) ID of the test sub result whose attachment has to be downloaded + TestSubResultId *int +} + +// [Preview API] Get list of test sub result attachments +func (client *ClientImpl) GetTestSubResultAttachments(ctx context.Context, args GetTestSubResultAttachmentsArgs) (*[]TestAttachment, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + queryParams := url.Values{} + if args.TestSubResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testSubResultId"} + } + queryParams.Add("testSubResultId", strconv.Itoa(*args.TestSubResultId)) + locationId, _ := uuid.Parse("2bffebe9-2f0f-4639-9af8-56129e9fed2d") + 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 []TestAttachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestSubResultAttachments function +type GetTestSubResultAttachmentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the result. + RunId *int + // (required) ID of the test results that contains sub result. + TestCaseResultId *int + // (required) ID of the test sub result whose attachment has to be downloaded + TestSubResultId *int +} + +// [Preview API] Download a test sub result attachment +func (client *ClientImpl) GetTestSubResultAttachmentZip(ctx context.Context, args GetTestSubResultAttachmentZipArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + queryParams := url.Values{} + if args.TestSubResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testSubResultId"} + } + queryParams.Add("testSubResultId", strconv.Itoa(*args.TestSubResultId)) + locationId, _ := uuid.Parse("2bffebe9-2f0f-4639-9af8-56129e9fed2d") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetTestSubResultAttachmentZip function +type GetTestSubResultAttachmentZipArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test run that contains the result. + RunId *int + // (required) ID of the test results that contains sub result. + TestCaseResultId *int + // (required) ID of the test result attachment to be downloaded + AttachmentId *int + // (required) ID of the test sub result whose attachment has to be downloaded + TestSubResultId *int +} + +// [Preview API] Get history of a test method using TestHistoryQuery +func (client *ClientImpl) QueryTestHistory(ctx context.Context, args QueryTestHistoryArgs) (*TestHistoryQuery, error) { + if args.Filter == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Filter"} + } + 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.Filter) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("929fd86c-3e38-4d8c-b4b6-90df256e5971") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue TestHistoryQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryTestHistory function +type QueryTestHistoryArgs struct { + // (required) TestHistoryQuery to get history + Filter *TestHistoryQuery + // (required) Project ID or project name + Project *string +} + +// Query Test Runs based on filters. Mandatory fields are minLastUpdatedDate and maxLastUpdatedDate. +func (client *ClientImpl) QueryTestRuns(ctx context.Context, args QueryTestRunsArgs) (*QueryTestRunsResponseValue, 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.MinLastUpdatedDate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "minLastUpdatedDate"} + } + queryParams.Add("minLastUpdatedDate", (*args.MinLastUpdatedDate).String()) + if args.MaxLastUpdatedDate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "maxLastUpdatedDate"} + } + queryParams.Add("maxLastUpdatedDate", (*args.MaxLastUpdatedDate).String()) + if args.State != nil { + queryParams.Add("state", string(*args.State)) + } + if args.PlanIds != nil { + var stringList []string + for _, item := range *args.PlanIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("planIds", listAsString) + } + if args.IsAutomated != nil { + queryParams.Add("isAutomated", strconv.FormatBool(*args.IsAutomated)) + } + if args.PublishContext != nil { + queryParams.Add("publishContext", string(*args.PublishContext)) + } + if args.BuildIds != nil { + var stringList []string + for _, item := range *args.BuildIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("buildIds", listAsString) + } + if args.BuildDefIds != nil { + var stringList []string + for _, item := range *args.BuildDefIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("buildDefIds", listAsString) + } + if args.BranchName != nil { + queryParams.Add("branchName", *args.BranchName) + } + if args.ReleaseIds != nil { + var stringList []string + for _, item := range *args.ReleaseIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseIds", listAsString) + } + if args.ReleaseDefIds != nil { + var stringList []string + for _, item := range *args.ReleaseDefIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseDefIds", listAsString) + } + if args.ReleaseEnvIds != nil { + var stringList []string + for _, item := range *args.ReleaseEnvIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseEnvIds", listAsString) + } + if args.ReleaseEnvDefIds != nil { + var stringList []string + for _, item := range *args.ReleaseEnvDefIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseEnvDefIds", listAsString) + } + if args.RunTitle != nil { + queryParams.Add("runTitle", *args.RunTitle) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("cadb3810-d47d-4a3c-a234-fe5f3be50138") + 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 QueryTestRunsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the QueryTestRuns function +type QueryTestRunsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Minimum Last Modified Date of run to be queried (Mandatory). + MinLastUpdatedDate *azuredevops.Time + // (required) Maximum Last Modified Date of run to be queried (Mandatory, difference between min and max date can be atmost 7 days). + MaxLastUpdatedDate *azuredevops.Time + // (optional) Current state of the Runs to be queried. + State *TestRunState + // (optional) Plan Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10). + PlanIds *[]int + // (optional) Automation type of the Runs to be queried. + IsAutomated *bool + // (optional) PublishContext of the Runs to be queried. + PublishContext *TestRunPublishContext + // (optional) Build Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10). + BuildIds *[]int + // (optional) Build Definition Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10). + BuildDefIds *[]int + // (optional) Source Branch name of the Runs to be queried. + BranchName *string + // (optional) Release Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10). + ReleaseIds *[]int + // (optional) Release Definition Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10). + ReleaseDefIds *[]int + // (optional) Release Environment Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10). + ReleaseEnvIds *[]int + // (optional) Release Environment Definition Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10). + ReleaseEnvDefIds *[]int + // (optional) Run Title of the Runs to be queried. + RunTitle *string + // (optional) Number of runs to be queried. Limit is 100 + Top *int + // (optional) continuationToken received from previous batch or null for first batch. It is not supposed to be created (or altered, if received from last batch) by user. + ContinuationToken *string +} + +// Return type for the QueryTestRuns function +type QueryTestRunsResponseValue struct { + Value []TestRun + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// The test points associated with the test cases are removed from the test suite. The test case work item is not deleted from the system. See test cases resource to delete a test case permanently. +func (client *ClientImpl) RemoveTestCasesFromSuiteUrl(ctx context.Context, args RemoveTestCasesFromSuiteUrlArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + if args.TestCaseIds == nil || *args.TestCaseIds == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestCaseIds"} + } + routeValues["testCaseIds"] = *args.TestCaseIds + routeValues["action"] = "TestCases" + + locationId, _ := uuid.Parse("a4a1ec1c-b03f-41ca-8857-704594ecf58e") + _, 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 RemoveTestCasesFromSuiteUrl function +type RemoveTestCasesFromSuiteUrlArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan that contains the suite. + PlanId *int + // (required) ID of the suite to get. + SuiteId *int + // (required) IDs of the test cases to remove from the suite. + TestCaseIds *string +} + +// [Preview API] Update test result retention settings +func (client *ClientImpl) UpdateResultRetentionSettings(ctx context.Context, args UpdateResultRetentionSettingsArgs) (*ResultRetentionSettings, error) { + if args.RetentionSettings == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RetentionSettings"} + } + 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.RetentionSettings) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a3206d9e-fa8d-42d3-88cb-f75c51e69cde") + 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 ResultRetentionSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateResultRetentionSettings function +type UpdateResultRetentionSettingsArgs struct { + // (required) Test result retention settings details to be updated + RetentionSettings *ResultRetentionSettings + // (required) Project ID or project name + Project *string +} + +// Updates the properties of the test case association in a suite. +func (client *ClientImpl) UpdateSuiteTestCases(ctx context.Context, args UpdateSuiteTestCasesArgs) (*[]SuiteTestCase, error) { + if args.SuiteTestCaseUpdateModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteTestCaseUpdateModel"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + if args.TestCaseIds == nil || *args.TestCaseIds == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestCaseIds"} + } + routeValues["testCaseIds"] = *args.TestCaseIds + routeValues["action"] = "TestCases" + + body, marshalErr := json.Marshal(*args.SuiteTestCaseUpdateModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a4a1ec1c-b03f-41ca-8857-704594ecf58e") + 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 []SuiteTestCase + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateSuiteTestCases function +type UpdateSuiteTestCasesArgs struct { + // (required) Model for updation of the properties of test case suite association. + SuiteTestCaseUpdateModel *SuiteTestCaseUpdateModel + // (required) Project ID or project name + Project *string + // (required) ID of the test plan that contains the suite. + PlanId *int + // (required) ID of the test suite to which the test cases must be added. + SuiteId *int + // (required) IDs of the test cases to add to the suite. Ids are specified in comma separated format. + TestCaseIds *string +} + +// Update test points. +func (client *ClientImpl) UpdateTestPoints(ctx context.Context, args UpdateTestPointsArgs) (*[]TestPoint, error) { + if args.PointUpdateModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PointUpdateModel"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + if args.PointIds == nil || *args.PointIds == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PointIds"} + } + routeValues["pointIds"] = *args.PointIds + + body, marshalErr := json.Marshal(*args.PointUpdateModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("3bcfd5c8-be62-488e-b1da-b8289ce9299c") + 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 []TestPoint + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestPoints function +type UpdateTestPointsArgs struct { + // (required) Data to update. + PointUpdateModel *PointUpdateModel + // (required) Project ID or project name + Project *string + // (required) ID of the test plan. + PlanId *int + // (required) ID of the suite that contains the points. + SuiteId *int + // (required) ID of the test point to get. Use a comma-separated list of IDs to update multiple test points. + PointIds *string +} + +// Update test results in a test run. +func (client *ClientImpl) UpdateTestResults(ctx context.Context, args UpdateTestResultsArgs) (*[]TestCaseResult, error) { + if args.Results == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Results"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + body, marshalErr := json.Marshal(*args.Results) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4637d869-3a76-4468-8057-0bb02aa385cf") + 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 []TestCaseResult + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestResults function +type UpdateTestResultsArgs struct { + // (required) List of test results to update. + Results *[]TestCaseResult + // (required) Project ID or project name + Project *string + // (required) Test run ID whose test results to update. + RunId *int +} + +// Update test run by its ID. +func (client *ClientImpl) UpdateTestRun(ctx context.Context, args UpdateTestRunArgs) (*TestRun, error) { + if args.RunUpdateModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunUpdateModel"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + body, marshalErr := json.Marshal(*args.RunUpdateModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("cadb3810-d47d-4a3c-a234-fe5f3be50138") + 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 TestRun + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestRun function +type UpdateTestRunArgs struct { + // (required) Run details RunUpdateModel + RunUpdateModel *RunUpdateModel + // (required) Project ID or project name + Project *string + // (required) ID of the run to update. + RunId *int +} + +// [Preview API] Update a test session +func (client *ClientImpl) UpdateTestSession(ctx context.Context, args UpdateTestSessionArgs) (*TestSession, error) { + if args.TestSession == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestSession"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + body, marshalErr := json.Marshal(*args.TestSession) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1500b4b4-6c69-4ca6-9b18-35e9e97fe2ac") + 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 TestSession + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestSession function +type UpdateTestSessionArgs struct { + // (required) Test session details for update + TestSession *TestSession + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} diff --git a/azuredevops/test/models.go b/azuredevops/test/models.go new file mode 100644 index 00000000..b8a0ae75 --- /dev/null +++ b/azuredevops/test/models.go @@ -0,0 +1,3564 @@ +// -------------------------------------------------------------------------------------------- +// 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 test + +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/system" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type AbortTestRunRequest struct { + Options *int `json:"options,omitempty"` + ProjectName *string `json:"projectName,omitempty"` + Revision *int `json:"revision,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type AfnStrip struct { + // Auxiliary Url to be consumed by MTM + AuxiliaryUrl *string `json:"auxiliaryUrl,omitempty"` + // Creation date of the AfnStrip + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + // File name of the attachment created + FileName *string `json:"fileName,omitempty"` + // ID of AfnStrip. This is same as the attachment ID. + Id *int `json:"id,omitempty"` + // Project identifier which contains AfnStrip + Project *string `json:"project,omitempty"` + // Service in which this attachment is stored in + StoredIn *string `json:"storedIn,omitempty"` + // Afn strip stream. + Stream *string `json:"stream,omitempty"` + // ID of the testcase. + TestCaseId *int `json:"testCaseId,omitempty"` + // Backing test result id. + TestResultId *int `json:"testResultId,omitempty"` + // Backing test run id. + TestRunId *int `json:"testRunId,omitempty"` + // Byte stream (uncompressed) length of Afn strip. + UnCompressedStreamLength *uint64 `json:"unCompressedStreamLength,omitempty"` + // Url of the attachment created. + Url *string `json:"url,omitempty"` +} + +type AggregatedDataForResultTrend struct { + // This is tests execution duration. + Duration interface{} `json:"duration,omitempty"` + ResultsByOutcome *map[TestOutcome]AggregatedResultsByOutcome `json:"resultsByOutcome,omitempty"` + RunSummaryByState *map[TestRunState]AggregatedRunsByState `json:"runSummaryByState,omitempty"` + TestResultsContext *TestResultsContext `json:"testResultsContext,omitempty"` + TotalTests *int `json:"totalTests,omitempty"` +} + +type AggregatedResultsAnalysis struct { + Duration interface{} `json:"duration,omitempty"` + NotReportedResultsByOutcome *map[TestOutcome]AggregatedResultsByOutcome `json:"notReportedResultsByOutcome,omitempty"` + PreviousContext *TestResultsContext `json:"previousContext,omitempty"` + ResultsByOutcome *map[TestOutcome]AggregatedResultsByOutcome `json:"resultsByOutcome,omitempty"` + ResultsDifference *AggregatedResultsDifference `json:"resultsDifference,omitempty"` + RunSummaryByOutcome *map[TestRunOutcome]AggregatedRunsByOutcome `json:"runSummaryByOutcome,omitempty"` + RunSummaryByState *map[TestRunState]AggregatedRunsByState `json:"runSummaryByState,omitempty"` + TotalTests *int `json:"totalTests,omitempty"` +} + +type AggregatedResultsByOutcome struct { + Count *int `json:"count,omitempty"` + Duration interface{} `json:"duration,omitempty"` + GroupByField *string `json:"groupByField,omitempty"` + GroupByValue interface{} `json:"groupByValue,omitempty"` + Outcome *TestOutcome `json:"outcome,omitempty"` + RerunResultCount *int `json:"rerunResultCount,omitempty"` +} + +type AggregatedResultsDifference struct { + IncreaseInDuration interface{} `json:"increaseInDuration,omitempty"` + IncreaseInFailures *int `json:"increaseInFailures,omitempty"` + IncreaseInOtherTests *int `json:"increaseInOtherTests,omitempty"` + IncreaseInPassedTests *int `json:"increaseInPassedTests,omitempty"` + IncreaseInTotalTests *int `json:"increaseInTotalTests,omitempty"` +} + +type AggregatedRunsByOutcome struct { + Outcome *TestRunOutcome `json:"outcome,omitempty"` + RunsCount *int `json:"runsCount,omitempty"` +} + +type AggregatedRunsByState struct { + ResultsByOutcome *map[TestOutcome]AggregatedResultsByOutcome `json:"resultsByOutcome,omitempty"` + RunsCount *int `json:"runsCount,omitempty"` + State *TestRunState `json:"state,omitempty"` +} + +// The types of test attachments. +type AttachmentType string + +type attachmentTypeValuesType struct { + GeneralAttachment AttachmentType + CodeCoverage AttachmentType + ConsoleLog AttachmentType +} + +var AttachmentTypeValues = attachmentTypeValuesType{ + // Attachment type GeneralAttachment , use this as default type unless you have other type. + GeneralAttachment: "generalAttachment", + // Attachment type CodeCoverage. + CodeCoverage: "codeCoverage", + // Attachment type ConsoleLog. + ConsoleLog: "consoleLog", +} + +type BatchResponse struct { + Error *string `json:"error,omitempty"` + Responses *[]Response `json:"responses,omitempty"` + Status *string `json:"status,omitempty"` +} + +// BuildConfiguration Details. +type BuildConfiguration struct { + // Branch name for which build is generated. + BranchName *string `json:"branchName,omitempty"` + // BuildDefinitionId for build. + BuildDefinitionId *int `json:"buildDefinitionId,omitempty"` + // Build system. + BuildSystem *string `json:"buildSystem,omitempty"` + // Build Creation Date. + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + // Build flavor (eg Build/Release). + Flavor *string `json:"flavor,omitempty"` + // BuildConfiguration Id. + Id *int `json:"id,omitempty"` + // Build Number. + Number *string `json:"number,omitempty"` + // BuildConfiguration Platform. + Platform *string `json:"platform,omitempty"` + // Project associated with this BuildConfiguration. + Project *ShallowReference `json:"project,omitempty"` + // Repository Guid for the Build. + RepositoryGuid *string `json:"repositoryGuid,omitempty"` + // Deprecated: Use RepositoryGuid instead + RepositoryId *int `json:"repositoryId,omitempty"` + // Repository Type (eg. TFSGit). + RepositoryType *string `json:"repositoryType,omitempty"` + // Source Version(/first commit) for the build was triggered. + SourceVersion *string `json:"sourceVersion,omitempty"` + // Target BranchName. + TargetBranchName *string `json:"targetBranchName,omitempty"` + // Build Uri. + Uri *string `json:"uri,omitempty"` +} + +// Build Coverage Detail +type BuildCoverage struct { + // Code Coverage File Url + CodeCoverageFileUrl *string `json:"codeCoverageFileUrl,omitempty"` + // Build Configuration + Configuration *BuildConfiguration `json:"configuration,omitempty"` + // Last Error + LastError *string `json:"lastError,omitempty"` + // List of Modules + Modules *[]ModuleCoverage `json:"modules,omitempty"` + // State + State *string `json:"state,omitempty"` +} + +// Reference to a build. +type BuildReference struct { + // Branch name. + BranchName *string `json:"branchName,omitempty"` + // Build system. + BuildSystem *string `json:"buildSystem,omitempty"` + // Build Definition ID. + DefinitionId *int `json:"definitionId,omitempty"` + // Build ID. + Id *int `json:"id,omitempty"` + // Build Number. + Number *string `json:"number,omitempty"` + // Repository ID. + RepositoryId *string `json:"repositoryId,omitempty"` + // Build URI. + Uri *string `json:"uri,omitempty"` +} + +type BuildReference2 struct { + BranchName *string `json:"branchName,omitempty"` + BuildConfigurationId *int `json:"buildConfigurationId,omitempty"` + BuildDefinitionId *int `json:"buildDefinitionId,omitempty"` + BuildDeleted *bool `json:"buildDeleted,omitempty"` + BuildFlavor *string `json:"buildFlavor,omitempty"` + BuildId *int `json:"buildId,omitempty"` + BuildNumber *string `json:"buildNumber,omitempty"` + BuildPlatform *string `json:"buildPlatform,omitempty"` + BuildSystem *string `json:"buildSystem,omitempty"` + BuildUri *string `json:"buildUri,omitempty"` + CoverageId *int `json:"coverageId,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + RepoId *string `json:"repoId,omitempty"` + RepoType *string `json:"repoType,omitempty"` + SourceVersion *string `json:"sourceVersion,omitempty"` +} + +type BulkResultUpdateRequest struct { + ProjectName *string `json:"projectName,omitempty"` + Requests *[]ResultUpdateRequest `json:"requests,omitempty"` +} + +// Detail About Clone Operation. +type CloneOperationInformation struct { + // Clone Statistics + CloneStatistics *CloneStatistics `json:"cloneStatistics,omitempty"` + // If the operation is complete, the DateTime of completion. If operation is not complete, this is DateTime.MaxValue + CompletionDate *azuredevops.Time `json:"completionDate,omitempty"` + // DateTime when the operation was started + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + // Shallow reference of the destination + DestinationObject *ShallowReference `json:"destinationObject,omitempty"` + // Shallow reference of the destination + DestinationPlan *ShallowReference `json:"destinationPlan,omitempty"` + // Shallow reference of the destination + DestinationProject *ShallowReference `json:"destinationProject,omitempty"` + // If the operation has Failed, Message contains the reason for failure. Null otherwise. + Message *string `json:"message,omitempty"` + // The ID of the operation + OpId *int `json:"opId,omitempty"` + // The type of the object generated as a result of the Clone operation + ResultObjectType *ResultObjectType `json:"resultObjectType,omitempty"` + // Shallow reference of the source + SourceObject *ShallowReference `json:"sourceObject,omitempty"` + // Shallow reference of the source + SourcePlan *ShallowReference `json:"sourcePlan,omitempty"` + // Shallow reference of the source + SourceProject *ShallowReference `json:"sourceProject,omitempty"` + // Current state of the operation. When State reaches Succeeded or Failed, the operation is complete + State *CloneOperationState `json:"state,omitempty"` + // Url for getting the clone information + Url *string `json:"url,omitempty"` +} + +// Enum of type Clone Operation Type. +type CloneOperationState string + +type cloneOperationStateValuesType struct { + Failed CloneOperationState + InProgress CloneOperationState + Queued CloneOperationState + Succeeded CloneOperationState +} + +var CloneOperationStateValues = cloneOperationStateValuesType{ + // value for Failed State + Failed: "failed", + // value for Inprogress state + InProgress: "inProgress", + // Value for Queued State + Queued: "queued", + // value for Success state + Succeeded: "succeeded", +} + +// Clone options for cloning the test suite. +type CloneOptions struct { + // If set to true requirements will be cloned + CloneRequirements *bool `json:"cloneRequirements,omitempty"` + // copy all suites from a source plan + CopyAllSuites *bool `json:"copyAllSuites,omitempty"` + // copy ancestor hierarchy + CopyAncestorHierarchy *bool `json:"copyAncestorHierarchy,omitempty"` + // Name of the workitem type of the clone + DestinationWorkItemType *string `json:"destinationWorkItemType,omitempty"` + // Key value pairs where the key value is overridden by the value. + OverrideParameters *map[string]string `json:"overrideParameters,omitempty"` + // Comment on the link that will link the new clone test case to the original Set null for no comment + RelatedLinkComment *string `json:"relatedLinkComment,omitempty"` +} + +// Clone Statistics Details. +type CloneStatistics struct { + // Number of requirements cloned so far. + ClonedRequirementsCount *int `json:"clonedRequirementsCount,omitempty"` + // Number of shared steps cloned so far. + ClonedSharedStepsCount *int `json:"clonedSharedStepsCount,omitempty"` + // Number of test cases cloned so far + ClonedTestCasesCount *int `json:"clonedTestCasesCount,omitempty"` + // Total number of requirements to be cloned + TotalRequirementsCount *int `json:"totalRequirementsCount,omitempty"` + // Total number of test cases to be cloned + TotalTestCasesCount *int `json:"totalTestCasesCount,omitempty"` +} + +// Represents the build configuration (platform, flavor) and coverage data for the build +type CodeCoverageData struct { + // Flavor of build for which data is retrieved/published + BuildFlavor *string `json:"buildFlavor,omitempty"` + // Platform of build for which data is retrieved/published + BuildPlatform *string `json:"buildPlatform,omitempty"` + // List of coverage data for the build + CoverageStats *[]CodeCoverageStatistics `json:"coverageStats,omitempty"` +} + +// Represents the code coverage statistics for a particular coverage label (modules, statements, blocks, etc.) +type CodeCoverageStatistics struct { + // Covered units + Covered *int `json:"covered,omitempty"` + // Delta of coverage + Delta *float64 `json:"delta,omitempty"` + // Is delta valid + IsDeltaAvailable *bool `json:"isDeltaAvailable,omitempty"` + // Label of coverage data ("Blocks", "Statements", "Modules", etc.) + Label *string `json:"label,omitempty"` + // Position of label + Position *int `json:"position,omitempty"` + // Total units + Total *int `json:"total,omitempty"` +} + +// Represents the code coverage summary results Used to publish or retrieve code coverage summary against a build +type CodeCoverageSummary struct { + // Uri of build for which data is retrieved/published + Build *ShallowReference `json:"build,omitempty"` + // List of coverage data and details for the build + CoverageData *[]CodeCoverageData `json:"coverageData,omitempty"` + // Uri of build against which difference in coverage is computed + DeltaBuild *ShallowReference `json:"deltaBuild,omitempty"` + // Uri of build against which difference in coverage is computed + Status *CoverageSummaryStatus `json:"status,omitempty"` +} + +type CodeCoverageSummary2 struct { + BuildConfigurationId *int `json:"buildConfigurationId,omitempty"` + Covered *int `json:"covered,omitempty"` + Label *string `json:"label,omitempty"` + Position *int `json:"position,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + Total *int `json:"total,omitempty"` +} + +type Coverage2 struct { + CoverageId *int `json:"coverageId,omitempty"` + DateCreated *azuredevops.Time `json:"dateCreated,omitempty"` + DateModified *azuredevops.Time `json:"dateModified,omitempty"` + LastError *string `json:"lastError,omitempty"` + State *byte `json:"state,omitempty"` +} + +// [Flags] Used to choose which coverage data is returned by a QueryXXXCoverage() call. +type CoverageQueryFlags string + +type coverageQueryFlagsValuesType struct { + Modules CoverageQueryFlags + Functions CoverageQueryFlags + BlockData CoverageQueryFlags +} + +var CoverageQueryFlagsValues = coverageQueryFlagsValuesType{ + // If set, the Coverage.Modules property will be populated. + Modules: "modules", + // If set, the ModuleCoverage.Functions properties will be populated. + Functions: "functions", + // If set, the ModuleCoverage.CoverageData field will be populated. + BlockData: "blockData", +} + +type CoverageStatistics struct { + BlocksCovered *int `json:"blocksCovered,omitempty"` + BlocksNotCovered *int `json:"blocksNotCovered,omitempty"` + LinesCovered *int `json:"linesCovered,omitempty"` + LinesNotCovered *int `json:"linesNotCovered,omitempty"` + LinesPartiallyCovered *int `json:"linesPartiallyCovered,omitempty"` +} + +type CoverageStatus string + +type coverageStatusValuesType struct { + Covered CoverageStatus + NotCovered CoverageStatus + PartiallyCovered CoverageStatus +} + +var CoverageStatusValues = coverageStatusValuesType{ + Covered: "covered", + NotCovered: "notCovered", + PartiallyCovered: "partiallyCovered", +} + +// Represents status of code coverage summary for a build +type CoverageSummaryStatus string + +type coverageSummaryStatusValuesType struct { + None CoverageSummaryStatus + InProgress CoverageSummaryStatus + Completed CoverageSummaryStatus + Finalized CoverageSummaryStatus + Pending CoverageSummaryStatus +} + +var CoverageSummaryStatusValues = coverageSummaryStatusValuesType{ + // No coverage status + None: "none", + // The summary evaluation is in progress + InProgress: "inProgress", + // The summary evaluation for the previous request is completed. Summary can change in future + Completed: "completed", + // The summary evaluation is finalized and won't change + Finalized: "finalized", + // The summary evaluation is pending + Pending: "pending", +} + +type CreateTestMessageLogEntryRequest struct { + ProjectName *string `json:"projectName,omitempty"` + TestMessageLogEntry *[]TestMessageLogEntry `json:"testMessageLogEntry,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type CreateTestResultsRequest struct { + ProjectName *string `json:"projectName,omitempty"` + Results *[]LegacyTestCaseResult `json:"results,omitempty"` +} + +type CreateTestRunRequest struct { + ProjectName *string `json:"projectName,omitempty"` + Results *[]LegacyTestCaseResult `json:"results,omitempty"` + TestRun *LegacyTestRun `json:"testRun,omitempty"` + TestSettings *LegacyTestSettings `json:"testSettings,omitempty"` +} + +// A custom field information. Allowed Key : Value pairs - ( AttemptId: int value, IsTestResultFlaky: bool) +type CustomTestField struct { + // Field Name. + FieldName *string `json:"fieldName,omitempty"` + // Field value. + Value interface{} `json:"value,omitempty"` +} + +type CustomTestFieldDefinition struct { + FieldId *int `json:"fieldId,omitempty"` + FieldName *string `json:"fieldName,omitempty"` + FieldType *CustomTestFieldType `json:"fieldType,omitempty"` + Scope *CustomTestFieldScope `json:"scope,omitempty"` +} + +// [Flags] +type CustomTestFieldScope string + +type customTestFieldScopeValuesType struct { + None CustomTestFieldScope + TestRun CustomTestFieldScope + TestResult CustomTestFieldScope + System CustomTestFieldScope + All CustomTestFieldScope +} + +var CustomTestFieldScopeValues = customTestFieldScopeValuesType{ + None: "none", + TestRun: "testRun", + TestResult: "testResult", + System: "system", + All: "all", +} + +type CustomTestFieldType string + +type customTestFieldTypeValuesType struct { + Bit CustomTestFieldType + DateTime CustomTestFieldType + Int CustomTestFieldType + Float CustomTestFieldType + String CustomTestFieldType + Guid CustomTestFieldType +} + +var CustomTestFieldTypeValues = customTestFieldTypeValuesType{ + Bit: "bit", + DateTime: "dateTime", + Int: "int", + Float: "float", + String: "string", + Guid: "guid", +} + +type DatedTestFieldData struct { + Date *azuredevops.Time `json:"date,omitempty"` + Value *TestFieldData `json:"value,omitempty"` +} + +type DefaultAfnStripBinding struct { + TestCaseId *int `json:"testCaseId,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type DeleteTestRunRequest struct { + ProjectName *string `json:"projectName,omitempty"` + TestRunIds *[]int `json:"testRunIds,omitempty"` +} + +type DownloadAttachmentsRequest struct { + Ids *[]int `json:"ids,omitempty"` + Lengths *[]uint64 `json:"lengths,omitempty"` +} + +// This is a temporary class to provide the details for the test run environment. +type DtlEnvironmentDetails struct { + CsmContent *string `json:"csmContent,omitempty"` + CsmParameters *string `json:"csmParameters,omitempty"` + SubscriptionName *string `json:"subscriptionName,omitempty"` +} + +// Failing since information of a test result. +type FailingSince struct { + // Build reference since failing. + Build *BuildReference `json:"build,omitempty"` + // Time since failing. + Date *azuredevops.Time `json:"date,omitempty"` + // Release reference since failing. + Release *ReleaseReference `json:"release,omitempty"` +} + +type FetchTestResultsRequest struct { + IdAndRevs *[]TestCaseResultIdAndRev `json:"idAndRevs,omitempty"` + IncludeActionResults *bool `json:"includeActionResults,omitempty"` + ProjectName *string `json:"projectName,omitempty"` +} + +type FetchTestResultsResponse struct { + ActionResults *[]TestActionResult `json:"actionResults,omitempty"` + Attachments *[]TestResultAttachment `json:"attachments,omitempty"` + DeletedIds *[]LegacyTestCaseResultIdentifier `json:"deletedIds,omitempty"` + Results *[]LegacyTestCaseResult `json:"results,omitempty"` + TestParameters *[]TestResultParameter `json:"testParameters,omitempty"` +} + +type FieldDetailsForTestResults struct { + // Group by field name + FieldName *string `json:"fieldName,omitempty"` + // Group by field values + GroupsForField *[]interface{} `json:"groupsForField,omitempty"` +} + +type FileCoverage struct { + // List of line blocks along with their coverage status + LineBlocksCoverage *[]LineBlockCoverage `json:"lineBlocksCoverage,omitempty"` + // File path for which coverage information is sought for + Path *string `json:"path,omitempty"` +} + +type FileCoverageRequest struct { + FilePath *string `json:"filePath,omitempty"` + PullRequestBaseIterationId *int `json:"pullRequestBaseIterationId,omitempty"` + PullRequestId *int `json:"pullRequestId,omitempty"` + PullRequestIterationId *int `json:"pullRequestIterationId,omitempty"` + RepoId *string `json:"repoId,omitempty"` +} + +type FilterPointQuery struct { + PlanId *int `json:"planId,omitempty"` + PointIds *[]int `json:"pointIds,omitempty"` + PointOutcome *[]byte `json:"pointOutcome,omitempty"` + ResultState *[]byte `json:"resultState,omitempty"` +} + +type FlakyDetection struct { + // FlakyDetectionPipelines defines Pipelines for Detection. + FlakyDetectionPipelines *FlakyDetectionPipelines `json:"flakyDetectionPipelines,omitempty"` + // FlakyDetectionType defines Detection type i.e. 1. System or 2. Manual. + FlakyDetectionType *FlakyDetectionType `json:"flakyDetectionType,omitempty"` +} + +type FlakyDetectionPipelines struct { + // AllowedPipelines - List All Pipelines allowed for detection. + AllowedPipelines *[]int `json:"allowedPipelines,omitempty"` + // IsAllPipelinesAllowed if users configure all system's pipelines. + IsAllPipelinesAllowed *bool `json:"isAllPipelinesAllowed,omitempty"` +} + +type FlakyDetectionType string + +type flakyDetectionTypeValuesType struct { + Custom FlakyDetectionType + System FlakyDetectionType +} + +var FlakyDetectionTypeValues = flakyDetectionTypeValuesType{ + // Custom defines manual detection type. + Custom: "custom", + // Defines System detection type. + System: "system", +} + +type FlakySettings struct { + // FlakyDetection defines types of detection. + FlakyDetection *FlakyDetection `json:"flakyDetection,omitempty"` + // FlakyInSummaryReport defines flaky data should show in summary report or not. + FlakyInSummaryReport *bool `json:"flakyInSummaryReport,omitempty"` + // ManualMarkUnmarkFlaky defines manual marking unmarking of flaky testcase. + ManualMarkUnmarkFlaky *bool `json:"manualMarkUnmarkFlaky,omitempty"` +} + +type FunctionCoverage struct { + Class *string `json:"class,omitempty"` + Name *string `json:"name,omitempty"` + Namespace *string `json:"namespace,omitempty"` + SourceFile *string `json:"sourceFile,omitempty"` + Statistics *CoverageStatistics `json:"statistics,omitempty"` +} + +type FunctionCoverage2 struct { + BlocksCovered *int `json:"blocksCovered,omitempty"` + BlocksNotCovered *int `json:"blocksNotCovered,omitempty"` + Class *string `json:"class,omitempty"` + CoverageId *int `json:"coverageId,omitempty"` + FunctionId *int `json:"functionId,omitempty"` + LinesCovered *int `json:"linesCovered,omitempty"` + LinesNotCovered *int `json:"linesNotCovered,omitempty"` + LinesPartiallyCovered *int `json:"linesPartiallyCovered,omitempty"` + ModuleId *int `json:"moduleId,omitempty"` + Name *string `json:"name,omitempty"` + Namespace *string `json:"namespace,omitempty"` + SourceFile *string `json:"sourceFile,omitempty"` +} + +type HttpPostedTcmAttachment struct { + AttachmentContent *string `json:"attachmentContent,omitempty"` + ContentLength *int `json:"contentLength,omitempty"` + ContentType *string `json:"contentType,omitempty"` + FileName *string `json:"fileName,omitempty"` +} + +// Job in pipeline. This is related to matrixing in YAML. +type JobReference struct { + // Attempt number of the job + Attempt *int `json:"attempt,omitempty"` + // Matrixing in YAML generates copies of a job with different inputs in matrix. JobName is the name of those input. Maximum supported length for name is 256 character. + JobName *string `json:"jobName,omitempty"` +} + +// Last result details of test point. +type LastResultDetails struct { + // CompletedDate of LastResult. + DateCompleted *azuredevops.Time `json:"dateCompleted,omitempty"` + // Duration of LastResult. + Duration *uint64 `json:"duration,omitempty"` + // RunBy. + RunBy *webapi.IdentityRef `json:"runBy,omitempty"` +} + +type LegacyBuildConfiguration struct { + BranchName *string `json:"branchName,omitempty"` + BuildConfigurationId *int `json:"buildConfigurationId,omitempty"` + BuildDefinitionId *int `json:"buildDefinitionId,omitempty"` + BuildDefinitionName *string `json:"buildDefinitionName,omitempty"` + BuildFlavor *string `json:"buildFlavor,omitempty"` + BuildId *int `json:"buildId,omitempty"` + BuildNumber *string `json:"buildNumber,omitempty"` + BuildPlatform *string `json:"buildPlatform,omitempty"` + BuildQuality *string `json:"buildQuality,omitempty"` + BuildSystem *string `json:"buildSystem,omitempty"` + BuildUri *string `json:"buildUri,omitempty"` + CompletedDate *azuredevops.Time `json:"completedDate,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + OldBuildConfigurationId *int `json:"oldBuildConfigurationId,omitempty"` + RepositoryId *string `json:"repositoryId,omitempty"` + RepositoryType *string `json:"repositoryType,omitempty"` + SourceVersion *string `json:"sourceVersion,omitempty"` + TeamProjectName *string `json:"teamProjectName,omitempty"` +} + +type LegacyReleaseReference struct { + Attempt *int `json:"attempt,omitempty"` + EnvironmentCreationDate *azuredevops.Time `json:"environmentCreationDate,omitempty"` + PrimaryArtifactBuildId *int `json:"primaryArtifactBuildId,omitempty"` + PrimaryArtifactProjectId *string `json:"primaryArtifactProjectId,omitempty"` + PrimaryArtifactType *string `json:"primaryArtifactType,omitempty"` + ReleaseCreationDate *azuredevops.Time `json:"releaseCreationDate,omitempty"` + ReleaseDefId *int `json:"releaseDefId,omitempty"` + ReleaseEnvDefId *int `json:"releaseEnvDefId,omitempty"` + ReleaseEnvId *int `json:"releaseEnvId,omitempty"` + ReleaseEnvName *string `json:"releaseEnvName,omitempty"` + ReleaseEnvUri *string `json:"releaseEnvUri,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` + ReleaseName *string `json:"releaseName,omitempty"` + ReleaseRefId *int `json:"releaseRefId,omitempty"` + ReleaseUri *string `json:"releaseUri,omitempty"` +} + +type LegacyTestCaseResult struct { + AfnStripId *int `json:"afnStripId,omitempty"` + AreaId *int `json:"areaId,omitempty"` + AreaUri *string `json:"areaUri,omitempty"` + AutomatedTestId *string `json:"automatedTestId,omitempty"` + AutomatedTestName *string `json:"automatedTestName,omitempty"` + AutomatedTestStorage *string `json:"automatedTestStorage,omitempty"` + AutomatedTestType *string `json:"automatedTestType,omitempty"` + AutomatedTestTypeId *string `json:"automatedTestTypeId,omitempty"` + BuildNumber *string `json:"buildNumber,omitempty"` + BuildReference *LegacyBuildConfiguration `json:"buildReference,omitempty"` + Comment *string `json:"comment,omitempty"` + ComputerName *string `json:"computerName,omitempty"` + ConfigurationId *int `json:"configurationId,omitempty"` + ConfigurationName *string `json:"configurationName,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + CustomFields *[]TestExtensionField `json:"customFields,omitempty"` + DateCompleted *azuredevops.Time `json:"dateCompleted,omitempty"` + DateStarted *azuredevops.Time `json:"dateStarted,omitempty"` + Duration *uint64 `json:"duration,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + FailingSince *FailingSince `json:"failingSince,omitempty"` + FailureType *byte `json:"failureType,omitempty"` + Id *LegacyTestCaseResultIdentifier `json:"id,omitempty"` + IsRerun *bool `json:"isRerun,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LastUpdatedBy *uuid.UUID `json:"lastUpdatedBy,omitempty"` + LastUpdatedByName *string `json:"lastUpdatedByName,omitempty"` + Outcome *byte `json:"outcome,omitempty"` + Owner *uuid.UUID `json:"owner,omitempty"` + OwnerName *string `json:"ownerName,omitempty"` + Priority *byte `json:"priority,omitempty"` + ReleaseReference *LegacyReleaseReference `json:"releaseReference,omitempty"` + ResetCount *int `json:"resetCount,omitempty"` + ResolutionStateId *int `json:"resolutionStateId,omitempty"` + ResultGroupType *ResultGroupType `json:"resultGroupType,omitempty"` + Revision *int `json:"revision,omitempty"` + RunBy *uuid.UUID `json:"runBy,omitempty"` + RunByName *string `json:"runByName,omitempty"` + SequenceId *int `json:"sequenceId,omitempty"` + StackTrace *TestExtensionField `json:"stackTrace,omitempty"` + State *byte `json:"state,omitempty"` + SubResultCount *int `json:"subResultCount,omitempty"` + SuiteName *string `json:"suiteName,omitempty"` + TestCaseArea *string `json:"testCaseArea,omitempty"` + TestCaseAreaUri *string `json:"testCaseAreaUri,omitempty"` + TestCaseId *int `json:"testCaseId,omitempty"` + TestCaseReferenceId *int `json:"testCaseReferenceId,omitempty"` + TestCaseRevision *int `json:"testCaseRevision,omitempty"` + TestCaseTitle *string `json:"testCaseTitle,omitempty"` + TestPlanId *int `json:"testPlanId,omitempty"` + TestPointId *int `json:"testPointId,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` + TestRunTitle *string `json:"testRunTitle,omitempty"` + TestSuiteId *int `json:"testSuiteId,omitempty"` +} + +type LegacyTestCaseResultIdentifier struct { + AreaUri *string `json:"areaUri,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type LegacyTestRun struct { + BugsCount *int `json:"bugsCount,omitempty"` + BuildConfigurationId *int `json:"buildConfigurationId,omitempty"` + BuildFlavor *string `json:"buildFlavor,omitempty"` + BuildNumber *string `json:"buildNumber,omitempty"` + BuildPlatform *string `json:"buildPlatform,omitempty"` + BuildReference *LegacyBuildConfiguration `json:"buildReference,omitempty"` + BuildUri *string `json:"buildUri,omitempty"` + Comment *string `json:"comment,omitempty"` + CompleteDate *azuredevops.Time `json:"completeDate,omitempty"` + ConfigurationIds *[]int `json:"configurationIds,omitempty"` + Controller *string `json:"controller,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + CsmContent *string `json:"csmContent,omitempty"` + CsmParameters *string `json:"csmParameters,omitempty"` + CustomFields *[]TestExtensionField `json:"customFields,omitempty"` + DropLocation *string `json:"dropLocation,omitempty"` + DtlAutEnvironment *ShallowReference `json:"dtlAutEnvironment,omitempty"` + DtlTestEnvironment *ShallowReference `json:"dtlTestEnvironment,omitempty"` + DueDate *azuredevops.Time `json:"dueDate,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + Filter *RunFilter `json:"filter,omitempty"` + IncompleteTests *int `json:"incompleteTests,omitempty"` + IsAutomated *bool `json:"isAutomated,omitempty"` + IsBvt *bool `json:"isBvt,omitempty"` + Iteration *string `json:"iteration,omitempty"` + IterationId *int `json:"iterationId,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LastUpdatedBy *uuid.UUID `json:"lastUpdatedBy,omitempty"` + LastUpdatedByName *string `json:"lastUpdatedByName,omitempty"` + LegacySharePath *string `json:"legacySharePath,omitempty"` + NotApplicableTests *int `json:"notApplicableTests,omitempty"` + Owner *uuid.UUID `json:"owner,omitempty"` + OwnerName *string `json:"ownerName,omitempty"` + PassedTests *int `json:"passedTests,omitempty"` + PostProcessState *byte `json:"postProcessState,omitempty"` + PublicTestSettingsId *int `json:"publicTestSettingsId,omitempty"` + ReleaseEnvironmentUri *string `json:"releaseEnvironmentUri,omitempty"` + ReleaseReference *LegacyReleaseReference `json:"releaseReference,omitempty"` + ReleaseUri *string `json:"releaseUri,omitempty"` + Revision *int `json:"revision,omitempty"` + RowVersion *[]byte `json:"rowVersion,omitempty"` + RunHasDtlEnvironment *bool `json:"runHasDtlEnvironment,omitempty"` + RunTimeout interface{} `json:"runTimeout,omitempty"` + ServiceVersion *string `json:"serviceVersion,omitempty"` + SourceWorkflow *string `json:"sourceWorkflow,omitempty"` + StartDate *azuredevops.Time `json:"startDate,omitempty"` + State *byte `json:"state,omitempty"` + SubscriptionName *string `json:"subscriptionName,omitempty"` + Substate *byte `json:"substate,omitempty"` + TeamProject *string `json:"teamProject,omitempty"` + TeamProjectUri *string `json:"teamProjectUri,omitempty"` + TestConfigurationsMapping *string `json:"testConfigurationsMapping,omitempty"` + TestEnvironmentId *uuid.UUID `json:"testEnvironmentId,omitempty"` + TestMessageLogEntries *[]TestMessageLogDetails `json:"testMessageLogEntries,omitempty"` + TestMessageLogId *int `json:"testMessageLogId,omitempty"` + TestPlanId *int `json:"testPlanId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` + TestRunStatistics *[]LegacyTestRunStatistic `json:"testRunStatistics,omitempty"` + TestSettingsId *int `json:"testSettingsId,omitempty"` + Title *string `json:"title,omitempty"` + TotalTests *int `json:"totalTests,omitempty"` + Type *byte `json:"type,omitempty"` + UnanalyzedTests *int `json:"unanalyzedTests,omitempty"` + Version *int `json:"version,omitempty"` +} + +type LegacyTestRunStatistic struct { + Count *int `json:"count,omitempty"` + Outcome *byte `json:"outcome,omitempty"` + ResolutionState *TestResolutionState `json:"resolutionState,omitempty"` + State *byte `json:"state,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type LegacyTestSettings struct { + AreaId *int `json:"areaId,omitempty"` + AreaPath *string `json:"areaPath,omitempty"` + CreatedBy *uuid.UUID `json:"createdBy,omitempty"` + CreatedByName *string `json:"createdByName,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + Description *string `json:"description,omitempty"` + Id *int `json:"id,omitempty"` + IsAutomated *bool `json:"isAutomated,omitempty"` + IsPublic *bool `json:"isPublic,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LastUpdatedBy *uuid.UUID `json:"lastUpdatedBy,omitempty"` + LastUpdatedByName *string `json:"lastUpdatedByName,omitempty"` + MachineRoles *[]TestSettingsMachineRole `json:"machineRoles,omitempty"` + Name *string `json:"name,omitempty"` + Revision *int `json:"revision,omitempty"` + Settings *string `json:"settings,omitempty"` + TeamProjectUri *string `json:"teamProjectUri,omitempty"` +} + +type LineBlockCoverage struct { + // End of line block + End *int `json:"end,omitempty"` + // Start of line block + Start *int `json:"start,omitempty"` + // Coverage status. Covered: 0, NotCovered: 1, PartiallyCovered: 2 + Status *int `json:"status,omitempty"` +} + +type LinkedWorkItemsQuery struct { + AutomatedTestNames *[]string `json:"automatedTestNames,omitempty"` + PlanId *int `json:"planId,omitempty"` + PointIds *[]int `json:"pointIds,omitempty"` + SuiteIds *[]int `json:"suiteIds,omitempty"` + TestCaseIds *[]int `json:"testCaseIds,omitempty"` + WorkItemCategory *string `json:"workItemCategory,omitempty"` +} + +type LinkedWorkItemsQueryResult struct { + AutomatedTestName *string `json:"automatedTestName,omitempty"` + PlanId *int `json:"planId,omitempty"` + PointId *int `json:"pointId,omitempty"` + SuiteId *int `json:"suiteId,omitempty"` + TestCaseId *int `json:"testCaseId,omitempty"` + WorkItems *[]WorkItemReference `json:"workItems,omitempty"` +} + +type ModuleCoverage struct { + BlockCount *int `json:"blockCount,omitempty"` + BlockData *[]byte `json:"blockData,omitempty"` + // Code Coverage File Url + FileUrl *string `json:"fileUrl,omitempty"` + Functions *[]FunctionCoverage `json:"functions,omitempty"` + Name *string `json:"name,omitempty"` + Signature *uuid.UUID `json:"signature,omitempty"` + SignatureAge *int `json:"signatureAge,omitempty"` + Statistics *CoverageStatistics `json:"statistics,omitempty"` +} + +type ModuleCoverage2 struct { + BlockCount *int `json:"blockCount,omitempty"` + BlockData *[]byte `json:"blockData,omitempty"` + BlockDataLength *int `json:"blockDataLength,omitempty"` + BlocksCovered *int `json:"blocksCovered,omitempty"` + BlocksNotCovered *int `json:"blocksNotCovered,omitempty"` + CoverageFileUrl *string `json:"coverageFileUrl,omitempty"` + CoverageId *int `json:"coverageId,omitempty"` + LinesCovered *int `json:"linesCovered,omitempty"` + LinesNotCovered *int `json:"linesNotCovered,omitempty"` + LinesPartiallyCovered *int `json:"linesPartiallyCovered,omitempty"` + ModuleId *int `json:"moduleId,omitempty"` + Name *string `json:"name,omitempty"` + Signature *uuid.UUID `json:"signature,omitempty"` + SignatureAge *int `json:"signatureAge,omitempty"` +} + +// Name value pair +type NameValuePair struct { + // Name + Name *string `json:"name,omitempty"` + // Value + Value *string `json:"value,omitempty"` +} + +type OperationType string + +type operationTypeValuesType struct { + Add OperationType + Delete OperationType +} + +var OperationTypeValues = operationTypeValuesType{ + Add: "add", + Delete: "delete", +} + +// Phase in pipeline +type PhaseReference struct { + // Attempt number of the phase + Attempt *int `json:"attempt,omitempty"` + // Name of the phase. Maximum supported length for name is 256 character. + PhaseName *string `json:"phaseName,omitempty"` +} + +// Pipeline reference +type PipelineReference struct { + // Reference of the job + JobReference *JobReference `json:"jobReference,omitempty"` + // Reference of the phase. + PhaseReference *PhaseReference `json:"phaseReference,omitempty"` + // Reference of the pipeline with which this pipeline instance is related. + PipelineId *int `json:"pipelineId,omitempty"` + // Reference of the stage. + StageReference *StageReference `json:"stageReference,omitempty"` +} + +// A model class used for creating and updating test plans. +type PlanUpdateModel struct { + // Area path to which the test plan belongs. This should be set to area path of the team that works on this test plan. + Area *ShallowReference `json:"area,omitempty"` + // Build ID of the build whose quality is tested by the tests in this test plan. For automated testing, this build ID is used to find the test binaries that contain automated test methods. + Build *ShallowReference `json:"build,omitempty"` + // The Build Definition that generates a build associated with this test plan. + BuildDefinition *ShallowReference `json:"buildDefinition,omitempty"` + // IDs of configurations to be applied when new test suites and test cases are added to the test plan. + ConfigurationIds *[]int `json:"configurationIds,omitempty"` + // Description of the test plan. + Description *string `json:"description,omitempty"` + // End date for the test plan. + EndDate *string `json:"endDate,omitempty"` + // Iteration path assigned to the test plan. This indicates when the target iteration by which the testing in this plan is supposed to be complete and the product is ready to be released. + Iteration *string `json:"iteration,omitempty"` + // Name of the test plan. + Name *string `json:"name,omitempty"` + // Owner of the test plan. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Release Environment to be used to deploy the build and run automated tests from this test plan. + ReleaseEnvironmentDefinition *ReleaseEnvironmentDefinitionReference `json:"releaseEnvironmentDefinition,omitempty"` + // Start date for the test plan. + StartDate *string `json:"startDate,omitempty"` + // State of the test plan. + State *string `json:"state,omitempty"` + // Test Outcome settings + TestOutcomeSettings *TestOutcomeSettings `json:"testOutcomeSettings,omitempty"` +} + +// Adding test cases to a suite creates one of more test points based on the default configurations and testers assigned to the test suite. PointAssignment is the list of test points that were created for each of the test cases that were added to the test suite. +type PointAssignment struct { + // Configuration that was assigned to the test case. + Configuration *ShallowReference `json:"configuration,omitempty"` + // Tester that was assigned to the test case + Tester *webapi.IdentityRef `json:"tester,omitempty"` +} + +type PointLastResult struct { + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + PointId *int `json:"pointId,omitempty"` +} + +// Filter class for test point. +type PointsFilter struct { + // List of Configurations for filtering. + ConfigurationNames *[]string `json:"configurationNames,omitempty"` + // List of test case id for filtering. + TestcaseIds *[]int `json:"testcaseIds,omitempty"` + // List of tester for filtering. + Testers *[]webapi.IdentityRef `json:"testers,omitempty"` +} + +type PointsReference2 struct { + PlanId *int `json:"planId,omitempty"` + PointId *int `json:"pointId,omitempty"` +} + +type PointsResults2 struct { + ChangeNumber *int `json:"changeNumber,omitempty"` + LastFailureType *byte `json:"lastFailureType,omitempty"` + LastResolutionStateId *int `json:"lastResolutionStateId,omitempty"` + LastResultOutcome *byte `json:"lastResultOutcome,omitempty"` + LastResultState *byte `json:"lastResultState,omitempty"` + LastTestResultId *int `json:"lastTestResultId,omitempty"` + LastTestRunId *int `json:"lastTestRunId,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LastUpdatedBy *uuid.UUID `json:"lastUpdatedBy,omitempty"` + PlanId *int `json:"planId,omitempty"` + PointId *int `json:"pointId,omitempty"` +} + +// Model to update test point. +type PointUpdateModel struct { + // Outcome to update. + Outcome *string `json:"outcome,omitempty"` + // Reset test point to active. + ResetToActive *bool `json:"resetToActive,omitempty"` + // Tester to update. Type IdentityRef. + Tester *webapi.IdentityRef `json:"tester,omitempty"` +} + +// Test point workitem property. +type PointWorkItemProperty struct { + // key value pair of test point work item property. + WorkItem *azuredevops.KeyValuePair `json:"workItem,omitempty"` +} + +// The class to represent a Generic store for test session data. +type PropertyBag struct { + // Generic store for test session data + Bag *map[string]string `json:"bag,omitempty"` +} + +type QueryByPointRequest struct { + ProjectName *string `json:"projectName,omitempty"` + TestPlanId *int `json:"testPlanId,omitempty"` + TestPointId *int `json:"testPointId,omitempty"` +} + +type QueryByRunRequest struct { + IncludeActionResults *bool `json:"includeActionResults,omitempty"` + Outcome *byte `json:"outcome,omitempty"` + Owner *uuid.UUID `json:"owner,omitempty"` + PageSize *int `json:"pageSize,omitempty"` + ProjectName *string `json:"projectName,omitempty"` + State *byte `json:"state,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type QueryModel struct { + Query *string `json:"query,omitempty"` +} + +type QueryTestActionResultRequest struct { + Identifier *LegacyTestCaseResultIdentifier `json:"identifier,omitempty"` + ProjectName *string `json:"projectName,omitempty"` +} + +type QueryTestActionResultResponse struct { + TestActionResults *[]TestActionResult `json:"testActionResults,omitempty"` + TestAttachments *[]TestResultAttachment `json:"testAttachments,omitempty"` + TestResultParameters *[]TestResultParameter `json:"testResultParameters,omitempty"` +} + +type QueryTestMessageLogEntryRequest struct { + ProjectName *string `json:"projectName,omitempty"` + TestMessageLogId *int `json:"testMessageLogId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type QueryTestRuns2Request struct { + IncludeStatistics *bool `json:"includeStatistics,omitempty"` + Query *ResultsStoreQuery `json:"query,omitempty"` +} + +type QueryTestRunsRequest struct { + BuildUri *string `json:"buildUri,omitempty"` + Owner *uuid.UUID `json:"owner,omitempty"` + PlanId *int `json:"planId,omitempty"` + Skip *int `json:"skip,omitempty"` + TeamProjectName *string `json:"teamProjectName,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` + Top *int `json:"top,omitempty"` +} + +type QueryTestRunStatsRequest struct { + TeamProjectName *string `json:"teamProjectName,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +// Reference to release environment resource. +type ReleaseEnvironmentDefinitionReference struct { + // ID of the release definition that contains the release environment definition. + DefinitionId *int `json:"definitionId,omitempty"` + // ID of the release environment definition. + EnvironmentDefinitionId *int `json:"environmentDefinitionId,omitempty"` +} + +// Reference to a release. +type ReleaseReference struct { + // Number of Release Attempt. + Attempt *int `json:"attempt,omitempty"` + // Release Creation Date. + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + // Release definition ID. + DefinitionId *int `json:"definitionId,omitempty"` + // Environment creation Date. + EnvironmentCreationDate *azuredevops.Time `json:"environmentCreationDate,omitempty"` + // Release environment definition ID. + EnvironmentDefinitionId *int `json:"environmentDefinitionId,omitempty"` + // Release environment definition name. + EnvironmentDefinitionName *string `json:"environmentDefinitionName,omitempty"` + // Release environment ID. + EnvironmentId *int `json:"environmentId,omitempty"` + // Release environment name. + EnvironmentName *string `json:"environmentName,omitempty"` + // Release ID. + Id *int `json:"id,omitempty"` + // Release name. + Name *string `json:"name,omitempty"` +} + +type ReleaseReference2 struct { + Attempt *int `json:"attempt,omitempty"` + EnvironmentCreationDate *azuredevops.Time `json:"environmentCreationDate,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ReleaseCreationDate *azuredevops.Time `json:"releaseCreationDate,omitempty"` + ReleaseDefId *int `json:"releaseDefId,omitempty"` + ReleaseEnvDefId *int `json:"releaseEnvDefId,omitempty"` + ReleaseEnvId *int `json:"releaseEnvId,omitempty"` + ReleaseEnvName *string `json:"releaseEnvName,omitempty"` + ReleaseEnvUri *string `json:"releaseEnvUri,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` + ReleaseName *string `json:"releaseName,omitempty"` + ReleaseRefId *int `json:"releaseRefId,omitempty"` + ReleaseUri *string `json:"releaseUri,omitempty"` +} + +type RequirementsToTestsMapping2 struct { + CreatedBy *uuid.UUID `json:"createdBy,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + DeletedBy *uuid.UUID `json:"deletedBy,omitempty"` + DeletionDate *azuredevops.Time `json:"deletionDate,omitempty"` + IsMigratedToWIT *bool `json:"isMigratedToWIT,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + TestMetadataId *int `json:"testMetadataId,omitempty"` + WorkItemId *int `json:"workItemId,omitempty"` +} + +type ResetTestResultsRequest struct { + Ids *[]LegacyTestCaseResultIdentifier `json:"ids,omitempty"` + ProjectName *string `json:"projectName,omitempty"` +} + +type Response struct { + Error *string `json:"error,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Status *string `json:"status,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Additional details with test result +type ResultDetails string + +type resultDetailsValuesType struct { + None ResultDetails + Iterations ResultDetails + WorkItems ResultDetails + SubResults ResultDetails + Point ResultDetails +} + +var ResultDetailsValues = resultDetailsValuesType{ + // Core fields of test result. Core fields includes State, Outcome, Priority, AutomatedTestName, AutomatedTestStorage, Comments, ErrorMessage etc. + None: "none", + // Test iteration details in a test result. + Iterations: "iterations", + // Workitems associated with a test result. + WorkItems: "workItems", + // Subresults in a test result. + SubResults: "subResults", + // Point and plan detail in a test result. + Point: "point", +} + +// Hierarchy type of the result/subresults. +type ResultGroupType string + +type resultGroupTypeValuesType struct { + None ResultGroupType + Rerun ResultGroupType + DataDriven ResultGroupType + OrderedTest ResultGroupType + Generic ResultGroupType +} + +var ResultGroupTypeValues = resultGroupTypeValuesType{ + // Leaf node of test result. + None: "none", + // Hierarchy type of test result. + Rerun: "rerun", + // Hierarchy type of test result. + DataDriven: "dataDriven", + // Hierarchy type of test result. + OrderedTest: "orderedTest", + // Unknown hierarchy type. + Generic: "generic", +} + +// Additional details with test result metadata +type ResultMetaDataDetails string + +type resultMetaDataDetailsValuesType struct { + None ResultMetaDataDetails + FlakyIdentifiers ResultMetaDataDetails +} + +var ResultMetaDataDetailsValues = resultMetaDataDetailsValuesType{ + // Core fields of test result metadata. + None: "none", + // Test FlakyIdentifiers details in test result metadata. + FlakyIdentifiers: "flakyIdentifiers", +} + +// The top level entity that is being cloned as part of a Clone operation +type ResultObjectType string + +type resultObjectTypeValuesType struct { + TestSuite ResultObjectType + TestPlan ResultObjectType +} + +var ResultObjectTypeValues = resultObjectTypeValuesType{ + // Suite Clone + TestSuite: "testSuite", + // Plan Clone + TestPlan: "testPlan", +} + +// Test result retention settings +type ResultRetentionSettings struct { + // Automated test result retention duration in days + AutomatedResultsRetentionDuration *int `json:"automatedResultsRetentionDuration,omitempty"` + // Last Updated by identity + LastUpdatedBy *webapi.IdentityRef `json:"lastUpdatedBy,omitempty"` + // Last updated date + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Manual test result retention duration in days + ManualResultsRetentionDuration *int `json:"manualResultsRetentionDuration,omitempty"` +} + +type ResultsByQueryRequest struct { + PageSize *int `json:"pageSize,omitempty"` + Query *ResultsStoreQuery `json:"query,omitempty"` +} + +type ResultsByQueryResponse struct { + ExcessIds *[]LegacyTestCaseResultIdentifier `json:"excessIds,omitempty"` + TestResults *[]LegacyTestCaseResult `json:"testResults,omitempty"` +} + +type ResultsFilter struct { + AutomatedTestName *string `json:"automatedTestName,omitempty"` + Branch *string `json:"branch,omitempty"` + ExecutedIn *Service `json:"executedIn,omitempty"` + GroupBy *string `json:"groupBy,omitempty"` + MaxCompleteDate *azuredevops.Time `json:"maxCompleteDate,omitempty"` + ResultsCount *int `json:"resultsCount,omitempty"` + TestCaseId *int `json:"testCaseId,omitempty"` + TestCaseReferenceIds *[]int `json:"testCaseReferenceIds,omitempty"` + TestPlanId *int `json:"testPlanId,omitempty"` + TestPointIds *[]int `json:"testPointIds,omitempty"` + TestResultsContext *TestResultsContext `json:"testResultsContext,omitempty"` + TrendDays *int `json:"trendDays,omitempty"` +} + +type ResultsStoreQuery struct { + DayPrecision *bool `json:"dayPrecision,omitempty"` + QueryText *string `json:"queryText,omitempty"` + TeamProjectName *string `json:"teamProjectName,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} + +type ResultUpdateRequest struct { + ActionResultDeletes *[]TestActionResult `json:"actionResultDeletes,omitempty"` + ActionResults *[]TestActionResult `json:"actionResults,omitempty"` + AttachmentDeletes *[]TestResultAttachmentIdentity `json:"attachmentDeletes,omitempty"` + Attachments *[]TestResultAttachment `json:"attachments,omitempty"` + ParameterDeletes *[]TestResultParameter `json:"parameterDeletes,omitempty"` + Parameters *[]TestResultParameter `json:"parameters,omitempty"` + TestCaseResult *LegacyTestCaseResult `json:"testCaseResult,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type ResultUpdateRequestModel struct { + ActionResultDeletes *[]TestActionResultModel `json:"actionResultDeletes,omitempty"` + ActionResults *[]TestActionResultModel `json:"actionResults,omitempty"` + ParameterDeletes *[]TestResultParameterModel `json:"parameterDeletes,omitempty"` + Parameters *[]TestResultParameterModel `json:"parameters,omitempty"` + TestCaseResult *TestCaseResultUpdateModel `json:"testCaseResult,omitempty"` +} + +type ResultUpdateResponse struct { + AttachmentIds *[]int `json:"attachmentIds,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LastUpdatedBy *uuid.UUID `json:"lastUpdatedBy,omitempty"` + LastUpdatedByName *string `json:"lastUpdatedByName,omitempty"` + MaxReservedSubResultId *int `json:"maxReservedSubResultId,omitempty"` + Revision *int `json:"revision,omitempty"` + TestPlanId *int `json:"testPlanId,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` +} + +type ResultUpdateResponseModel struct { + Revision *int `json:"revision,omitempty"` +} + +// Test run create details. +type RunCreateModel struct { + // true if test run is automated, false otherwise. By default it will be false. + Automated *bool `json:"automated,omitempty"` + // An abstracted reference to the build that it belongs. + Build *ShallowReference `json:"build,omitempty"` + // Drop location of the build used for test run. + BuildDropLocation *string `json:"buildDropLocation,omitempty"` + // Flavor of the build used for test run. (E.g: Release, Debug) + BuildFlavor *string `json:"buildFlavor,omitempty"` + // Platform of the build used for test run. (E.g.: x86, amd64) + BuildPlatform *string `json:"buildPlatform,omitempty"` + // BuildReference of the test run. + BuildReference *BuildConfiguration `json:"buildReference,omitempty"` + // Comments entered by those analyzing the run. + Comment *string `json:"comment,omitempty"` + // Completed date time of the run. + CompleteDate *string `json:"completeDate,omitempty"` + // IDs of the test configurations associated with the run. + ConfigurationIds *[]int `json:"configurationIds,omitempty"` + // Name of the test controller used for automated run. + Controller *string `json:"controller,omitempty"` + // Additional properties of test Run. + CustomTestFields *[]CustomTestField `json:"customTestFields,omitempty"` + // An abstracted reference to DtlAutEnvironment. + DtlAutEnvironment *ShallowReference `json:"dtlAutEnvironment,omitempty"` + // An abstracted reference to DtlTestEnvironment. + DtlTestEnvironment *ShallowReference `json:"dtlTestEnvironment,omitempty"` + // Due date and time for test run. + DueDate *string `json:"dueDate,omitempty"` + EnvironmentDetails *DtlEnvironmentDetails `json:"environmentDetails,omitempty"` + // Error message associated with the run. + ErrorMessage *string `json:"errorMessage,omitempty"` + // Filter used for discovering the Run. + Filter *RunFilter `json:"filter,omitempty"` + // The iteration in which to create the run. Root iteration of the team project will be default + Iteration *string `json:"iteration,omitempty"` + // Name of the test run. + Name *string `json:"name,omitempty"` + // Display name of the owner of the run. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Reference of the pipeline to which this test run belongs. PipelineReference.PipelineId should be equal to RunCreateModel.Build.Id + PipelineReference *PipelineReference `json:"pipelineReference,omitempty"` + // An abstracted reference to the plan that it belongs. + Plan *ShallowReference `json:"plan,omitempty"` + // IDs of the test points to use in the run. + PointIds *[]int `json:"pointIds,omitempty"` + // URI of release environment associated with the run. + ReleaseEnvironmentUri *string `json:"releaseEnvironmentUri,omitempty"` + // Reference to release associated with test run. + ReleaseReference *ReleaseReference `json:"releaseReference,omitempty"` + // URI of release associated with the run. + ReleaseUri *string `json:"releaseUri,omitempty"` + // Run summary for run Type = NoConfigRun. + RunSummary *[]RunSummaryModel `json:"runSummary,omitempty"` + // Timespan till the run times out. + RunTimeout interface{} `json:"runTimeout,omitempty"` + // SourceWorkFlow(CI/CD) of the test run. + SourceWorkflow *string `json:"sourceWorkflow,omitempty"` + // Start date time of the run. + StartDate *string `json:"startDate,omitempty"` + // The state of the run. Type TestRunState Valid states - Unspecified ,NotStarted, InProgress, Completed, Waiting, Aborted, NeedsInvestigation + State *string `json:"state,omitempty"` + // Tags to attach with the test run, maximum of 5 tags can be added to run. + Tags *[]TestTag `json:"tags,omitempty"` + // TestConfigurationMapping of the test run. + TestConfigurationsMapping *string `json:"testConfigurationsMapping,omitempty"` + // ID of the test environment associated with the run. + TestEnvironmentId *string `json:"testEnvironmentId,omitempty"` + // An abstracted reference to the test settings resource. + TestSettings *ShallowReference `json:"testSettings,omitempty"` + // Type of the run(RunType) Valid Values : (Unspecified, Normal, Blocking, Web, MtrRunInitiatedFromWeb, RunWithDtlEnv, NoConfigRun) + Type *string `json:"type,omitempty"` +} + +// This class is used to provide the filters used for discovery +type RunFilter struct { + // filter for the test case sources (test containers) + SourceFilter *string `json:"sourceFilter,omitempty"` + // filter for the test cases + TestCaseFilter *string `json:"testCaseFilter,omitempty"` +} + +// Test run statistics per outcome. +type RunStatistic struct { + // Test result count fo the given outcome. + Count *int `json:"count,omitempty"` + // Test result outcome + Outcome *string `json:"outcome,omitempty"` + // Test run Resolution State. + ResolutionState *TestResolutionState `json:"resolutionState,omitempty"` + // State of the test run + State *string `json:"state,omitempty"` +} + +// Run summary for each output type of test. +type RunSummaryModel struct { + // Total time taken in milliseconds. + Duration *uint64 `json:"duration,omitempty"` + // Number of results for Outcome TestOutcome + ResultCount *int `json:"resultCount,omitempty"` + // Summary is based on outcome + TestOutcome *TestOutcome `json:"testOutcome,omitempty"` +} + +type RunType string + +type runTypeValuesType struct { + Unspecified RunType + Normal RunType + Blocking RunType + Web RunType + MtrRunInitiatedFromWeb RunType + RunWithDtlEnv RunType + NoConfigRun RunType +} + +var RunTypeValues = runTypeValuesType{ + // Only used during an update to preserve the existing value. + Unspecified: "unspecified", + // Normal test run. + Normal: "normal", + // Test run created for the blocked result when a test point is blocked. + Blocking: "blocking", + // Test run created from Web. + Web: "web", + // Run initiated from web through MTR + MtrRunInitiatedFromWeb: "mtrRunInitiatedFromWeb", + // These test run would require DTL environment. These could be either of automated or manual test run. + RunWithDtlEnv: "runWithDtlEnv", + // These test run may or may not have published test results but it will have summary like total test, passed test, failed test etc. These are automated tests. + NoConfigRun: "noConfigRun", +} + +type RunUpdateModel struct { + // An abstracted reference to the build that it belongs. + Build *ShallowReference `json:"build,omitempty"` + // Drop location of the build used for test run. + BuildDropLocation *string `json:"buildDropLocation,omitempty"` + // Flavor of the build used for test run. (E.g: Release, Debug) + BuildFlavor *string `json:"buildFlavor,omitempty"` + // Platform of the build used for test run. (E.g.: x86, amd64) + BuildPlatform *string `json:"buildPlatform,omitempty"` + // Comments entered by those analyzing the run. + Comment *string `json:"comment,omitempty"` + // Completed date time of the run. + CompletedDate *string `json:"completedDate,omitempty"` + // Name of the test controller used for automated run. + Controller *string `json:"controller,omitempty"` + // true to delete inProgess Results , false otherwise. + DeleteInProgressResults *bool `json:"deleteInProgressResults,omitempty"` + // An abstracted reference to DtlAutEnvironment. + DtlAutEnvironment *ShallowReference `json:"dtlAutEnvironment,omitempty"` + // An abstracted reference to DtlEnvironment. + DtlEnvironment *ShallowReference `json:"dtlEnvironment,omitempty"` + DtlEnvironmentDetails *DtlEnvironmentDetails `json:"dtlEnvironmentDetails,omitempty"` + // Due date and time for test run. + DueDate *string `json:"dueDate,omitempty"` + // Error message associated with the run. + ErrorMessage *string `json:"errorMessage,omitempty"` + // The iteration in which to create the run. + Iteration *string `json:"iteration,omitempty"` + // Log entries associated with the run. Use a comma-separated list of multiple log entry objects. { logEntry }, { logEntry }, ... + LogEntries *[]TestMessageLogDetails `json:"logEntries,omitempty"` + // Name of the test run. + Name *string `json:"name,omitempty"` + // URI of release environment associated with the run. + ReleaseEnvironmentUri *string `json:"releaseEnvironmentUri,omitempty"` + // URI of release associated with the run. + ReleaseUri *string `json:"releaseUri,omitempty"` + // Run summary for run Type = NoConfigRun. + RunSummary *[]RunSummaryModel `json:"runSummary,omitempty"` + // SourceWorkFlow(CI/CD) of the test run. + SourceWorkflow *string `json:"sourceWorkflow,omitempty"` + // Start date time of the run. + StartedDate *string `json:"startedDate,omitempty"` + // The state of the test run Below are the valid values - NotStarted, InProgress, Completed, Aborted, Waiting + State *string `json:"state,omitempty"` + // The types of sub states for test run. + Substate *TestRunSubstate `json:"substate,omitempty"` + // Tags to attach with the test run. + Tags *[]TestTag `json:"tags,omitempty"` + // ID of the test environment associated with the run. + TestEnvironmentId *string `json:"testEnvironmentId,omitempty"` + // An abstracted reference to test setting resource. + TestSettings *ShallowReference `json:"testSettings,omitempty"` +} + +type Service string + +type serviceValuesType struct { + Any Service + Tcm Service + Tfs Service +} + +var ServiceValues = serviceValuesType{ + Any: "any", + Tcm: "tcm", + Tfs: "tfs", +} + +// An abstracted reference to some other resource. This class is used to provide the build data contracts with a uniform way to reference other resources in a way that provides easy traversal through links. +type ShallowReference struct { + // ID of the resource + Id *string `json:"id,omitempty"` + // Name of the linked resource (definition name, controller name, etc.) + Name *string `json:"name,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` +} + +type ShallowTestCaseResult struct { + AutomatedTestName *string `json:"automatedTestName,omitempty"` + AutomatedTestStorage *string `json:"automatedTestStorage,omitempty"` + DurationInMs *float64 `json:"durationInMs,omitempty"` + Id *int `json:"id,omitempty"` + IsReRun *bool `json:"isReRun,omitempty"` + Outcome *string `json:"outcome,omitempty"` + Owner *string `json:"owner,omitempty"` + Priority *int `json:"priority,omitempty"` + RefId *int `json:"refId,omitempty"` + RunId *int `json:"runId,omitempty"` + Tags *[]string `json:"tags,omitempty"` + TestCaseTitle *string `json:"testCaseTitle,omitempty"` +} + +// Reference to shared step workitem. +type SharedStepModel struct { + // WorkItem shared step ID. + Id *int `json:"id,omitempty"` + // Shared step workitem revision. + Revision *int `json:"revision,omitempty"` +} + +// Stage in pipeline +type StageReference struct { + // Attempt number of stage + Attempt *int `json:"attempt,omitempty"` + // Name of the stage. Maximum supported length for name is 256 character. + StageName *string `json:"stageName,omitempty"` +} + +// Suite create model +type SuiteCreateModel struct { + // Name of test suite. + Name *string `json:"name,omitempty"` + // For query based suites, query string that defines the suite. + QueryString *string `json:"queryString,omitempty"` + // For requirements test suites, the IDs of the requirements. + RequirementIds *[]int `json:"requirementIds,omitempty"` + // Type of test suite to create. It can have value from DynamicTestSuite, StaticTestSuite and RequirementTestSuite. + SuiteType *string `json:"suiteType,omitempty"` +} + +// A suite entry defines properties for a test suite. +type SuiteEntry struct { + // Id of child suite in the test suite. + ChildSuiteId *int `json:"childSuiteId,omitempty"` + // Sequence number for the test case or child test suite in the test suite. + SequenceNumber *int `json:"sequenceNumber,omitempty"` + // Id for the test suite. + SuiteId *int `json:"suiteId,omitempty"` + // Id of a test case in the test suite. + TestCaseId *int `json:"testCaseId,omitempty"` +} + +// A model to define sequence of test suite entries in a test suite. +type SuiteEntryUpdateModel struct { + // Id of the child suite in the test suite. + ChildSuiteId *int `json:"childSuiteId,omitempty"` + // Updated sequence number for the test case or child test suite in the test suite. + SequenceNumber *int `json:"sequenceNumber,omitempty"` + // Id of the test case in the test suite. + TestCaseId *int `json:"testCaseId,omitempty"` +} + +// [Flags] Option to get details in response +type SuiteExpand string + +type suiteExpandValuesType struct { + Children SuiteExpand + DefaultTesters SuiteExpand +} + +var SuiteExpandValues = suiteExpandValuesType{ + // Include children in response. + Children: "children", + // Include default testers in response. + DefaultTesters: "defaultTesters", +} + +// Test case for the suite. +type SuiteTestCase struct { + // Point Assignment for test suite's test case. + PointAssignments *[]PointAssignment `json:"pointAssignments,omitempty"` + // Test case workItem reference. + TestCase *WorkItemReference `json:"testCase,omitempty"` +} + +// Test suite update model. +type SuiteTestCaseUpdateModel struct { + // Shallow reference of configurations for the test cases in the suite. + Configurations *[]ShallowReference `json:"configurations,omitempty"` +} + +// Test suite update model. +type SuiteUpdateModel struct { + // Shallow reference of default configurations for the suite. + DefaultConfigurations *[]ShallowReference `json:"defaultConfigurations,omitempty"` + // Shallow reference of test suite. + DefaultTesters *[]ShallowReference `json:"defaultTesters,omitempty"` + // Specifies if the default configurations have to be inherited from the parent test suite in which the test suite is created. + InheritDefaultConfigurations *bool `json:"inheritDefaultConfigurations,omitempty"` + // Test suite name + Name *string `json:"name,omitempty"` + // Shallow reference of the parent. + Parent *ShallowReference `json:"parent,omitempty"` + // For query based suites, the new query string. + QueryString *string `json:"queryString,omitempty"` +} + +type TCMPropertyBag2 struct { + ArtifactId *int `json:"artifactId,omitempty"` + ArtifactType *int `json:"artifactType,omitempty"` + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +type TCMServiceDataMigrationStatus string + +type tcmServiceDataMigrationStatusValuesType struct { + NotStarted TCMServiceDataMigrationStatus + InProgress TCMServiceDataMigrationStatus + Completed TCMServiceDataMigrationStatus + Failed TCMServiceDataMigrationStatus +} + +var TCMServiceDataMigrationStatusValues = tcmServiceDataMigrationStatusValuesType{ + // Migration Not Started + NotStarted: "notStarted", + // Migration InProgress + InProgress: "inProgress", + // Migration Completed + Completed: "completed", + // Migration Failed + Failed: "failed", +} + +type TestActionResult struct { + ActionPath *string `json:"actionPath,omitempty"` + Comment *string `json:"comment,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + DateCompleted *azuredevops.Time `json:"dateCompleted,omitempty"` + DateStarted *azuredevops.Time `json:"dateStarted,omitempty"` + Duration *uint64 `json:"duration,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + Id *LegacyTestCaseResultIdentifier `json:"id,omitempty"` + IterationId *int `json:"iterationId,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LastUpdatedBy *uuid.UUID `json:"lastUpdatedBy,omitempty"` + Outcome *byte `json:"outcome,omitempty"` + SharedStepId *int `json:"sharedStepId,omitempty"` + SharedStepRevision *int `json:"sharedStepRevision,omitempty"` +} + +type TestActionResult2 struct { + ActionPath *string `json:"actionPath,omitempty"` + Comment *string `json:"comment,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + DateCompleted *azuredevops.Time `json:"dateCompleted,omitempty"` + DateStarted *azuredevops.Time `json:"dateStarted,omitempty"` + Duration *uint64 `json:"duration,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + IterationId *int `json:"iterationId,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + Outcome *byte `json:"outcome,omitempty"` + SharedStepId *int `json:"sharedStepId,omitempty"` + SharedStepRevision *int `json:"sharedStepRevision,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +// Represents a test step result. +type TestActionResultModel struct { + // Comment in result. + Comment *string `json:"comment,omitempty"` + // Time when execution completed. + CompletedDate *azuredevops.Time `json:"completedDate,omitempty"` + // Duration of execution. + DurationInMs *float64 `json:"durationInMs,omitempty"` + // Error message in result. + ErrorMessage *string `json:"errorMessage,omitempty"` + // Test outcome of result. + Outcome *string `json:"outcome,omitempty"` + // Time when execution started. + StartedDate *azuredevops.Time `json:"startedDate,omitempty"` + // Path identifier test step in test case workitem. + ActionPath *string `json:"actionPath,omitempty"` + // Iteration ID of test action result. + IterationId *int `json:"iterationId,omitempty"` + // Reference to shared step workitem. + SharedStepModel *SharedStepModel `json:"sharedStepModel,omitempty"` + // This is step Id of test case. For shared step, it is step Id of shared step in test case workitem; step Id in shared step. Example: TestCase workitem has two steps: 1) Normal step with Id = 1 2) Shared Step with Id = 2. Inside shared step: a) Normal Step with Id = 1 Value for StepIdentifier for First step: "1" Second step: "2;1" + StepIdentifier *string `json:"stepIdentifier,omitempty"` + // Url of test action result. + Url *string `json:"url,omitempty"` +} + +type TestAttachment struct { + // Attachment type. + AttachmentType *AttachmentType `json:"attachmentType,omitempty"` + // Comment associated with attachment. + Comment *string `json:"comment,omitempty"` + // Attachment created date. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Attachment file name + FileName *string `json:"fileName,omitempty"` + // ID of the attachment. + Id *int `json:"id,omitempty"` + // Attachment size. + Size *uint64 `json:"size,omitempty"` + // Attachment Url. + Url *string `json:"url,omitempty"` +} + +// Reference to test attachment. +type TestAttachmentReference struct { + // ID of the attachment. + Id *int `json:"id,omitempty"` + // Url to download the attachment. + Url *string `json:"url,omitempty"` +} + +// Test attachment request model +type TestAttachmentRequestModel struct { + // Attachment type By Default it will be GeneralAttachment. It can be one of the following type. { GeneralAttachment, AfnStrip, BugFilingData, CodeCoverage, IntermediateCollectorData, RunConfig, TestImpactDetails, TmiTestRunDeploymentFiles, TmiTestRunReverseDeploymentFiles, TmiTestResultDetail, TmiTestRunSummary } + AttachmentType *string `json:"attachmentType,omitempty"` + // Comment associated with attachment + Comment *string `json:"comment,omitempty"` + // Attachment filename + FileName *string `json:"fileName,omitempty"` + // Base64 encoded file stream + Stream *string `json:"stream,omitempty"` +} + +type TestAuthoringDetails struct { + ConfigurationId *int `json:"configurationId,omitempty"` + IsAutomated *bool `json:"isAutomated,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + PointId *int `json:"pointId,omitempty"` + Priority *byte `json:"priority,omitempty"` + RunBy *uuid.UUID `json:"runBy,omitempty"` + State *TestPointState `json:"state,omitempty"` + SuiteId *int `json:"suiteId,omitempty"` + TesterId *uuid.UUID `json:"testerId,omitempty"` +} + +type TestCaseMetadata2 struct { + Container *string `json:"container,omitempty"` + Name *string `json:"name,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + TestMetadataId *int `json:"testMetadataId,omitempty"` +} + +type TestCaseReference2 struct { + AreaId *int `json:"areaId,omitempty"` + AutomatedTestId *string `json:"automatedTestId,omitempty"` + AutomatedTestName *string `json:"automatedTestName,omitempty"` + AutomatedTestNameHash *[]byte `json:"automatedTestNameHash,omitempty"` + AutomatedTestStorage *string `json:"automatedTestStorage,omitempty"` + AutomatedTestStorageHash *[]byte `json:"automatedTestStorageHash,omitempty"` + AutomatedTestType *string `json:"automatedTestType,omitempty"` + ConfigurationId *int `json:"configurationId,omitempty"` + CreatedBy *uuid.UUID `json:"createdBy,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + LastRefTestRunDate *azuredevops.Time `json:"lastRefTestRunDate,omitempty"` + Owner *string `json:"owner,omitempty"` + Priority *byte `json:"priority,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + TestCaseId *int `json:"testCaseId,omitempty"` + TestCaseRefId *int `json:"testCaseRefId,omitempty"` + TestCaseRevision *int `json:"testCaseRevision,omitempty"` + TestCaseTitle *string `json:"testCaseTitle,omitempty"` + TestPointId *int `json:"testPointId,omitempty"` +} + +// Represents a test result. +type TestCaseResult struct { + // Test attachment ID of action recording. + AfnStripId *int `json:"afnStripId,omitempty"` + // Reference to area path of test. + Area *ShallowReference `json:"area,omitempty"` + // Reference to bugs linked to test result. + AssociatedBugs *[]ShallowReference `json:"associatedBugs,omitempty"` + // ID representing test method in a dll. + AutomatedTestId *string `json:"automatedTestId,omitempty"` + // Fully qualified name of test executed. + AutomatedTestName *string `json:"automatedTestName,omitempty"` + // Container to which test belongs. + AutomatedTestStorage *string `json:"automatedTestStorage,omitempty"` + // Type of automated test. + AutomatedTestType *string `json:"automatedTestType,omitempty"` + // TypeId of automated test. + AutomatedTestTypeId *string `json:"automatedTestTypeId,omitempty"` + // Shallow reference to build associated with test result. + Build *ShallowReference `json:"build,omitempty"` + // Reference to build associated with test result. + BuildReference *BuildReference `json:"buildReference,omitempty"` + // Comment in a test result with maxSize= 1000 chars. + Comment *string `json:"comment,omitempty"` + // Time when test execution completed. Completed date should be greater than StartedDate. + CompletedDate *azuredevops.Time `json:"completedDate,omitempty"` + // Machine name where test executed. + ComputerName *string `json:"computerName,omitempty"` + // Reference to test configuration. Type ShallowReference. + Configuration *ShallowReference `json:"configuration,omitempty"` + // Timestamp when test result created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Additional properties of test result. + CustomFields *[]CustomTestField `json:"customFields,omitempty"` + // Duration of test execution in milliseconds. If not provided value will be set as CompletedDate - StartedDate + DurationInMs *float64 `json:"durationInMs,omitempty"` + // Error message in test execution. + ErrorMessage *string `json:"errorMessage,omitempty"` + // Information when test results started failing. + FailingSince *FailingSince `json:"failingSince,omitempty"` + // Failure type of test result. Valid Value= (Known Issue, New Issue, Regression, Unknown, None) + FailureType *string `json:"failureType,omitempty"` + // ID of a test result. + Id *int `json:"id,omitempty"` + // Test result details of test iterations used only for Manual Testing. + IterationDetails *[]TestIterationDetailsModel `json:"iterationDetails,omitempty"` + // Reference to identity last updated test result. + LastUpdatedBy *webapi.IdentityRef `json:"lastUpdatedBy,omitempty"` + // Last updated datetime of test result. + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Test outcome of test result. Valid values = (Unspecified, None, Passed, Failed, Inconclusive, Timeout, Aborted, Blocked, NotExecuted, Warning, Error, NotApplicable, Paused, InProgress, NotImpacted) + Outcome *string `json:"outcome,omitempty"` + // Reference to test owner. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Priority of test executed. + Priority *int `json:"priority,omitempty"` + // Reference to team project. + Project *ShallowReference `json:"project,omitempty"` + // Shallow reference to release associated with test result. + Release *ShallowReference `json:"release,omitempty"` + // Reference to release associated with test result. + ReleaseReference *ReleaseReference `json:"releaseReference,omitempty"` + // ResetCount. + ResetCount *int `json:"resetCount,omitempty"` + // Resolution state of test result. + ResolutionState *string `json:"resolutionState,omitempty"` + // ID of resolution state. + ResolutionStateId *int `json:"resolutionStateId,omitempty"` + // Hierarchy type of the result, default value of None means its leaf node. + ResultGroupType *ResultGroupType `json:"resultGroupType,omitempty"` + // Revision number of test result. + Revision *int `json:"revision,omitempty"` + // Reference to identity executed the test. + RunBy *webapi.IdentityRef `json:"runBy,omitempty"` + // Stacktrace with maxSize= 1000 chars. + StackTrace *string `json:"stackTrace,omitempty"` + // Time when test execution started. + StartedDate *azuredevops.Time `json:"startedDate,omitempty"` + // State of test result. Type TestRunState. + State *string `json:"state,omitempty"` + // List of sub results inside a test result, if ResultGroupType is not None, it holds corresponding type sub results. + SubResults *[]TestSubResult `json:"subResults,omitempty"` + // Reference to the test executed. + TestCase *ShallowReference `json:"testCase,omitempty"` + // Reference ID of test used by test result. Type TestResultMetaData + TestCaseReferenceId *int `json:"testCaseReferenceId,omitempty"` + // TestCaseRevision Number. + TestCaseRevision *int `json:"testCaseRevision,omitempty"` + // Name of test. + TestCaseTitle *string `json:"testCaseTitle,omitempty"` + // Reference to test plan test case workitem is part of. + TestPlan *ShallowReference `json:"testPlan,omitempty"` + // Reference to the test point executed. + TestPoint *ShallowReference `json:"testPoint,omitempty"` + // Reference to test run. + TestRun *ShallowReference `json:"testRun,omitempty"` + // Reference to test suite test case workitem is part of. + TestSuite *ShallowReference `json:"testSuite,omitempty"` + // Url of test result. + Url *string `json:"url,omitempty"` +} + +// Test attachment information in a test iteration. +type TestCaseResultAttachmentModel struct { + // Path identifier test step in test case workitem. + ActionPath *string `json:"actionPath,omitempty"` + // Attachment ID. + Id *int `json:"id,omitempty"` + // Iteration ID. + IterationId *int `json:"iterationId,omitempty"` + // Name of attachment. + Name *string `json:"name,omitempty"` + // Attachment size. + Size *uint64 `json:"size,omitempty"` + // Url to attachment. + Url *string `json:"url,omitempty"` +} + +type TestCaseResultIdAndRev struct { + Id *LegacyTestCaseResultIdentifier `json:"id,omitempty"` + Revision *int `json:"revision,omitempty"` +} + +// Reference to a test result. +type TestCaseResultIdentifier struct { + // Test result ID. + TestResultId *int `json:"testResultId,omitempty"` + // Test run ID. + TestRunId *int `json:"testRunId,omitempty"` +} + +type TestCaseResultUpdateModel struct { + AssociatedWorkItems *[]int `json:"associatedWorkItems,omitempty"` + AutomatedTestTypeId *string `json:"automatedTestTypeId,omitempty"` + Comment *string `json:"comment,omitempty"` + CompletedDate *string `json:"completedDate,omitempty"` + ComputerName *string `json:"computerName,omitempty"` + CustomFields *[]CustomTestField `json:"customFields,omitempty"` + DurationInMs *string `json:"durationInMs,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + FailureType *string `json:"failureType,omitempty"` + Outcome *string `json:"outcome,omitempty"` + Owner *webapi.IdentityRef `json:"owner,omitempty"` + ResolutionState *string `json:"resolutionState,omitempty"` + RunBy *webapi.IdentityRef `json:"runBy,omitempty"` + StackTrace *string `json:"stackTrace,omitempty"` + StartedDate *string `json:"startedDate,omitempty"` + State *string `json:"state,omitempty"` + TestCasePriority *string `json:"testCasePriority,omitempty"` + TestResult *ShallowReference `json:"testResult,omitempty"` +} + +// Test configuration +type TestConfiguration struct { + // Area of the configuration + Area *ShallowReference `json:"area,omitempty"` + // Description of the configuration + Description *string `json:"description,omitempty"` + // Id of the configuration + Id *int `json:"id,omitempty"` + // Is the configuration a default for the test plans + IsDefault *bool `json:"isDefault,omitempty"` + // Last Updated By Reference + LastUpdatedBy *webapi.IdentityRef `json:"lastUpdatedBy,omitempty"` + // Last Updated Data + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Name of the configuration + Name *string `json:"name,omitempty"` + // Project to which the configuration belongs + Project *ShallowReference `json:"project,omitempty"` + // Revision of the the configuration + Revision *int `json:"revision,omitempty"` + // State of the configuration + State *TestConfigurationState `json:"state,omitempty"` + // Url of Configuration Resource + Url *string `json:"url,omitempty"` + // Dictionary of Test Variable, Selected Value + Values *[]NameValuePair `json:"values,omitempty"` +} + +// Represents the state of an ITestConfiguration object. +type TestConfigurationState string + +type testConfigurationStateValuesType struct { + Active TestConfigurationState + Inactive TestConfigurationState +} + +var TestConfigurationStateValues = testConfigurationStateValuesType{ + // The configuration can be used for new test runs. + Active: "active", + // The configuration has been retired and should not be used for new test runs. + Inactive: "inactive", +} + +type TestExecutionReportData struct { + ReportData *[]DatedTestFieldData `json:"reportData,omitempty"` +} + +type TestExtensionField struct { + Field *TestExtensionFieldDetails `json:"field,omitempty"` + Value interface{} `json:"value,omitempty"` +} + +type TestExtensionFieldDetails struct { + Id *int `json:"id,omitempty"` + IsResultScoped *bool `json:"isResultScoped,omitempty"` + IsRunScoped *bool `json:"isRunScoped,omitempty"` + IsSystemField *bool `json:"isSystemField,omitempty"` + Name *string `json:"name,omitempty"` + Type *system.SqlDbType `json:"type,omitempty"` +} + +type TestFailureDetails struct { + Count *int `json:"count,omitempty"` + TestResults *[]TestCaseResultIdentifier `json:"testResults,omitempty"` +} + +type TestFailuresAnalysis struct { + ExistingFailures *TestFailureDetails `json:"existingFailures,omitempty"` + FixedTests *TestFailureDetails `json:"fixedTests,omitempty"` + NewFailures *TestFailureDetails `json:"newFailures,omitempty"` + PreviousContext *TestResultsContext `json:"previousContext,omitempty"` +} + +type TestFailureType struct { + Id *int `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Project *ShallowReference `json:"project,omitempty"` +} + +type TestFieldData struct { + Dimensions *map[string]interface{} `json:"dimensions,omitempty"` + Measure *uint64 `json:"measure,omitempty"` +} + +type TestFieldsEx2 struct { + FieldId *int `json:"fieldId,omitempty"` + FieldName *string `json:"fieldName,omitempty"` + FieldType *byte `json:"fieldType,omitempty"` + IsResultScoped *bool `json:"isResultScoped,omitempty"` + IsRunScoped *bool `json:"isRunScoped,omitempty"` + IsSystemField *bool `json:"isSystemField,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` +} + +// Test Flaky Identifier +type TestFlakyIdentifier struct { + // Branch Name where Flakiness has to be Marked/Unmarked + BranchName *string `json:"branchName,omitempty"` + // State for Flakiness + IsFlaky *bool `json:"isFlaky,omitempty"` +} + +// Filter to get TestCase result history. +type TestHistoryQuery struct { + // Automated test name of the TestCase. + AutomatedTestName *string `json:"automatedTestName,omitempty"` + // Results to be get for a particular branches. + Branch *string `json:"branch,omitempty"` + // Get the results history only for this BuildDefinitionId. This to get used in query GroupBy should be Branch. If this is provided, Branch will have no use. + BuildDefinitionId *int `json:"buildDefinitionId,omitempty"` + // It will be filled by server. If not null means there are some results still to be get, and we need to call this REST API with this ContinuousToken. It is not supposed to be created (or altered, if received from server in last batch) by user. + ContinuationToken *string `json:"continuationToken,omitempty"` + // Group the result on the basis of TestResultGroupBy. This can be Branch, Environment or null(if results are fetched by BuildDefinitionId) + GroupBy *TestResultGroupBy `json:"groupBy,omitempty"` + // History to get between time interval MaxCompleteDate and (MaxCompleteDate - TrendDays). Default is current date time. + MaxCompleteDate *azuredevops.Time `json:"maxCompleteDate,omitempty"` + // Get the results history only for this ReleaseEnvDefinitionId. This to get used in query GroupBy should be Environment. + ReleaseEnvDefinitionId *int `json:"releaseEnvDefinitionId,omitempty"` + // List of TestResultHistoryForGroup which are grouped by GroupBy + ResultsForGroup *[]TestResultHistoryForGroup `json:"resultsForGroup,omitempty"` + // Get the results history only for this testCaseId. This to get used in query to filter the result along with automatedtestname + TestCaseId *int `json:"testCaseId,omitempty"` + // Number of days for which history to collect. Maximum supported value is 7 days. Default is 7 days. + TrendDays *int `json:"trendDays,omitempty"` +} + +// Represents a test iteration result. +type TestIterationDetailsModel struct { + // Test step results in an iteration. + ActionResults *[]TestActionResultModel `json:"actionResults,omitempty"` + // Reference to attachments in test iteration result. + Attachments *[]TestCaseResultAttachmentModel `json:"attachments,omitempty"` + // Comment in test iteration result. + Comment *string `json:"comment,omitempty"` + // Time when execution completed. + CompletedDate *azuredevops.Time `json:"completedDate,omitempty"` + // Duration of execution. + DurationInMs *float64 `json:"durationInMs,omitempty"` + // Error message in test iteration result execution. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ID of test iteration result. + Id *int `json:"id,omitempty"` + // Test outcome if test iteration result. + Outcome *string `json:"outcome,omitempty"` + // Test parameters in an iteration. + Parameters *[]TestResultParameterModel `json:"parameters,omitempty"` + // Time when execution started. + StartedDate *azuredevops.Time `json:"startedDate,omitempty"` + // Url to test iteration result. + Url *string `json:"url,omitempty"` +} + +// Represents Test Log Result object. +type TestLog struct { + // Test Log Context run, build + LogReference *TestLogReference `json:"logReference,omitempty"` + MetaData *map[string]string `json:"metaData,omitempty"` + // LastUpdatedDate for Log file + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Size in Bytes for Log file + Size *uint64 `json:"size,omitempty"` +} + +type TestLogReference struct { + // BuildId for test log, if context is build + BuildId *int `json:"buildId,omitempty"` + // FileName for log file + FilePath *string `json:"filePath,omitempty"` + // ReleaseEnvId for test log, if context is Release + ReleaseEnvId *int `json:"releaseEnvId,omitempty"` + // ReleaseId for test log, if context is Release + ReleaseId *int `json:"releaseId,omitempty"` + // Resultid for test log, if context is run and log is related to result + ResultId *int `json:"resultId,omitempty"` + // runid for test log, if context is run + RunId *int `json:"runId,omitempty"` + // Test Log Reference object + Scope *TestLogScope `json:"scope,omitempty"` + // SubResultid for test log, if context is run and log is related to subresult + SubResultId *int `json:"subResultId,omitempty"` + // Log Type + Type *TestLogType `json:"type,omitempty"` +} + +// Test Log Context +type TestLogScope string + +type testLogScopeValuesType struct { + Run TestLogScope + Build TestLogScope + Release TestLogScope +} + +var TestLogScopeValues = testLogScopeValuesType{ + // Log file is associated with Run, result, subresult + Run: "run", + // Log File associated with Build + Build: "build", + // Log File associated with Release + Release: "release", +} + +// Represents Test Log Status object. +type TestLogStatus struct { + // Exception message + Exception *string `json:"exception,omitempty"` + // Test Log Status code + Status *TestLogStatusCode `json:"status,omitempty"` + // Blob Transfer Error code + TransferFailureType *string `json:"transferFailureType,omitempty"` +} + +// Test Log Status codes. +type TestLogStatusCode string + +type testLogStatusCodeValuesType struct { + Success TestLogStatusCode + Failed TestLogStatusCode + FileAlreadyExists TestLogStatusCode + InvalidInput TestLogStatusCode + InvalidFileName TestLogStatusCode + InvalidContainer TestLogStatusCode + TransferFailed TestLogStatusCode + FeatureDisabled TestLogStatusCode + BuildDoesNotExist TestLogStatusCode + RunDoesNotExist TestLogStatusCode + ContainerNotCreated TestLogStatusCode + ApiNotSupported TestLogStatusCode + FileSizeExceeds TestLogStatusCode + ContainerNotFound TestLogStatusCode + FileNotFound TestLogStatusCode + DirectoryNotFound TestLogStatusCode +} + +var TestLogStatusCodeValues = testLogStatusCodeValuesType{ + Success: "success", + Failed: "failed", + FileAlreadyExists: "fileAlreadyExists", + InvalidInput: "invalidInput", + InvalidFileName: "invalidFileName", + InvalidContainer: "invalidContainer", + TransferFailed: "transferFailed", + FeatureDisabled: "featureDisabled", + BuildDoesNotExist: "buildDoesNotExist", + RunDoesNotExist: "runDoesNotExist", + ContainerNotCreated: "containerNotCreated", + ApiNotSupported: "apiNotSupported", + FileSizeExceeds: "fileSizeExceeds", + ContainerNotFound: "containerNotFound", + FileNotFound: "fileNotFound", + DirectoryNotFound: "directoryNotFound", +} + +// Represents Test Log store endpoint details. +type TestLogStoreEndpointDetails struct { + // Test log store connection Uri. + EndpointSASUri *string `json:"endpointSASUri,omitempty"` + // Test log store endpoint type. + EndpointType *TestLogStoreEndpointType `json:"endpointType,omitempty"` + // Test log store status code + Status *TestLogStatusCode `json:"status,omitempty"` +} + +type TestLogStoreEndpointType string + +type testLogStoreEndpointTypeValuesType struct { + Root TestLogStoreEndpointType + File TestLogStoreEndpointType +} + +var TestLogStoreEndpointTypeValues = testLogStoreEndpointTypeValuesType{ + Root: "root", + File: "file", +} + +type TestLogStoreOperationType string + +type testLogStoreOperationTypeValuesType struct { + Read TestLogStoreOperationType + Create TestLogStoreOperationType + ReadAndCreate TestLogStoreOperationType +} + +var TestLogStoreOperationTypeValues = testLogStoreOperationTypeValuesType{ + Read: "read", + Create: "create", + ReadAndCreate: "readAndCreate", +} + +// Test Log Types +type TestLogType string + +type testLogTypeValuesType struct { + GeneralAttachment TestLogType + CodeCoverage TestLogType + TestImpact TestLogType + Intermediate TestLogType +} + +var TestLogTypeValues = testLogTypeValuesType{ + // Any gereric attachment. + GeneralAttachment: "generalAttachment", + // Code Coverage files + CodeCoverage: "codeCoverage", + // Test Impact details. + TestImpact: "testImpact", + // Temporary files + Intermediate: "intermediate", +} + +type TestMessageLog2 struct { + TestMessageLogId *int `json:"testMessageLogId,omitempty"` +} + +// An abstracted reference to some other resource. This class is used to provide the build data contracts with a uniform way to reference other resources in a way that provides easy traversal through links. +type TestMessageLogDetails struct { + // Date when the resource is created + DateCreated *azuredevops.Time `json:"dateCreated,omitempty"` + // Id of the resource + EntryId *int `json:"entryId,omitempty"` + // Message of the resource + Message *string `json:"message,omitempty"` +} + +type TestMessageLogEntry struct { + DateCreated *azuredevops.Time `json:"dateCreated,omitempty"` + EntryId *int `json:"entryId,omitempty"` + LogLevel *byte `json:"logLevel,omitempty"` + LogUser *uuid.UUID `json:"logUser,omitempty"` + LogUserName *string `json:"logUserName,omitempty"` + Message *string `json:"message,omitempty"` + TestMessageLogId *int `json:"testMessageLogId,omitempty"` +} + +type TestMessageLogEntry2 struct { + DateCreated *azuredevops.Time `json:"dateCreated,omitempty"` + EntryId *int `json:"entryId,omitempty"` + LogLevel *byte `json:"logLevel,omitempty"` + LogUser *uuid.UUID `json:"logUser,omitempty"` + Message *string `json:"message,omitempty"` + TestMessageLogId *int `json:"testMessageLogId,omitempty"` +} + +type TestMethod struct { + Container *string `json:"container,omitempty"` + Name *string `json:"name,omitempty"` +} + +// Class representing a reference to an operation. +type TestOperationReference struct { + Id *string `json:"id,omitempty"` + Status *string `json:"status,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Valid TestOutcome values. +type TestOutcome string + +type testOutcomeValuesType struct { + Unspecified TestOutcome + None TestOutcome + Passed TestOutcome + Failed TestOutcome + Inconclusive TestOutcome + Timeout TestOutcome + Aborted TestOutcome + Blocked TestOutcome + NotExecuted TestOutcome + Warning TestOutcome + Error TestOutcome + NotApplicable TestOutcome + Paused TestOutcome + InProgress TestOutcome + NotImpacted TestOutcome +} + +var TestOutcomeValues = testOutcomeValuesType{ + // Only used during an update to preserve the existing value. + Unspecified: "unspecified", + // Test has not been completed, or the test type does not report pass/failure. + None: "none", + // Test was executed w/o any issues. + Passed: "passed", + // Test was executed, but there were issues. Issues may involve exceptions or failed assertions. + Failed: "failed", + // Test has completed, but we can't say if it passed or failed. May be used for aborted tests... + Inconclusive: "inconclusive", + // The test timed out + Timeout: "timeout", + // Test was aborted. This was not caused by a user gesture, but rather by a framework decision. + Aborted: "aborted", + // Test had it chance for been executed but was not, as ITestElement.IsRunnable == false. + Blocked: "blocked", + // Test was not executed. This was caused by a user gesture - e.g. user hit stop button. + NotExecuted: "notExecuted", + // To be used by Run level results. This is not a failure. + Warning: "warning", + // There was a system error while we were trying to execute a test. + Error: "error", + // Test is Not Applicable for execution. + NotApplicable: "notApplicable", + // Test is paused. + Paused: "paused", + // Test is currently executing. Added this for TCM charts + InProgress: "inProgress", + // Test is not impacted. Added fot TIA. + NotImpacted: "notImpacted", +} + +// Test outcome settings +type TestOutcomeSettings struct { + // Value to configure how test outcomes for the same tests across suites are shown + SyncOutcomeAcrossSuites *bool `json:"syncOutcomeAcrossSuites,omitempty"` +} + +type TestParameter2 struct { + ActionPath *string `json:"actionPath,omitempty"` + Actual *[]byte `json:"actual,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + DataType *byte `json:"dataType,omitempty"` + DateModified *azuredevops.Time `json:"dateModified,omitempty"` + Expected *[]byte `json:"expected,omitempty"` + IterationId *int `json:"iterationId,omitempty"` + ParameterName *string `json:"parameterName,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +// The test plan resource. +type TestPlan struct { + // Area of the test plan. + Area *ShallowReference `json:"area,omitempty"` + // Build to be tested. + Build *ShallowReference `json:"build,omitempty"` + // The Build Definition that generates a build associated with this test plan. + BuildDefinition *ShallowReference `json:"buildDefinition,omitempty"` + // Description of the test plan. + Description *string `json:"description,omitempty"` + // End date for the test plan. + EndDate *azuredevops.Time `json:"endDate,omitempty"` + // ID of the test plan. + Id *int `json:"id,omitempty"` + // Iteration path of the test plan. + Iteration *string `json:"iteration,omitempty"` + // Name of the test plan. + Name *string `json:"name,omitempty"` + // Owner of the test plan. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + PreviousBuild *ShallowReference `json:"previousBuild,omitempty"` + // Project which contains the test plan. + Project *ShallowReference `json:"project,omitempty"` + // Release Environment to be used to deploy the build and run automated tests from this test plan. + ReleaseEnvironmentDefinition *ReleaseEnvironmentDefinitionReference `json:"releaseEnvironmentDefinition,omitempty"` + // Revision of the test plan. + Revision *int `json:"revision,omitempty"` + // Root test suite of the test plan. + RootSuite *ShallowReference `json:"rootSuite,omitempty"` + // Start date for the test plan. + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // State of the test plan. + State *string `json:"state,omitempty"` + // Value to configure how same tests across test suites under a test plan need to behave + TestOutcomeSettings *TestOutcomeSettings `json:"testOutcomeSettings,omitempty"` + UpdatedBy *webapi.IdentityRef `json:"updatedBy,omitempty"` + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` + // URL of the test plan resource. + Url *string `json:"url,omitempty"` +} + +type TestPlanCloneRequest struct { + DestinationTestPlan *TestPlan `json:"destinationTestPlan,omitempty"` + Options *CloneOptions `json:"options,omitempty"` + SuiteIds *[]int `json:"suiteIds,omitempty"` +} + +type TestPlanHubData struct { + SelectedSuiteId *int `json:"selectedSuiteId,omitempty"` + TestPlan *TestPlan `json:"testPlan,omitempty"` + TestPoints *[]TestPoint `json:"testPoints,omitempty"` + TestSuites *[]TestSuite `json:"testSuites,omitempty"` + TotalTestPoints *int `json:"totalTestPoints,omitempty"` +} + +type TestPlansWithSelection struct { + LastSelectedPlan *int `json:"lastSelectedPlan,omitempty"` + LastSelectedSuite *int `json:"lastSelectedSuite,omitempty"` + Plans *[]TestPlan `json:"plans,omitempty"` +} + +// Test point. +type TestPoint struct { + // AssignedTo. Type IdentityRef. + AssignedTo *webapi.IdentityRef `json:"assignedTo,omitempty"` + // Automated. + Automated *bool `json:"automated,omitempty"` + // Comment associated with test point. + Comment *string `json:"comment,omitempty"` + // Configuration. Type ShallowReference. + Configuration *ShallowReference `json:"configuration,omitempty"` + // Failure type of test point. + FailureType *string `json:"failureType,omitempty"` + // ID of the test point. + Id *int `json:"id,omitempty"` + // Last date when test point was reset to Active. + LastResetToActive *azuredevops.Time `json:"lastResetToActive,omitempty"` + // Last resolution state id of test point. + LastResolutionStateId *int `json:"lastResolutionStateId,omitempty"` + // Last result of test point. Type ShallowReference. + LastResult *ShallowReference `json:"lastResult,omitempty"` + // Last result details of test point. Type LastResultDetails. + LastResultDetails *LastResultDetails `json:"lastResultDetails,omitempty"` + // Last result state of test point. + LastResultState *string `json:"lastResultState,omitempty"` + // LastRun build number of test point. + LastRunBuildNumber *string `json:"lastRunBuildNumber,omitempty"` + // Last testRun of test point. Type ShallowReference. + LastTestRun *ShallowReference `json:"lastTestRun,omitempty"` + // Test point last updated by. Type IdentityRef. + LastUpdatedBy *webapi.IdentityRef `json:"lastUpdatedBy,omitempty"` + // Last updated date of test point. + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Outcome of test point. + Outcome *string `json:"outcome,omitempty"` + // Revision number. + Revision *int `json:"revision,omitempty"` + // State of test point. + State *string `json:"state,omitempty"` + // Suite of test point. Type ShallowReference. + Suite *ShallowReference `json:"suite,omitempty"` + // TestCase associated to test point. Type WorkItemReference. + TestCase *WorkItemReference `json:"testCase,omitempty"` + // TestPlan of test point. Type ShallowReference. + TestPlan *ShallowReference `json:"testPlan,omitempty"` + // Test point Url. + Url *string `json:"url,omitempty"` + // Work item properties of test point. + WorkItemProperties *[]interface{} `json:"workItemProperties,omitempty"` +} + +type TestPointReference struct { + Id *int `json:"id,omitempty"` + State *TestPointState `json:"state,omitempty"` +} + +type TestPointsEvent struct { + ProjectName *string `json:"projectName,omitempty"` + TestPoints *[]TestPointReference `json:"testPoints,omitempty"` +} + +// Test point query class. +type TestPointsQuery struct { + // Order by results. + OrderBy *string `json:"orderBy,omitempty"` + // List of test points + Points *[]TestPoint `json:"points,omitempty"` + // Filter + PointsFilter *PointsFilter `json:"pointsFilter,omitempty"` + // List of workitem fields to get. + WitFields *[]string `json:"witFields,omitempty"` +} + +type TestPointState string + +type testPointStateValuesType struct { + None TestPointState + Ready TestPointState + Completed TestPointState + NotReady TestPointState + InProgress TestPointState + MaxValue TestPointState +} + +var TestPointStateValues = testPointStateValuesType{ + // Default + None: "none", + // The test point needs to be executed in order for the test pass to be considered complete. Either the test has not been run before or the previous run failed. + Ready: "ready", + // The test has passed successfully and does not need to be re-run for the test pass to be considered complete. + Completed: "completed", + // The test point needs to be executed but is not able to. + NotReady: "notReady", + // The test is being executed. + InProgress: "inProgress", + MaxValue: "maxValue", +} + +type TestPointsUpdatedEvent struct { + ProjectName *string `json:"projectName,omitempty"` + TestPoints *[]TestPointReference `json:"testPoints,omitempty"` +} + +// Test Resolution State Details. +type TestResolutionState struct { + // Test Resolution state Id. + Id *int `json:"id,omitempty"` + // Test Resolution State Name. + Name *string `json:"name,omitempty"` + Project *ShallowReference `json:"project,omitempty"` +} + +type TestResult2 struct { + AfnStripId *int `json:"afnStripId,omitempty"` + ComputerName *string `json:"computerName,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + DateCompleted *azuredevops.Time `json:"dateCompleted,omitempty"` + DateStarted *azuredevops.Time `json:"dateStarted,omitempty"` + EffectivePointState *byte `json:"effectivePointState,omitempty"` + FailureType *byte `json:"failureType,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LastUpdatedBy *uuid.UUID `json:"lastUpdatedBy,omitempty"` + Outcome *byte `json:"outcome,omitempty"` + Owner *uuid.UUID `json:"owner,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ResetCount *int `json:"resetCount,omitempty"` + ResolutionStateId *int `json:"resolutionStateId,omitempty"` + Revision *int `json:"revision,omitempty"` + RunBy *uuid.UUID `json:"runBy,omitempty"` + State *byte `json:"state,omitempty"` + TestCaseRefId *int `json:"testCaseRefId,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type TestResultAcrossProjectResponse struct { + ProjectName *string `json:"projectName,omitempty"` + TestResult *LegacyTestCaseResult `json:"testResult,omitempty"` +} + +type TestResultAttachment struct { + ActionPath *string `json:"actionPath,omitempty"` + AttachmentType *AttachmentType `json:"attachmentType,omitempty"` + Comment *string `json:"comment,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + DownloadQueryString *string `json:"downloadQueryString,omitempty"` + FileName *string `json:"fileName,omitempty"` + Id *int `json:"id,omitempty"` + IsComplete *bool `json:"isComplete,omitempty"` + IterationId *int `json:"iterationId,omitempty"` + Length *uint64 `json:"length,omitempty"` + SessionId *int `json:"sessionId,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` + TmiRunId *uuid.UUID `json:"tmiRunId,omitempty"` +} + +type TestResultAttachmentIdentity struct { + AttachmentId *int `json:"attachmentId,omitempty"` + SessionId *int `json:"sessionId,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type TestResultCreateModel struct { + Area *ShallowReference `json:"area,omitempty"` + AssociatedWorkItems *[]int `json:"associatedWorkItems,omitempty"` + AutomatedTestId *string `json:"automatedTestId,omitempty"` + AutomatedTestName *string `json:"automatedTestName,omitempty"` + AutomatedTestStorage *string `json:"automatedTestStorage,omitempty"` + AutomatedTestType *string `json:"automatedTestType,omitempty"` + AutomatedTestTypeId *string `json:"automatedTestTypeId,omitempty"` + Comment *string `json:"comment,omitempty"` + CompletedDate *string `json:"completedDate,omitempty"` + ComputerName *string `json:"computerName,omitempty"` + Configuration *ShallowReference `json:"configuration,omitempty"` + CustomFields *[]CustomTestField `json:"customFields,omitempty"` + DurationInMs *string `json:"durationInMs,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + FailureType *string `json:"failureType,omitempty"` + Outcome *string `json:"outcome,omitempty"` + Owner *webapi.IdentityRef `json:"owner,omitempty"` + ResolutionState *string `json:"resolutionState,omitempty"` + RunBy *webapi.IdentityRef `json:"runBy,omitempty"` + StackTrace *string `json:"stackTrace,omitempty"` + StartedDate *string `json:"startedDate,omitempty"` + State *string `json:"state,omitempty"` + TestCase *ShallowReference `json:"testCase,omitempty"` + TestCasePriority *string `json:"testCasePriority,omitempty"` + TestCaseTitle *string `json:"testCaseTitle,omitempty"` + TestPoint *ShallowReference `json:"testPoint,omitempty"` +} + +type TestResultDocument struct { + OperationReference *TestOperationReference `json:"operationReference,omitempty"` + Payload *TestResultPayload `json:"payload,omitempty"` +} + +// Group by for results +type TestResultGroupBy string + +type testResultGroupByValuesType struct { + Branch TestResultGroupBy + Environment TestResultGroupBy +} + +var TestResultGroupByValues = testResultGroupByValuesType{ + // Group the results by branches + Branch: "branch", + // Group the results by environment + Environment: "environment", +} + +type TestResultHistory struct { + GroupByField *string `json:"groupByField,omitempty"` + ResultsForGroup *[]TestResultHistoryDetailsForGroup `json:"resultsForGroup,omitempty"` +} + +type TestResultHistoryDetailsForGroup struct { + GroupByValue interface{} `json:"groupByValue,omitempty"` + LatestResult *TestCaseResult `json:"latestResult,omitempty"` +} + +// List of test results filtered on the basis of GroupByValue +type TestResultHistoryForGroup struct { + // Display name of the group. + DisplayName *string `json:"displayName,omitempty"` + // Name or Id of the group identifier by which results are grouped together. + GroupByValue *string `json:"groupByValue,omitempty"` + // List of results for GroupByValue + Results *[]TestCaseResult `json:"results,omitempty"` +} + +// Represents a Meta Data of a test result. +type TestResultMetaData struct { + // AutomatedTestName of test result. + AutomatedTestName *string `json:"automatedTestName,omitempty"` + // AutomatedTestStorage of test result. + AutomatedTestStorage *string `json:"automatedTestStorage,omitempty"` + // List of Flaky Identifier for TestCaseReferenceId + FlakyIdentifiers *[]TestFlakyIdentifier `json:"flakyIdentifiers,omitempty"` + // Owner of test result. + Owner *string `json:"owner,omitempty"` + // Priority of test result. + Priority *int `json:"priority,omitempty"` + // ID of TestCaseReference. + TestCaseReferenceId *int `json:"testCaseReferenceId,omitempty"` + // TestCaseTitle of test result. + TestCaseTitle *string `json:"testCaseTitle,omitempty"` +} + +// Represents a TestResultMetaData Input +type TestResultMetaDataUpdateInput struct { + // List of Flaky Identifiers + FlakyIdentifiers *[]TestFlakyIdentifier `json:"flakyIdentifiers,omitempty"` +} + +type TestResultMetaDataUpdateResponse struct { + Status *string `json:"status,omitempty"` +} + +type TestResultModelBase struct { + // Comment in result. + Comment *string `json:"comment,omitempty"` + // Time when execution completed. + CompletedDate *azuredevops.Time `json:"completedDate,omitempty"` + // Duration of execution. + DurationInMs *float64 `json:"durationInMs,omitempty"` + // Error message in result. + ErrorMessage *string `json:"errorMessage,omitempty"` + // Test outcome of result. + Outcome *string `json:"outcome,omitempty"` + // Time when execution started. + StartedDate *azuredevops.Time `json:"startedDate,omitempty"` +} + +type TestResultParameter struct { + ActionPath *string `json:"actionPath,omitempty"` + Actual *[]byte `json:"actual,omitempty"` + Expected *[]byte `json:"expected,omitempty"` + IterationId *int `json:"iterationId,omitempty"` + ParameterName *string `json:"parameterName,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +// Test parameter information in a test iteration. +type TestResultParameterModel struct { + // Test step path where parameter is referenced. + ActionPath *string `json:"actionPath,omitempty"` + // Iteration ID. + IterationId *int `json:"iterationId,omitempty"` + // Name of parameter. + ParameterName *string `json:"parameterName,omitempty"` + // This is step Id of test case. For shared step, it is step Id of shared step in test case workitem; step Id in shared step. Example: TestCase workitem has two steps: 1) Normal step with Id = 1 2) Shared Step with Id = 2. Inside shared step: a) Normal Step with Id = 1 Value for StepIdentifier for First step: "1" Second step: "2;1" + StepIdentifier *string `json:"stepIdentifier,omitempty"` + // Url of test parameter. + Url *string `json:"url,omitempty"` + // Value of parameter. + Value *string `json:"value,omitempty"` +} + +type TestResultPayload struct { + Comment *string `json:"comment,omitempty"` + Name *string `json:"name,omitempty"` + Stream *string `json:"stream,omitempty"` +} + +type TestResultReset2 struct { + AuditIdentity *uuid.UUID `json:"auditIdentity,omitempty"` + DateModified *azuredevops.Time `json:"dateModified,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + Revision *int `json:"revision,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestResultRV *[]byte `json:"testResultRV,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type TestResultsContext struct { + Build *BuildReference `json:"build,omitempty"` + ContextType *TestResultsContextType `json:"contextType,omitempty"` + Release *ReleaseReference `json:"release,omitempty"` +} + +type TestResultsContextType string + +type testResultsContextTypeValuesType struct { + Build TestResultsContextType + Release TestResultsContextType +} + +var TestResultsContextTypeValues = testResultsContextTypeValuesType{ + Build: "build", + Release: "release", +} + +type TestResultsDetails struct { + GroupByField *string `json:"groupByField,omitempty"` + ResultsForGroup *[]TestResultsDetailsForGroup `json:"resultsForGroup,omitempty"` +} + +type TestResultsDetailsForGroup struct { + GroupByValue interface{} `json:"groupByValue,omitempty"` + Results *[]TestCaseResult `json:"results,omitempty"` + ResultsCountByOutcome *map[TestOutcome]AggregatedResultsByOutcome `json:"resultsCountByOutcome,omitempty"` + Tags *[]string `json:"tags,omitempty"` +} + +type TestResultsEx2 struct { + BitValue *bool `json:"bitValue,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + DateTimeValue *azuredevops.Time `json:"dateTimeValue,omitempty"` + FieldId *int `json:"fieldId,omitempty"` + FieldName *string `json:"fieldName,omitempty"` + FloatValue *float64 `json:"floatValue,omitempty"` + GuidValue *uuid.UUID `json:"guidValue,omitempty"` + IntValue *int `json:"intValue,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + StringValue *string `json:"stringValue,omitempty"` + TestResultId *int `json:"testResultId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type TestResultsGroupsForBuild struct { + // BuildId for which groupby result is fetched. + BuildId *int `json:"buildId,omitempty"` + // The group by results + Fields *[]FieldDetailsForTestResults `json:"fields,omitempty"` +} + +type TestResultsGroupsForRelease struct { + // The group by results + Fields *[]FieldDetailsForTestResults `json:"fields,omitempty"` + // Release Environment Id for which groupby result is fetched. + ReleaseEnvId *int `json:"releaseEnvId,omitempty"` + // ReleaseId for which groupby result is fetched. + ReleaseId *int `json:"releaseId,omitempty"` +} + +type TestResultsQuery struct { + Fields *[]string `json:"fields,omitempty"` + Results *[]TestCaseResult `json:"results,omitempty"` + ResultsFilter *ResultsFilter `json:"resultsFilter,omitempty"` +} + +type TestResultsSettings struct { + // IsRequired and EmitDefaultValue are passed as false as if users doesn't pass anything, should not come for serialisation and deserialisation. + FlakySettings *FlakySettings `json:"flakySettings,omitempty"` +} + +type TestResultsSettingsType string + +type testResultsSettingsTypeValuesType struct { + All TestResultsSettingsType + Flaky TestResultsSettingsType +} + +var TestResultsSettingsTypeValues = testResultsSettingsTypeValuesType{ + // Returns All Test Settings. + All: "all", + // Returns Flaky Test Settings. + Flaky: "flaky", +} + +type TestResultSummary struct { + AggregatedResultsAnalysis *AggregatedResultsAnalysis `json:"aggregatedResultsAnalysis,omitempty"` + NoConfigRunsCount *int `json:"noConfigRunsCount,omitempty"` + TeamProject *core.TeamProjectReference `json:"teamProject,omitempty"` + TestFailures *TestFailuresAnalysis `json:"testFailures,omitempty"` + TestResultsContext *TestResultsContext `json:"testResultsContext,omitempty"` + TotalRunsCount *int `json:"totalRunsCount,omitempty"` +} + +type TestResultsUpdateSettings struct { + // FlakySettings defines Flaky Settings Data. + FlakySettings *FlakySettings `json:"flakySettings,omitempty"` +} + +type TestResultsWithWatermark struct { + ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` + PointsResults *[]PointsResults2 `json:"pointsResults,omitempty"` + ResultId *int `json:"resultId,omitempty"` + RunId *int `json:"runId,omitempty"` +} + +type TestResultTrendFilter struct { + BranchNames *[]string `json:"branchNames,omitempty"` + BuildCount *int `json:"buildCount,omitempty"` + DefinitionIds *[]int `json:"definitionIds,omitempty"` + EnvDefinitionIds *[]int `json:"envDefinitionIds,omitempty"` + MaxCompleteDate *azuredevops.Time `json:"maxCompleteDate,omitempty"` + PublishContext *string `json:"publishContext,omitempty"` + TestRunTitles *[]string `json:"testRunTitles,omitempty"` + TrendDays *int `json:"trendDays,omitempty"` +} + +// Test run details. +type TestRun struct { + // Build associated with this test run. + Build *ShallowReference `json:"build,omitempty"` + // Build configuration details associated with this test run. + BuildConfiguration *BuildConfiguration `json:"buildConfiguration,omitempty"` + // Comments entered by those analyzing the run. + Comment *string `json:"comment,omitempty"` + // Completed date time of the run. + CompletedDate *azuredevops.Time `json:"completedDate,omitempty"` + // Test Run Controller. + Controller *string `json:"controller,omitempty"` + // Test Run CreatedDate. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // List of Custom Fields for TestRun. + CustomFields *[]CustomTestField `json:"customFields,omitempty"` + // Drop Location for the test Run. + DropLocation *string `json:"dropLocation,omitempty"` + DtlAutEnvironment *ShallowReference `json:"dtlAutEnvironment,omitempty"` + DtlEnvironment *ShallowReference `json:"dtlEnvironment,omitempty"` + DtlEnvironmentCreationDetails *DtlEnvironmentDetails `json:"dtlEnvironmentCreationDetails,omitempty"` + // Due date and time for test run. + DueDate *azuredevops.Time `json:"dueDate,omitempty"` + // Error message associated with the run. + ErrorMessage *string `json:"errorMessage,omitempty"` + Filter *RunFilter `json:"filter,omitempty"` + // ID of the test run. + Id *int `json:"id,omitempty"` + // Number of Incomplete Tests. + IncompleteTests *int `json:"incompleteTests,omitempty"` + // true if test run is automated, false otherwise. + IsAutomated *bool `json:"isAutomated,omitempty"` + // The iteration to which the run belongs. + Iteration *string `json:"iteration,omitempty"` + // Team foundation ID of the last updated the test run. + LastUpdatedBy *webapi.IdentityRef `json:"lastUpdatedBy,omitempty"` + // Last updated date and time + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Name of the test run. + Name *string `json:"name,omitempty"` + // Number of Not Applicable Tests. + NotApplicableTests *int `json:"notApplicableTests,omitempty"` + // Team Foundation ID of the owner of the runs. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Number of passed tests in the run + PassedTests *int `json:"passedTests,omitempty"` + // Phase/State for the testRun. + Phase *string `json:"phase,omitempty"` + // Reference of the pipeline to which this test run belongs. + PipelineReference *PipelineReference `json:"pipelineReference,omitempty"` + // Test plan associated with this test run. + Plan *ShallowReference `json:"plan,omitempty"` + // Post Process State. + PostProcessState *string `json:"postProcessState,omitempty"` + // Project associated with this run. + Project *ShallowReference `json:"project,omitempty"` + // Release Reference for the Test Run. + Release *ReleaseReference `json:"release,omitempty"` + // Release Environment Uri for TestRun. + ReleaseEnvironmentUri *string `json:"releaseEnvironmentUri,omitempty"` + // Release Uri for TestRun. + ReleaseUri *string `json:"releaseUri,omitempty"` + Revision *int `json:"revision,omitempty"` + // RunSummary by outcome. + RunStatistics *[]RunStatistic `json:"runStatistics,omitempty"` + // Start date time of the run. + StartedDate *azuredevops.Time `json:"startedDate,omitempty"` + // The state of the run. Type TestRunState Valid states - Unspecified ,NotStarted, InProgress, Completed, Waiting, Aborted, NeedsInvestigation + State *string `json:"state,omitempty"` + // TestRun Substate. + Substate *TestRunSubstate `json:"substate,omitempty"` + // Tags attached with this test run. + Tags *[]TestTag `json:"tags,omitempty"` + TestMessageLogId *int `json:"testMessageLogId,omitempty"` + TestSettings *ShallowReference `json:"testSettings,omitempty"` + // Total tests in the run + TotalTests *int `json:"totalTests,omitempty"` + // Number of failed tests in the run. + UnanalyzedTests *int `json:"unanalyzedTests,omitempty"` + // Url of the test run + Url *string `json:"url,omitempty"` + // Web Access Url for TestRun. + WebAccessUrl *string `json:"webAccessUrl,omitempty"` +} + +type TestRun2 struct { + BuildConfigurationId *int `json:"buildConfigurationId,omitempty"` + BuildNumber *string `json:"buildNumber,omitempty"` + Comment *string `json:"comment,omitempty"` + CompleteDate *azuredevops.Time `json:"completeDate,omitempty"` + Controller *string `json:"controller,omitempty"` + CoverageId *int `json:"coverageId,omitempty"` + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + DeletedOn *azuredevops.Time `json:"deletedOn,omitempty"` + DropLocation *string `json:"dropLocation,omitempty"` + DueDate *azuredevops.Time `json:"dueDate,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + IncompleteTests *int `json:"incompleteTests,omitempty"` + IsAutomated *bool `json:"isAutomated,omitempty"` + IsBvt *bool `json:"isBvt,omitempty"` + IsMigrated *bool `json:"isMigrated,omitempty"` + IterationId *int `json:"iterationId,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LastUpdatedBy *uuid.UUID `json:"lastUpdatedBy,omitempty"` + LegacySharePath *string `json:"legacySharePath,omitempty"` + MaxReservedResultId *int `json:"maxReservedResultId,omitempty"` + NotApplicableTests *int `json:"notApplicableTests,omitempty"` + Owner *uuid.UUID `json:"owner,omitempty"` + PassedTests *int `json:"passedTests,omitempty"` + PostProcessState *byte `json:"postProcessState,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + PublicTestSettingsId *int `json:"publicTestSettingsId,omitempty"` + ReleaseEnvironmentUri *string `json:"releaseEnvironmentUri,omitempty"` + ReleaseUri *string `json:"releaseUri,omitempty"` + Revision *int `json:"revision,omitempty"` + StartDate *azuredevops.Time `json:"startDate,omitempty"` + State *byte `json:"state,omitempty"` + TestEnvironmentId *uuid.UUID `json:"testEnvironmentId,omitempty"` + TestMessageLogId *int `json:"testMessageLogId,omitempty"` + TestPlanId *int `json:"testPlanId,omitempty"` + TestRunContextId *int `json:"testRunContextId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` + TestSettingsId *int `json:"testSettingsId,omitempty"` + Title *string `json:"title,omitempty"` + TotalTests *int `json:"totalTests,omitempty"` + Type *byte `json:"type,omitempty"` + UnanalyzedTests *int `json:"unanalyzedTests,omitempty"` + Version *int `json:"version,omitempty"` +} + +type TestRunCanceledEvent struct { + TestRun *TestRun `json:"testRun,omitempty"` +} + +type TestRunContext2 struct { + BuildRefId *int `json:"buildRefId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ReleaseRefId *int `json:"releaseRefId,omitempty"` + SourceWorkflow *string `json:"sourceWorkflow,omitempty"` + TestRunContextId *int `json:"testRunContextId,omitempty"` +} + +// Test Run Code Coverage Details +type TestRunCoverage struct { + // Last Error + LastError *string `json:"lastError,omitempty"` + // List of Modules Coverage + Modules *[]ModuleCoverage `json:"modules,omitempty"` + // State + State *string `json:"state,omitempty"` + // Reference of test Run. + TestRun *ShallowReference `json:"testRun,omitempty"` +} + +type TestRunCreatedEvent struct { + TestRun *TestRun `json:"testRun,omitempty"` +} + +type TestRunEvent struct { + TestRun *TestRun `json:"testRun,omitempty"` +} + +type TestRunEx2 struct { + BitValue *bool `json:"bitValue,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + DateTimeValue *azuredevops.Time `json:"dateTimeValue,omitempty"` + FieldId *int `json:"fieldId,omitempty"` + FieldName *string `json:"fieldName,omitempty"` + FloatValue *float64 `json:"floatValue,omitempty"` + GuidValue *uuid.UUID `json:"guidValue,omitempty"` + IntValue *int `json:"intValue,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + StringValue *string `json:"stringValue,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +type TestRunExtended2 struct { + AutEnvironmentUrl *string `json:"autEnvironmentUrl,omitempty"` + CsmContent *string `json:"csmContent,omitempty"` + CsmParameters *string `json:"csmParameters,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + SourceFilter *string `json:"sourceFilter,omitempty"` + SubscriptionName *string `json:"subscriptionName,omitempty"` + Substate *byte `json:"substate,omitempty"` + TestCaseFilter *string `json:"testCaseFilter,omitempty"` + TestEnvironmentUrl *string `json:"testEnvironmentUrl,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` +} + +// The types of outcomes for test run. +type TestRunOutcome string + +type testRunOutcomeValuesType struct { + Passed TestRunOutcome + Failed TestRunOutcome + NotImpacted TestRunOutcome + Others TestRunOutcome +} + +var TestRunOutcomeValues = testRunOutcomeValuesType{ + // Run with zero failed tests and has at least one impacted test + Passed: "passed", + // Run with at-least one failed test. + Failed: "failed", + // Run with no impacted tests. + NotImpacted: "notImpacted", + // Runs with All tests in other category. + Others: "others", +} + +// The types of publish context for run. +type TestRunPublishContext string + +type testRunPublishContextValuesType struct { + Build TestRunPublishContext + Release TestRunPublishContext + All TestRunPublishContext +} + +var TestRunPublishContextValues = testRunPublishContextValuesType{ + // Run is published for Build Context. + Build: "build", + // Run is published for Release Context. + Release: "release", + // Run is published for any Context. + All: "all", +} + +type TestRunStartedEvent struct { + TestRun *TestRun `json:"testRun,omitempty"` +} + +// The types of states for test run. +type TestRunState string + +type testRunStateValuesType struct { + Unspecified TestRunState + NotStarted TestRunState + InProgress TestRunState + Completed TestRunState + Aborted TestRunState + Waiting TestRunState + NeedsInvestigation TestRunState +} + +var TestRunStateValues = testRunStateValuesType{ + // Only used during an update to preserve the existing value. + Unspecified: "unspecified", + // The run is still being created. No tests have started yet. + NotStarted: "notStarted", + // Tests are running. + InProgress: "inProgress", + // All tests have completed or been skipped. + Completed: "completed", + // Run is stopped and remaining tests have been aborted + Aborted: "aborted", + // Run is currently initializing This is a legacy state and should not be used any more + Waiting: "waiting", + // Run requires investigation because of a test point failure This is a legacy state and should not be used any more + NeedsInvestigation: "needsInvestigation", +} + +// Test run statistics. +type TestRunStatistic struct { + Run *ShallowReference `json:"run,omitempty"` + RunStatistics *[]RunStatistic `json:"runStatistics,omitempty"` +} + +// The types of sub states for test run. It gives the user more info about the test run beyond the high level test run state +type TestRunSubstate string + +type testRunSubstateValuesType struct { + None TestRunSubstate + CreatingEnvironment TestRunSubstate + RunningTests TestRunSubstate + CanceledByUser TestRunSubstate + AbortedBySystem TestRunSubstate + TimedOut TestRunSubstate + PendingAnalysis TestRunSubstate + Analyzed TestRunSubstate + CancellationInProgress TestRunSubstate +} + +var TestRunSubstateValues = testRunSubstateValuesType{ + // Run with noState. + None: "none", + // Run state while Creating Environment. + CreatingEnvironment: "creatingEnvironment", + // Run state while Running Tests. + RunningTests: "runningTests", + // Run state while Creating Environment. + CanceledByUser: "canceledByUser", + // Run state when it is Aborted By the System. + AbortedBySystem: "abortedBySystem", + // Run state when run has timedOut. + TimedOut: "timedOut", + // Run state while Pending Analysis. + PendingAnalysis: "pendingAnalysis", + // Run state after being Analysed. + Analyzed: "analyzed", + // Run state when cancellation is in Progress. + CancellationInProgress: "cancellationInProgress", +} + +type TestRunSummary2 struct { + IsRerun *bool `json:"isRerun,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ResultCount *int `json:"resultCount,omitempty"` + ResultDuration *uint64 `json:"resultDuration,omitempty"` + RunDuration *uint64 `json:"runDuration,omitempty"` + TestOutcome *byte `json:"testOutcome,omitempty"` + TestRunCompletedDate *azuredevops.Time `json:"testRunCompletedDate,omitempty"` + TestRunContextId *int `json:"testRunContextId,omitempty"` + TestRunId *int `json:"testRunId,omitempty"` + TestRunStatsId *int `json:"testRunStatsId,omitempty"` +} + +type TestRunWithDtlEnvEvent struct { + TestRun *TestRun `json:"testRun,omitempty"` + ConfigurationIds *[]int `json:"configurationIds,omitempty"` + MappedTestRunEventType *string `json:"mappedTestRunEventType,omitempty"` + RunTimeout interface{} `json:"runTimeout,omitempty"` + TestConfigurationsMapping *string `json:"testConfigurationsMapping,omitempty"` +} + +// Test Session +type TestSession struct { + // Area path of the test session + Area *ShallowReference `json:"area,omitempty"` + // Comments in the test session + Comment *string `json:"comment,omitempty"` + // Duration of the session + EndDate *azuredevops.Time `json:"endDate,omitempty"` + // Id of the test session + Id *int `json:"id,omitempty"` + // Last Updated By Reference + LastUpdatedBy *webapi.IdentityRef `json:"lastUpdatedBy,omitempty"` + // Last updated date + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Owner of the test session + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Project to which the test session belongs + Project *ShallowReference `json:"project,omitempty"` + // Generic store for test session data + PropertyBag *PropertyBag `json:"propertyBag,omitempty"` + // Revision of the test session + Revision *int `json:"revision,omitempty"` + // Source of the test session + Source *TestSessionSource `json:"source,omitempty"` + // Start date + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // State of the test session + State *TestSessionState `json:"state,omitempty"` + // Title of the test session + Title *string `json:"title,omitempty"` + // Url of Test Session Resource + Url *string `json:"url,omitempty"` +} + +type TestSessionExploredWorkItemReference struct { + // Id of the workitem + Id *int `json:"id,omitempty"` + // Type of the workitem + Type *string `json:"type,omitempty"` + // Workitem references of workitems filed as a part of the current workitem exploration. + AssociatedWorkItems *[]TestSessionWorkItemReference `json:"associatedWorkItems,omitempty"` + // Time when exploration of workitem ended. + EndTime *azuredevops.Time `json:"endTime,omitempty"` + // Time when explore of workitem was started. + StartTime *azuredevops.Time `json:"startTime,omitempty"` +} + +// Represents the source from which the test session was created +type TestSessionSource string + +type testSessionSourceValuesType struct { + Unknown TestSessionSource + XtDesktop TestSessionSource + FeedbackDesktop TestSessionSource + XtWeb TestSessionSource + FeedbackWeb TestSessionSource + XtDesktop2 TestSessionSource + SessionInsightsForAll TestSessionSource +} + +var TestSessionSourceValues = testSessionSourceValuesType{ + // Source of test session uncertain as it is stale + Unknown: "unknown", + // The session was created from Microsoft Test Manager exploratory desktop tool. + XtDesktop: "xtDesktop", + // The session was created from feedback client. + FeedbackDesktop: "feedbackDesktop", + // The session was created from browser extension. + XtWeb: "xtWeb", + // The session was created from browser extension. + FeedbackWeb: "feedbackWeb", + // The session was created from web access using Microsoft Test Manager exploratory desktop tool. + XtDesktop2: "xtDesktop2", + // To show sessions from all supported sources. + SessionInsightsForAll: "sessionInsightsForAll", +} + +// Represents the state of the test session. +type TestSessionState string + +type testSessionStateValuesType struct { + Unspecified TestSessionState + NotStarted TestSessionState + InProgress TestSessionState + Paused TestSessionState + Completed TestSessionState + Declined TestSessionState +} + +var TestSessionStateValues = testSessionStateValuesType{ + // Only used during an update to preserve the existing value. + Unspecified: "unspecified", + // The session is still being created. + NotStarted: "notStarted", + // The session is running. + InProgress: "inProgress", + // The session has paused. + Paused: "paused", + // The session has completed. + Completed: "completed", + // This is required for Feedback session which are declined + Declined: "declined", +} + +type TestSessionWorkItemReference struct { + // Id of the workitem + Id *int `json:"id,omitempty"` + // Type of the workitem + Type *string `json:"type,omitempty"` +} + +// Represents the test settings of the run. Used to create test settings and fetch test settings +type TestSettings struct { + // Area path required to create test settings + AreaPath *string `json:"areaPath,omitempty"` + // Description of the test settings. Used in create test settings. + Description *string `json:"description,omitempty"` + // Indicates if the tests settings is public or private.Used in create test settings. + IsPublic *bool `json:"isPublic,omitempty"` + // Xml string of machine roles. Used in create test settings. + MachineRoles *string `json:"machineRoles,omitempty"` + // Test settings content. + TestSettingsContent *string `json:"testSettingsContent,omitempty"` + // Test settings id. + TestSettingsId *int `json:"testSettingsId,omitempty"` + // Test settings name. + TestSettingsName *string `json:"testSettingsName,omitempty"` +} + +// Represents the test settings of the run. Used to create test settings and fetch test settings +type TestSettings2 struct { + // Area path required to create test settings + AreaPath *string `json:"areaPath,omitempty"` + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Description of the test settings. Used in create test settings. + Description *string `json:"description,omitempty"` + // Indicates if the tests settings is public or private.Used in create test settings. + IsPublic *bool `json:"isPublic,omitempty"` + LastUpdatedBy *webapi.IdentityRef `json:"lastUpdatedBy,omitempty"` + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Xml string of machine roles. Used in create test settings. + MachineRoles *string `json:"machineRoles,omitempty"` + // Test settings content. + TestSettingsContent *string `json:"testSettingsContent,omitempty"` + // Test settings id. + TestSettingsId *int `json:"testSettingsId,omitempty"` + // Test settings name. + TestSettingsName *string `json:"testSettingsName,omitempty"` +} + +type TestSettingsMachineRole struct { + IsExecution *bool `json:"isExecution,omitempty"` + Name *string `json:"name,omitempty"` +} + +// Represents a sub result of a test result. +type TestSubResult struct { + // Comment in sub result. + Comment *string `json:"comment,omitempty"` + // Time when test execution completed. + CompletedDate *azuredevops.Time `json:"completedDate,omitempty"` + // Machine where test executed. + ComputerName *string `json:"computerName,omitempty"` + // Reference to test configuration. + Configuration *ShallowReference `json:"configuration,omitempty"` + // Additional properties of sub result. + CustomFields *[]CustomTestField `json:"customFields,omitempty"` + // Name of sub result. + DisplayName *string `json:"displayName,omitempty"` + // Duration of test execution. + DurationInMs *uint64 `json:"durationInMs,omitempty"` + // Error message in sub result. + ErrorMessage *string `json:"errorMessage,omitempty"` + // ID of sub result. + Id *int `json:"id,omitempty"` + // Time when result last updated. + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Outcome of sub result. + Outcome *string `json:"outcome,omitempty"` + // Immediate parent ID of sub result. + ParentId *int `json:"parentId,omitempty"` + // Hierarchy type of the result, default value of None means its leaf node. + ResultGroupType *ResultGroupType `json:"resultGroupType,omitempty"` + // Index number of sub result. + SequenceId *int `json:"sequenceId,omitempty"` + // Stacktrace. + StackTrace *string `json:"stackTrace,omitempty"` + // Time when test execution started. + StartedDate *azuredevops.Time `json:"startedDate,omitempty"` + // List of sub results inside a sub result, if ResultGroupType is not None, it holds corresponding type sub results. + SubResults *[]TestSubResult `json:"subResults,omitempty"` + // Reference to test result. + TestResult *TestCaseResultIdentifier `json:"testResult,omitempty"` + // Url of sub result. + Url *string `json:"url,omitempty"` +} + +// Test suite +type TestSuite struct { + // Area uri of the test suite. + AreaUri *string `json:"areaUri,omitempty"` + // Child test suites of current test suite. + Children *[]TestSuite `json:"children,omitempty"` + // Test suite default configuration. + DefaultConfigurations *[]ShallowReference `json:"defaultConfigurations,omitempty"` + // Test suite default testers. + DefaultTesters *[]ShallowReference `json:"defaultTesters,omitempty"` + // Id of test suite. + Id *int `json:"id,omitempty"` + // Default configuration was inherited or not. + InheritDefaultConfigurations *bool `json:"inheritDefaultConfigurations,omitempty"` + // Last error for test suite. + LastError *string `json:"lastError,omitempty"` + // Last populated date. + LastPopulatedDate *azuredevops.Time `json:"lastPopulatedDate,omitempty"` + // IdentityRef of user who has updated test suite recently. + LastUpdatedBy *webapi.IdentityRef `json:"lastUpdatedBy,omitempty"` + // Last update date. + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Name of test suite. + Name *string `json:"name,omitempty"` + // Test suite parent shallow reference. + Parent *ShallowReference `json:"parent,omitempty"` + // Test plan to which the test suite belongs. + Plan *ShallowReference `json:"plan,omitempty"` + // Test suite project shallow reference. + Project *ShallowReference `json:"project,omitempty"` + // Test suite query string, for dynamic suites. + QueryString *string `json:"queryString,omitempty"` + // Test suite requirement id. + RequirementId *int `json:"requirementId,omitempty"` + // Test suite revision. + Revision *int `json:"revision,omitempty"` + // State of test suite. + State *string `json:"state,omitempty"` + // List of shallow reference of suites. + Suites *[]ShallowReference `json:"suites,omitempty"` + // Test suite type. + SuiteType *string `json:"suiteType,omitempty"` + // Test cases count. + TestCaseCount *int `json:"testCaseCount,omitempty"` + // Test case url. + TestCasesUrl *string `json:"testCasesUrl,omitempty"` + // Used in tree view. If test suite is root suite then, it is name of plan otherwise title of the suite. + Text *string `json:"text,omitempty"` + // Url of test suite. + Url *string `json:"url,omitempty"` +} + +// Test suite clone request +type TestSuiteCloneRequest struct { + // Clone options for cloning the test suite. + CloneOptions *CloneOptions `json:"cloneOptions,omitempty"` + // Suite id under which, we have to clone the suite. + DestinationSuiteId *int `json:"destinationSuiteId,omitempty"` + // Destination suite project name. + DestinationSuiteProjectName *string `json:"destinationSuiteProjectName,omitempty"` +} + +type TestSummaryForWorkItem struct { + Summary *AggregatedDataForResultTrend `json:"summary,omitempty"` + WorkItem *WorkItemReference `json:"workItem,omitempty"` +} + +// Tag attached to a run or result. +type TestTag struct { + // Name of the tag, alphanumeric value less than 30 chars + Name *string `json:"name,omitempty"` +} + +// Test tag summary for build or release grouped by test run. +type TestTagSummary struct { + // Dictionary which contains tags associated with a test run. + TagsGroupByTestArtifact *map[int][]TestTag `json:"tagsGroupByTestArtifact,omitempty"` +} + +// Tags to update to a run or result. +type TestTagsUpdateModel struct { + Tags *[]azuredevops.KeyValuePair `json:"tags,omitempty"` +} + +type TestToWorkItemLinks struct { + Test *TestMethod `json:"test,omitempty"` + WorkItems *[]WorkItemReference `json:"workItems,omitempty"` +} + +type TestVariable struct { + // Description of the test variable + Description *string `json:"description,omitempty"` + // Id of the test variable + Id *int `json:"id,omitempty"` + // Name of the test variable + Name *string `json:"name,omitempty"` + // Project to which the test variable belongs + Project *ShallowReference `json:"project,omitempty"` + // Revision + Revision *int `json:"revision,omitempty"` + // Url of the test variable + Url *string `json:"url,omitempty"` + // List of allowed values + Values *[]string `json:"values,omitempty"` +} + +type UpdatedProperties struct { + Id *int `json:"id,omitempty"` + LastUpdated *azuredevops.Time `json:"lastUpdated,omitempty"` + LastUpdatedBy *uuid.UUID `json:"lastUpdatedBy,omitempty"` + LastUpdatedByName *string `json:"lastUpdatedByName,omitempty"` + Revision *int `json:"revision,omitempty"` +} + +type UpdateTestRunRequest struct { + AttachmentsToAdd *[]TestResultAttachment `json:"attachmentsToAdd,omitempty"` + AttachmentsToDelete *[]TestResultAttachmentIdentity `json:"attachmentsToDelete,omitempty"` + ProjectName *string `json:"projectName,omitempty"` + ShouldHyderate *bool `json:"shouldHyderate,omitempty"` + TestRun *LegacyTestRun `json:"testRun,omitempty"` +} + +type UpdateTestRunResponse struct { + AttachmentIds *[]int `json:"attachmentIds,omitempty"` + UpdatedProperties *UpdatedProperties `json:"updatedProperties,omitempty"` +} + +type UploadAttachmentsRequest struct { + Attachments *[]HttpPostedTcmAttachment `json:"attachments,omitempty"` + RequestParams *map[string]string `json:"requestParams,omitempty"` +} + +// WorkItem reference Details. +type WorkItemReference struct { + // WorkItem Id. + Id *string `json:"id,omitempty"` + // WorkItem Name. + Name *string `json:"name,omitempty"` + // WorkItem Type. + Type *string `json:"type,omitempty"` + // WorkItem Url. Valid Values : (Bug, Task, User Story, Test Case) + Url *string `json:"url,omitempty"` + // WorkItem WebUrl. + WebUrl *string `json:"webUrl,omitempty"` +} + +type WorkItemToTestLinks struct { + ExecutedIn *Service `json:"executedIn,omitempty"` + Tests *[]TestMethod `json:"tests,omitempty"` + WorkItem *WorkItemReference `json:"workItem,omitempty"` +} diff --git a/azuredevops/testplan/client.go b/azuredevops/testplan/client.go new file mode 100644 index 00000000..58693390 --- /dev/null +++ b/azuredevops/testplan/client.go @@ -0,0 +1,1562 @@ +// -------------------------------------------------------------------------------------------- +// 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 testplan + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" +) + +type Client interface { + // [Preview API] Add test cases to a suite with specified configurations + AddTestCasesToSuite(context.Context, AddTestCasesToSuiteArgs) (*[]TestCase, error) + // [Preview API] Clone test plan + CloneTestPlan(context.Context, CloneTestPlanArgs) (*CloneTestPlanOperationInformation, error) + // [Preview API] Clone test suite + CloneTestSuite(context.Context, CloneTestSuiteArgs) (*CloneTestSuiteOperationInformation, error) + // [Preview API] Create a test configuration. + CreateTestConfiguration(context.Context, CreateTestConfigurationArgs) (*TestConfiguration, error) + // [Preview API] Create a test plan. + CreateTestPlan(context.Context, CreateTestPlanArgs) (*TestPlan, error) + // [Preview API] Create test suite. + CreateTestSuite(context.Context, CreateTestSuiteArgs) (*TestSuite, error) + // [Preview API] Create a test variable. + CreateTestVariable(context.Context, CreateTestVariableArgs) (*TestVariable, error) + // [Preview API] Delete a test case. + DeleteTestCase(context.Context, DeleteTestCaseArgs) error + // [Preview API] Delete a test configuration by its ID. + DeleteTestConfguration(context.Context, DeleteTestConfgurationArgs) error + // [Preview API] Delete a test plan. + DeleteTestPlan(context.Context, DeleteTestPlanArgs) error + // [Preview API] Delete test suite. + DeleteTestSuite(context.Context, DeleteTestSuiteArgs) error + // [Preview API] Delete a test variable by its ID. + DeleteTestVariable(context.Context, DeleteTestVariableArgs) error + // [Preview API] Get clone information. + GetCloneInformation(context.Context, GetCloneInformationArgs) (*CloneTestPlanOperationInformation, error) + // [Preview API] Get a list of points based on point Ids provided. + GetPoints(context.Context, GetPointsArgs) (*[]TestPoint, error) + // [Preview API] Get all the points inside a suite based on some filters + GetPointsList(context.Context, GetPointsListArgs) (*GetPointsListResponseValue, error) + // [Preview API] Get clone information. + GetSuiteCloneInformation(context.Context, GetSuiteCloneInformationArgs) (*CloneTestSuiteOperationInformation, error) + // [Preview API] Get a list of test suite entries in the test suite. + GetSuiteEntries(context.Context, GetSuiteEntriesArgs) (*[]SuiteEntry, error) + // Find the list of all test suites in which a given test case is present. This is helpful if you need to find out which test suites are using a test case, when you need to make changes to a test case. + GetSuitesByTestCaseId(context.Context, GetSuitesByTestCaseIdArgs) (*[]TestSuite, error) + // [Preview API] Get Test Cases For a Suite. + GetTestCase(context.Context, GetTestCaseArgs) (*[]TestCase, error) + // [Preview API] Get Test Case List return those test cases which have all the configuration Ids as mentioned in the optional parameter. If configuration Ids is null, it return all the test cases + GetTestCaseList(context.Context, GetTestCaseListArgs) (*GetTestCaseListResponseValue, error) + // [Preview API] Get a test configuration + GetTestConfigurationById(context.Context, GetTestConfigurationByIdArgs) (*TestConfiguration, error) + // [Preview API] Get a list of test configurations. + GetTestConfigurations(context.Context, GetTestConfigurationsArgs) (*GetTestConfigurationsResponseValue, error) + // [Preview API] Get a test plan by Id. + GetTestPlanById(context.Context, GetTestPlanByIdArgs) (*TestPlan, error) + // [Preview API] Get a list of test plans + GetTestPlans(context.Context, GetTestPlansArgs) (*GetTestPlansResponseValue, error) + // [Preview API] Get test suite by suite id. + GetTestSuiteById(context.Context, GetTestSuiteByIdArgs) (*TestSuite, error) + // [Preview API] Get test suites for plan. + GetTestSuitesForPlan(context.Context, GetTestSuitesForPlanArgs) (*GetTestSuitesForPlanResponseValue, error) + // [Preview API] Get a test variable by its ID. + GetTestVariableById(context.Context, GetTestVariableByIdArgs) (*TestVariable, error) + // [Preview API] Get a list of test variables. + GetTestVariables(context.Context, GetTestVariablesArgs) (*GetTestVariablesResponseValue, error) + // [Preview API] Removes test cases from a suite based on the list of test case Ids provided. + RemoveTestCasesFromSuite(context.Context, RemoveTestCasesFromSuiteArgs) error + // [Preview API] Reorder test suite entries in the test suite. + ReorderSuiteEntries(context.Context, ReorderSuiteEntriesArgs) (*[]SuiteEntry, error) + // [Preview API] Update the configurations for test cases + UpdateSuiteTestCases(context.Context, UpdateSuiteTestCasesArgs) (*[]TestCase, error) + // [Preview API] Update a test configuration by its ID. + UpdateTestConfiguration(context.Context, UpdateTestConfigurationArgs) (*TestConfiguration, error) + // [Preview API] Update a test plan. + UpdateTestPlan(context.Context, UpdateTestPlanArgs) (*TestPlan, error) + // [Preview API] Update Test Points. This is used to Reset test point to active, update the outcome of a test point or update the tester of a test point + UpdateTestPoints(context.Context, UpdateTestPointsArgs) (*[]TestPoint, error) + // [Preview API] Update test suite. + UpdateTestSuite(context.Context, UpdateTestSuiteArgs) (*TestSuite, error) + // [Preview API] Update a test variable by its ID. + UpdateTestVariable(context.Context, UpdateTestVariableArgs) (*TestVariable, 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, + } +} + +// [Preview API] Add test cases to a suite with specified configurations +func (client *ClientImpl) AddTestCasesToSuite(ctx context.Context, args AddTestCasesToSuiteArgs) (*[]TestCase, error) { + if args.SuiteTestCaseCreateUpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteTestCaseCreateUpdateParameters"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + + body, marshalErr := json.Marshal(*args.SuiteTestCaseCreateUpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a9bd61ac-45cf-4d13-9441-43dcd01edf8d") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []TestCase + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddTestCasesToSuite function +type AddTestCasesToSuiteArgs struct { + // (required) SuiteTestCaseCreateUpdateParameters object. + SuiteTestCaseCreateUpdateParameters *[]SuiteTestCaseCreateUpdateParameters + // (required) Project ID or project name + Project *string + // (required) ID of the test plan to which test cases are to be added. + PlanId *int + // (required) ID of the test suite to which test cases are to be added. + SuiteId *int +} + +// [Preview API] Clone test plan +func (client *ClientImpl) CloneTestPlan(ctx context.Context, args CloneTestPlanArgs) (*CloneTestPlanOperationInformation, error) { + if args.CloneRequestBody == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CloneRequestBody"} + } + 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.DeepClone != nil { + queryParams.Add("deepClone", strconv.FormatBool(*args.DeepClone)) + } + body, marshalErr := json.Marshal(*args.CloneRequestBody) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e65df662-d8a3-46c7-ae1c-14e2d4df57e1") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue CloneTestPlanOperationInformation + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CloneTestPlan function +type CloneTestPlanArgs struct { + // (required) Plan Clone Request Body detail TestPlanCloneRequest + CloneRequestBody *CloneTestPlanParams + // (required) Project ID or project name + Project *string + // (optional) Clones all the associated test cases as well + DeepClone *bool +} + +// [Preview API] Clone test suite +func (client *ClientImpl) CloneTestSuite(ctx context.Context, args CloneTestSuiteArgs) (*CloneTestSuiteOperationInformation, error) { + if args.CloneRequestBody == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CloneRequestBody"} + } + 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.DeepClone != nil { + queryParams.Add("deepClone", strconv.FormatBool(*args.DeepClone)) + } + body, marshalErr := json.Marshal(*args.CloneRequestBody) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("181d4c97-0e98-4ee2-ad6a-4cada675e555") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue CloneTestSuiteOperationInformation + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CloneTestSuite function +type CloneTestSuiteArgs struct { + // (required) Suite Clone Request Body detail TestSuiteCloneRequest + CloneRequestBody *CloneTestSuiteParams + // (required) Project ID or project name + Project *string + // (optional) Clones all the associated test cases as well + DeepClone *bool +} + +// [Preview API] Create a test configuration. +func (client *ClientImpl) CreateTestConfiguration(ctx context.Context, args CreateTestConfigurationArgs) (*TestConfiguration, error) { + if args.TestConfigurationCreateUpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestConfigurationCreateUpdateParameters"} + } + 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.TestConfigurationCreateUpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("8369318e-38fa-4e84-9043-4b2a75d2c256") + 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 TestConfiguration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestConfiguration function +type CreateTestConfigurationArgs struct { + // (required) TestConfigurationCreateUpdateParameters + TestConfigurationCreateUpdateParameters *TestConfigurationCreateUpdateParameters + // (required) Project ID or project name + Project *string +} + +// [Preview API] Create a test plan. +func (client *ClientImpl) CreateTestPlan(ctx context.Context, args CreateTestPlanArgs) (*TestPlan, error) { + if args.TestPlanCreateParams == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestPlanCreateParams"} + } + 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.TestPlanCreateParams) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("0e292477-a0c2-47f3-a9b6-34f153d627f4") + 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 TestPlan + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestPlan function +type CreateTestPlanArgs struct { + // (required) A testPlanCreateParams object.TestPlanCreateParams + TestPlanCreateParams *TestPlanCreateParams + // (required) Project ID or project name + Project *string +} + +// [Preview API] Create test suite. +func (client *ClientImpl) CreateTestSuite(ctx context.Context, args CreateTestSuiteArgs) (*TestSuite, error) { + if args.TestSuiteCreateParams == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestSuiteCreateParams"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + + body, marshalErr := json.Marshal(*args.TestSuiteCreateParams) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1046d5d3-ab61-4ca7-a65a-36118a978256") + 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 TestSuite + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestSuite function +type CreateTestSuiteArgs struct { + // (required) Parameters for suite creation + TestSuiteCreateParams *TestSuiteCreateParams + // (required) Project ID or project name + Project *string + // (required) ID of the test plan that contains the suites. + PlanId *int +} + +// [Preview API] Create a test variable. +func (client *ClientImpl) CreateTestVariable(ctx context.Context, args CreateTestVariableArgs) (*TestVariable, error) { + if args.TestVariableCreateUpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestVariableCreateUpdateParameters"} + } + 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.TestVariableCreateUpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2c61fac6-ac4e-45a5-8c38-1c2b8fd8ea6c") + 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 TestVariable + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestVariable function +type CreateTestVariableArgs struct { + // (required) TestVariableCreateUpdateParameters + TestVariableCreateUpdateParameters *TestVariableCreateUpdateParameters + // (required) Project ID or project name + Project *string +} + +// [Preview API] Delete a test case. +func (client *ClientImpl) DeleteTestCase(ctx context.Context, args DeleteTestCaseArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.TestCaseId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseId"} + } + routeValues["testCaseId"] = strconv.Itoa(*args.TestCaseId) + + locationId, _ := uuid.Parse("29006fb5-816b-4ff7-a329-599943569229") + _, 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 DeleteTestCase function +type DeleteTestCaseArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of test case to be deleted. + TestCaseId *int +} + +// [Preview API] Delete a test configuration by its ID. +func (client *ClientImpl) DeleteTestConfguration(ctx context.Context, args DeleteTestConfgurationArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.TestConfiguartionId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "testConfiguartionId"} + } + queryParams.Add("testConfiguartionId", strconv.Itoa(*args.TestConfiguartionId)) + locationId, _ := uuid.Parse("8369318e-38fa-4e84-9043-4b2a75d2c256") + _, 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 DeleteTestConfguration function +type DeleteTestConfgurationArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test configuration to delete. + TestConfiguartionId *int +} + +// [Preview API] Delete a test plan. +func (client *ClientImpl) DeleteTestPlan(ctx context.Context, args DeleteTestPlanArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + + locationId, _ := uuid.Parse("0e292477-a0c2-47f3-a9b6-34f153d627f4") + _, 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 DeleteTestPlan function +type DeleteTestPlanArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan to be deleted. + PlanId *int +} + +// [Preview API] Delete test suite. +func (client *ClientImpl) DeleteTestSuite(ctx context.Context, args DeleteTestSuiteArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + + locationId, _ := uuid.Parse("1046d5d3-ab61-4ca7-a65a-36118a978256") + _, 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 DeleteTestSuite function +type DeleteTestSuiteArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan that contains the suite. + PlanId *int + // (required) ID of the test suite to delete. + SuiteId *int +} + +// [Preview API] Delete a test variable by its ID. +func (client *ClientImpl) DeleteTestVariable(ctx context.Context, args DeleteTestVariableArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.TestVariableId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.TestVariableId"} + } + routeValues["testVariableId"] = strconv.Itoa(*args.TestVariableId) + + locationId, _ := uuid.Parse("2c61fac6-ac4e-45a5-8c38-1c2b8fd8ea6c") + _, 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 DeleteTestVariable function +type DeleteTestVariableArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test variable to delete. + TestVariableId *int +} + +// [Preview API] Get clone information. +func (client *ClientImpl) GetCloneInformation(ctx context.Context, args GetCloneInformationArgs) (*CloneTestPlanOperationInformation, 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.CloneOperationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CloneOperationId"} + } + routeValues["cloneOperationId"] = strconv.Itoa(*args.CloneOperationId) + + locationId, _ := uuid.Parse("e65df662-d8a3-46c7-ae1c-14e2d4df57e1") + 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 CloneTestPlanOperationInformation + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCloneInformation function +type GetCloneInformationArgs struct { + // (required) Project ID or project name + Project *string + // (required) Operation ID returned when we queue a clone operation + CloneOperationId *int +} + +// [Preview API] Get a list of points based on point Ids provided. +func (client *ClientImpl) GetPoints(ctx context.Context, args GetPointsArgs) (*[]TestPoint, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + if args.PointIds == nil || *args.PointIds == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PointIds"} + } + routeValues["pointIds"] = *args.PointIds + + queryParams := url.Values{} + if args.ReturnIdentityRef != nil { + queryParams.Add("returnIdentityRef", strconv.FormatBool(*args.ReturnIdentityRef)) + } + locationId, _ := uuid.Parse("52df686e-bae4-4334-b0ee-b6cf4e6f6b73") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []TestPoint + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPoints function +type GetPointsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan for which test points are requested. + PlanId *int + // (required) ID of the test suite for which test points are requested. + SuiteId *int + // (required) ID of test points to be fetched. + PointIds *string + // (optional) If set to true, returns the AssignedTo field in TestCaseReference as IdentityRef object. + ReturnIdentityRef *bool +} + +// [Preview API] Get all the points inside a suite based on some filters +func (client *ClientImpl) GetPointsList(ctx context.Context, args GetPointsListArgs) (*GetPointsListResponseValue, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + + queryParams := url.Values{} + if args.TestPointIds != nil { + queryParams.Add("testPointIds", *args.TestPointIds) + } + if args.TestCaseId != nil { + queryParams.Add("testCaseId", *args.TestCaseId) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.ReturnIdentityRef != nil { + queryParams.Add("returnIdentityRef", strconv.FormatBool(*args.ReturnIdentityRef)) + } + if args.IncludePointDetails != nil { + queryParams.Add("includePointDetails", strconv.FormatBool(*args.IncludePointDetails)) + } + locationId, _ := uuid.Parse("52df686e-bae4-4334-b0ee-b6cf4e6f6b73") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GetPointsListResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetPointsList function +type GetPointsListArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan for which test points are requested. + PlanId *int + // (required) ID of the test suite for which test points are requested + SuiteId *int + // (optional) ID of test points to fetch. + TestPointIds *string + // (optional) Get Test Points for specific test case Ids. + TestCaseId *string + // (optional) If the list of test point returned is not complete, a continuation token to query next batch of test points is included in the response header as "x-ms-continuationtoken". Omit this parameter to get the first batch of test points. + ContinuationToken *string + // (optional) If set to true, returns the AssignedTo field in TestCaseReference as IdentityRef object. + ReturnIdentityRef *bool + // (optional) If set to false, returns only necessary information + IncludePointDetails *bool +} + +// Return type for the GetPointsList function +type GetPointsListResponseValue struct { + Value []TestPoint + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get clone information. +func (client *ClientImpl) GetSuiteCloneInformation(ctx context.Context, args GetSuiteCloneInformationArgs) (*CloneTestSuiteOperationInformation, 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.CloneOperationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CloneOperationId"} + } + routeValues["cloneOperationId"] = strconv.Itoa(*args.CloneOperationId) + + locationId, _ := uuid.Parse("181d4c97-0e98-4ee2-ad6a-4cada675e555") + 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 CloneTestSuiteOperationInformation + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSuiteCloneInformation function +type GetSuiteCloneInformationArgs struct { + // (required) Project ID or project name + Project *string + // (required) Operation ID returned when we queue a clone operation + CloneOperationId *int +} + +// [Preview API] Get a list of test suite entries in the test suite. +func (client *ClientImpl) GetSuiteEntries(ctx context.Context, args GetSuiteEntriesArgs) (*[]SuiteEntry, 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.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + + queryParams := url.Values{} + if args.SuiteEntryType != nil { + queryParams.Add("suiteEntryType", string(*args.SuiteEntryType)) + } + locationId, _ := uuid.Parse("d6733edf-72f1-4252-925b-c560dfe9b75a") + 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 []SuiteEntry + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSuiteEntries function +type GetSuiteEntriesArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the parent suite. + SuiteId *int + // (optional) + SuiteEntryType *SuiteEntryTypes +} + +// Find the list of all test suites in which a given test case is present. This is helpful if you need to find out which test suites are using a test case, when you need to make changes to a test case. +func (client *ClientImpl) GetSuitesByTestCaseId(ctx context.Context, args GetSuitesByTestCaseIdArgs) (*[]TestSuite, error) { + queryParams := url.Values{} + if args.TestCaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testCaseId"} + } + queryParams.Add("testCaseId", strconv.Itoa(*args.TestCaseId)) + locationId, _ := uuid.Parse("a4080e84-f17b-4fad-84f1-7960b6525bf2") + 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 []TestSuite + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetSuitesByTestCaseId function +type GetSuitesByTestCaseIdArgs struct { + // (required) ID of the test case for which suites need to be fetched. + TestCaseId *int +} + +// [Preview API] Get Test Cases For a Suite. +func (client *ClientImpl) GetTestCase(ctx context.Context, args GetTestCaseArgs) (*[]TestCase, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + if args.TestCaseIds == nil || *args.TestCaseIds == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestCaseIds"} + } + routeValues["testCaseIds"] = *args.TestCaseIds + + queryParams := url.Values{} + if args.WitFields != nil { + queryParams.Add("witFields", *args.WitFields) + } + if args.ReturnIdentityRef != nil { + queryParams.Add("returnIdentityRef", strconv.FormatBool(*args.ReturnIdentityRef)) + } + locationId, _ := uuid.Parse("a9bd61ac-45cf-4d13-9441-43dcd01edf8d") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []TestCase + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestCase function +type GetTestCaseArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan for which test cases are requested. + PlanId *int + // (required) ID of the test suite for which test cases are requested. + SuiteId *int + // (required) Test Case Ids to be fetched. + TestCaseIds *string + // (optional) Get the list of witFields. + WitFields *string + // (optional) If set to true, returns all identity fields, like AssignedTo, ActivatedBy etc., as IdentityRef objects. If set to false, these fields are returned as unique names in string format. This is false by default. + ReturnIdentityRef *bool +} + +// [Preview API] Get Test Case List return those test cases which have all the configuration Ids as mentioned in the optional parameter. If configuration Ids is null, it return all the test cases +func (client *ClientImpl) GetTestCaseList(ctx context.Context, args GetTestCaseListArgs) (*GetTestCaseListResponseValue, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + + queryParams := url.Values{} + if args.TestIds != nil { + queryParams.Add("testIds", *args.TestIds) + } + if args.ConfigurationIds != nil { + queryParams.Add("configurationIds", *args.ConfigurationIds) + } + if args.WitFields != nil { + queryParams.Add("witFields", *args.WitFields) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.ReturnIdentityRef != nil { + queryParams.Add("returnIdentityRef", strconv.FormatBool(*args.ReturnIdentityRef)) + } + if args.Expand != nil { + queryParams.Add("expand", strconv.FormatBool(*args.Expand)) + } + locationId, _ := uuid.Parse("a9bd61ac-45cf-4d13-9441-43dcd01edf8d") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GetTestCaseListResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetTestCaseList function +type GetTestCaseListArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan for which test cases are requested. + PlanId *int + // (required) ID of the test suite for which test cases are requested. + SuiteId *int + // (optional) Test Case Ids to be fetched. + TestIds *string + // (optional) Fetch Test Cases which contains all the configuration Ids specified. + ConfigurationIds *string + // (optional) Get the list of witFields. + WitFields *string + // (optional) If the list of test cases returned is not complete, a continuation token to query next batch of test cases is included in the response header as "x-ms-continuationtoken". Omit this parameter to get the first batch of test cases. + ContinuationToken *string + // (optional) If set to true, returns all identity fields, like AssignedTo, ActivatedBy etc., as IdentityRef objects. If set to false, these fields are returned as unique names in string format. This is false by default. + ReturnIdentityRef *bool + // (optional) If set to false, will get a smaller payload containing only basic details about the suite test case object + Expand *bool +} + +// Return type for the GetTestCaseList function +type GetTestCaseListResponseValue struct { + Value []TestCase + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get a test configuration +func (client *ClientImpl) GetTestConfigurationById(ctx context.Context, args GetTestConfigurationByIdArgs) (*TestConfiguration, 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.TestConfigurationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestConfigurationId"} + } + routeValues["testConfigurationId"] = strconv.Itoa(*args.TestConfigurationId) + + locationId, _ := uuid.Parse("8369318e-38fa-4e84-9043-4b2a75d2c256") + 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 TestConfiguration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestConfigurationById function +type GetTestConfigurationByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test configuration to get. + TestConfigurationId *int +} + +// [Preview API] Get a list of test configurations. +func (client *ClientImpl) GetTestConfigurations(ctx context.Context, args GetTestConfigurationsArgs) (*GetTestConfigurationsResponseValue, 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.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("8369318e-38fa-4e84-9043-4b2a75d2c256") + 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 GetTestConfigurationsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetTestConfigurations function +type GetTestConfigurationsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) If the list of configurations returned is not complete, a continuation token to query next batch of configurations is included in the response header as "x-ms-continuationtoken". Omit this parameter to get the first batch of test configurations. + ContinuationToken *string +} + +// Return type for the GetTestConfigurations function +type GetTestConfigurationsResponseValue struct { + Value []TestConfiguration + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get a test plan by Id. +func (client *ClientImpl) GetTestPlanById(ctx context.Context, args GetTestPlanByIdArgs) (*TestPlan, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + + locationId, _ := uuid.Parse("0e292477-a0c2-47f3-a9b6-34f153d627f4") + 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 TestPlan + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestPlanById function +type GetTestPlanByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan to get. + PlanId *int +} + +// [Preview API] Get a list of test plans +func (client *ClientImpl) GetTestPlans(ctx context.Context, args GetTestPlansArgs) (*GetTestPlansResponseValue, 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.Owner != nil { + queryParams.Add("owner", *args.Owner) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.IncludePlanDetails != nil { + queryParams.Add("includePlanDetails", strconv.FormatBool(*args.IncludePlanDetails)) + } + if args.FilterActivePlans != nil { + queryParams.Add("filterActivePlans", strconv.FormatBool(*args.FilterActivePlans)) + } + locationId, _ := uuid.Parse("0e292477-a0c2-47f3-a9b6-34f153d627f4") + 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 GetTestPlansResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetTestPlans function +type GetTestPlansArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Filter for test plan by owner ID or name + Owner *string + // (optional) If the list of plans returned is not complete, a continuation token to query next batch of plans is included in the response header as "x-ms-continuationtoken". Omit this parameter to get the first batch of test plans. + ContinuationToken *string + // (optional) Get all properties of the test plan + IncludePlanDetails *bool + // (optional) Get just the active plans + FilterActivePlans *bool +} + +// Return type for the GetTestPlans function +type GetTestPlansResponseValue struct { + Value []TestPlan + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get test suite by suite id. +func (client *ClientImpl) GetTestSuiteById(ctx context.Context, args GetTestSuiteByIdArgs) (*TestSuite, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("1046d5d3-ab61-4ca7-a65a-36118a978256") + 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 TestSuite + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestSuiteById function +type GetTestSuiteByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan that contains the suites. + PlanId *int + // (required) ID of the suite to get. + SuiteId *int + // (optional) Include the children suites and testers details + Expand *SuiteExpand +} + +// [Preview API] Get test suites for plan. +func (client *ClientImpl) GetTestSuitesForPlan(ctx context.Context, args GetTestSuitesForPlanArgs) (*GetTestSuitesForPlanResponseValue, 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.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("expand", string(*args.Expand)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.AsTreeView != nil { + queryParams.Add("asTreeView", strconv.FormatBool(*args.AsTreeView)) + } + locationId, _ := uuid.Parse("1046d5d3-ab61-4ca7-a65a-36118a978256") + 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 GetTestSuitesForPlanResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetTestSuitesForPlan function +type GetTestSuitesForPlanArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan for which suites are requested. + PlanId *int + // (optional) Include the children suites and testers details. + Expand *SuiteExpand + // (optional) If the list of suites returned is not complete, a continuation token to query next batch of suites is included in the response header as "x-ms-continuationtoken". Omit this parameter to get the first batch of test suites. + ContinuationToken *string + // (optional) If the suites returned should be in a tree structure. + AsTreeView *bool +} + +// Return type for the GetTestSuitesForPlan function +type GetTestSuitesForPlanResponseValue struct { + Value []TestSuite + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get a test variable by its ID. +func (client *ClientImpl) GetTestVariableById(ctx context.Context, args GetTestVariableByIdArgs) (*TestVariable, 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.TestVariableId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestVariableId"} + } + routeValues["testVariableId"] = strconv.Itoa(*args.TestVariableId) + + locationId, _ := uuid.Parse("2c61fac6-ac4e-45a5-8c38-1c2b8fd8ea6c") + 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 TestVariable + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestVariableById function +type GetTestVariableByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test variable to get. + TestVariableId *int +} + +// [Preview API] Get a list of test variables. +func (client *ClientImpl) GetTestVariables(ctx context.Context, args GetTestVariablesArgs) (*GetTestVariablesResponseValue, 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.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("2c61fac6-ac4e-45a5-8c38-1c2b8fd8ea6c") + 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 GetTestVariablesResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetTestVariables function +type GetTestVariablesArgs struct { + // (required) Project ID or project name + Project *string + // (optional) If the list of variables returned is not complete, a continuation token to query next batch of variables is included in the response header as "x-ms-continuationtoken". Omit this parameter to get the first batch of test variables. + ContinuationToken *string +} + +// Return type for the GetTestVariables function +type GetTestVariablesResponseValue struct { + Value []TestVariable + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Removes test cases from a suite based on the list of test case Ids provided. +func (client *ClientImpl) RemoveTestCasesFromSuite(ctx context.Context, args RemoveTestCasesFromSuiteArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + if args.TestCaseIds == nil || *args.TestCaseIds == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.TestCaseIds"} + } + routeValues["testCaseIds"] = *args.TestCaseIds + + locationId, _ := uuid.Parse("a9bd61ac-45cf-4d13-9441-43dcd01edf8d") + _, 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 RemoveTestCasesFromSuite function +type RemoveTestCasesFromSuiteArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the test plan from which test cases are to be removed. + PlanId *int + // (required) ID of the test suite from which test cases are to be removed. + SuiteId *int + // (required) Test Case Ids to be removed. + TestCaseIds *string +} + +// [Preview API] Reorder test suite entries in the test suite. +func (client *ClientImpl) ReorderSuiteEntries(ctx context.Context, args ReorderSuiteEntriesArgs) (*[]SuiteEntry, error) { + if args.SuiteEntries == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteEntries"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + + body, marshalErr := json.Marshal(*args.SuiteEntries) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d6733edf-72f1-4252-925b-c560dfe9b75a") + 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 []SuiteEntry + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReorderSuiteEntries function +type ReorderSuiteEntriesArgs struct { + // (required) List of SuiteEntry to reorder. + SuiteEntries *[]SuiteEntryUpdateParams + // (required) Project ID or project name + Project *string + // (required) Id of the parent test suite. + SuiteId *int +} + +// [Preview API] Update the configurations for test cases +func (client *ClientImpl) UpdateSuiteTestCases(ctx context.Context, args UpdateSuiteTestCasesArgs) (*[]TestCase, error) { + if args.SuiteTestCaseCreateUpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteTestCaseCreateUpdateParameters"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + + body, marshalErr := json.Marshal(*args.SuiteTestCaseCreateUpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a9bd61ac-45cf-4d13-9441-43dcd01edf8d") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []TestCase + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateSuiteTestCases function +type UpdateSuiteTestCasesArgs struct { + // (required) A SuiteTestCaseCreateUpdateParameters object. + SuiteTestCaseCreateUpdateParameters *[]SuiteTestCaseCreateUpdateParameters + // (required) Project ID or project name + Project *string + // (required) ID of the test plan to which test cases are to be updated. + PlanId *int + // (required) ID of the test suite to which test cases are to be updated. + SuiteId *int +} + +// [Preview API] Update a test configuration by its ID. +func (client *ClientImpl) UpdateTestConfiguration(ctx context.Context, args UpdateTestConfigurationArgs) (*TestConfiguration, error) { + if args.TestConfigurationCreateUpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestConfigurationCreateUpdateParameters"} + } + 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.TestConfiguartionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testConfiguartionId"} + } + queryParams.Add("testConfiguartionId", strconv.Itoa(*args.TestConfiguartionId)) + body, marshalErr := json.Marshal(*args.TestConfigurationCreateUpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("8369318e-38fa-4e84-9043-4b2a75d2c256") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue TestConfiguration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestConfiguration function +type UpdateTestConfigurationArgs struct { + // (required) TestConfigurationCreateUpdateParameters + TestConfigurationCreateUpdateParameters *TestConfigurationCreateUpdateParameters + // (required) Project ID or project name + Project *string + // (required) ID of the test configuration to update. + TestConfiguartionId *int +} + +// [Preview API] Update a test plan. +func (client *ClientImpl) UpdateTestPlan(ctx context.Context, args UpdateTestPlanArgs) (*TestPlan, error) { + if args.TestPlanUpdateParams == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestPlanUpdateParams"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + + body, marshalErr := json.Marshal(*args.TestPlanUpdateParams) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("0e292477-a0c2-47f3-a9b6-34f153d627f4") + 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 TestPlan + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestPlan function +type UpdateTestPlanArgs struct { + // (required) A testPlanUpdateParams object.TestPlanUpdateParams + TestPlanUpdateParams *TestPlanUpdateParams + // (required) Project ID or project name + Project *string + // (required) ID of the test plan to be updated. + PlanId *int +} + +// [Preview API] Update Test Points. This is used to Reset test point to active, update the outcome of a test point or update the tester of a test point +func (client *ClientImpl) UpdateTestPoints(ctx context.Context, args UpdateTestPointsArgs) (*[]TestPoint, error) { + if args.TestPointUpdateParams == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestPointUpdateParams"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + + body, marshalErr := json.Marshal(*args.TestPointUpdateParams) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("52df686e-bae4-4334-b0ee-b6cf4e6f6b73") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []TestPoint + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestPoints function +type UpdateTestPointsArgs struct { + // (required) A TestPointUpdateParams Object. + TestPointUpdateParams *[]TestPointUpdateParams + // (required) Project ID or project name + Project *string + // (required) ID of the test plan for which test points are requested. + PlanId *int + // (required) ID of the test suite for which test points are requested. + SuiteId *int +} + +// [Preview API] Update test suite. +func (client *ClientImpl) UpdateTestSuite(ctx context.Context, args UpdateTestSuiteArgs) (*TestSuite, error) { + if args.TestSuiteUpdateParams == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestSuiteUpdateParams"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = strconv.Itoa(*args.PlanId) + if args.SuiteId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SuiteId"} + } + routeValues["suiteId"] = strconv.Itoa(*args.SuiteId) + + body, marshalErr := json.Marshal(*args.TestSuiteUpdateParams) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1046d5d3-ab61-4ca7-a65a-36118a978256") + 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 TestSuite + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestSuite function +type UpdateTestSuiteArgs struct { + // (required) Parameters for suite updation + TestSuiteUpdateParams *TestSuiteUpdateParams + // (required) Project ID or project name + Project *string + // (required) ID of the test plan that contains the suites. + PlanId *int + // (required) ID of the parent suite. + SuiteId *int +} + +// [Preview API] Update a test variable by its ID. +func (client *ClientImpl) UpdateTestVariable(ctx context.Context, args UpdateTestVariableArgs) (*TestVariable, error) { + if args.TestVariableCreateUpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestVariableCreateUpdateParameters"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.TestVariableId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestVariableId"} + } + routeValues["testVariableId"] = strconv.Itoa(*args.TestVariableId) + + body, marshalErr := json.Marshal(*args.TestVariableCreateUpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2c61fac6-ac4e-45a5-8c38-1c2b8fd8ea6c") + 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 TestVariable + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestVariable function +type UpdateTestVariableArgs struct { + // (required) TestVariableCreateUpdateParameters + TestVariableCreateUpdateParameters *TestVariableCreateUpdateParameters + // (required) Project ID or project name + Project *string + // (required) ID of the test variable to update. + TestVariableId *int +} diff --git a/azuredevops/testplan/models.go b/azuredevops/testplan/models.go new file mode 100644 index 00000000..b0e5459b --- /dev/null +++ b/azuredevops/testplan/models.go @@ -0,0 +1,881 @@ +// -------------------------------------------------------------------------------------------- +// 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 testplan + +import ( + "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/test" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +// The build definition reference resource +type BuildDefinitionReference struct { + // ID of the build definition + Id *int `json:"id,omitempty"` + // Name of the build definition + Name *string `json:"name,omitempty"` +} + +// Common Response for clone operation +type CloneOperationCommonResponse struct { + // Various statistics related to the clone operation + CloneStatistics *test.CloneStatistics `json:"cloneStatistics,omitempty"` + // Completion data of the operation + CompletionDate *azuredevops.Time `json:"completionDate,omitempty"` + // Creation data of the operation + CreationDate *azuredevops.Time `json:"creationDate,omitempty"` + // Reference links + Links interface{} `json:"links,omitempty"` + // Message related to the job + Message *string `json:"message,omitempty"` + // Clone operation Id + OpId *int `json:"opId,omitempty"` + // Clone operation state + State *test.CloneOperationState `json:"state,omitempty"` +} + +// Response for Test Plan clone operation +type CloneTestPlanOperationInformation struct { + // Various information related to the clone + CloneOperationResponse *CloneOperationCommonResponse `json:"cloneOperationResponse,omitempty"` + // Test Plan Clone create parameters + CloneOptions *test.CloneOptions `json:"cloneOptions,omitempty"` + // Information of destination Test Plan + DestinationTestPlan *TestPlan `json:"destinationTestPlan,omitempty"` + // Information of source Test Plan + SourceTestPlan *SourceTestplanResponse `json:"sourceTestPlan,omitempty"` +} + +// Parameters for Test Plan clone operation +type CloneTestPlanParams struct { + // Test Plan Clone create parameters + CloneOptions *test.CloneOptions `json:"cloneOptions,omitempty"` + // Information about destination Test Plan + DestinationTestPlan *DestinationTestPlanCloneParams `json:"destinationTestPlan,omitempty"` + // Information about source Test Plan + SourceTestPlan *SourceTestPlanInfo `json:"sourceTestPlan,omitempty"` +} + +// Response for Test Suite clone operation +type CloneTestSuiteOperationInformation struct { + // Information of newly cloned Test Suite + ClonedTestSuite *TestSuiteReferenceWithProject `json:"clonedTestSuite,omitempty"` + // Various information related to the clone + CloneOperationResponse *CloneOperationCommonResponse `json:"cloneOperationResponse,omitempty"` + // Test Plan Clone create parameters + CloneOptions *test.CloneOptions `json:"cloneOptions,omitempty"` + // Information of destination Test Suite + DestinationTestSuite *TestSuiteReferenceWithProject `json:"destinationTestSuite,omitempty"` + // Information of source Test Suite + SourceTestSuite *TestSuiteReferenceWithProject `json:"sourceTestSuite,omitempty"` +} + +// Parameters for Test Suite clone operation +type CloneTestSuiteParams struct { + // Test Plan Clone create parameters + CloneOptions *test.CloneOptions `json:"cloneOptions,omitempty"` + // Information about destination Test Suite + DestinationTestSuite *DestinationTestSuiteInfo `json:"destinationTestSuite,omitempty"` + // Information about source Test Suite + SourceTestSuite *SourceTestSuiteInfo `json:"sourceTestSuite,omitempty"` +} + +// Configuration of the Test Point +type Configuration struct { + // Id of the Configuration Assigned to the Test Point + ConfigurationId *int `json:"configurationId,omitempty"` +} + +// Destination Test Plan create parameters +type DestinationTestPlanCloneParams struct { + // Area of the test plan. + AreaPath *string `json:"areaPath,omitempty"` + // The Build Definition that generates a build associated with this test plan. + BuildDefinition *BuildDefinitionReference `json:"buildDefinition,omitempty"` + // Build to be tested. + BuildId *int `json:"buildId,omitempty"` + // Description of the test plan. + Description *string `json:"description,omitempty"` + // End date for the test plan. + EndDate *azuredevops.Time `json:"endDate,omitempty"` + // Iteration path of the test plan. + Iteration *string `json:"iteration,omitempty"` + // Name of the test plan. + Name *string `json:"name,omitempty"` + // Owner of the test plan. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Release Environment to be used to deploy the build and run automated tests from this test plan. + ReleaseEnvironmentDefinition *test.ReleaseEnvironmentDefinitionReference `json:"releaseEnvironmentDefinition,omitempty"` + // Start date for the test plan. + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // State of the test plan. + State *string `json:"state,omitempty"` + // Value to configure how same tests across test suites under a test plan need to behave + TestOutcomeSettings *test.TestOutcomeSettings `json:"testOutcomeSettings,omitempty"` + // Destination Project Name + Project *string `json:"project,omitempty"` +} + +// Destination Test Suite information for Test Suite clone operation +type DestinationTestSuiteInfo struct { + // Destination Suite Id + Id *int `json:"id,omitempty"` + // Destination Project Name + Project *string `json:"project,omitempty"` +} + +type FailureType string + +type failureTypeValuesType struct { + None FailureType + Regression FailureType + New_Issue FailureType + Known_Issue FailureType + Unknown FailureType + Null_Value FailureType + MaxValue FailureType +} + +var FailureTypeValues = failureTypeValuesType{ + None: "none", + Regression: "regression", + New_Issue: "new_Issue", + Known_Issue: "known_Issue", + Unknown: "unknown", + Null_Value: "null_Value", + MaxValue: "maxValue", +} + +type LastResolutionState string + +type lastResolutionStateValuesType struct { + None LastResolutionState + NeedsInvestigation LastResolutionState + TestIssue LastResolutionState + ProductIssue LastResolutionState + ConfigurationIssue LastResolutionState + NullValue LastResolutionState + MaxValue LastResolutionState +} + +var LastResolutionStateValues = lastResolutionStateValuesType{ + None: "none", + NeedsInvestigation: "needsInvestigation", + TestIssue: "testIssue", + ProductIssue: "productIssue", + ConfigurationIssue: "configurationIssue", + NullValue: "nullValue", + MaxValue: "maxValue", +} + +type Outcome string + +type outcomeValuesType struct { + Unspecified Outcome + None Outcome + Passed Outcome + Failed Outcome + Inconclusive Outcome + Timeout Outcome + Aborted Outcome + Blocked Outcome + NotExecuted Outcome + Warning Outcome + Error Outcome + NotApplicable Outcome + Paused Outcome + InProgress Outcome + NotImpacted Outcome + MaxValue Outcome +} + +var OutcomeValues = outcomeValuesType{ + // Only used during an update to preserve the existing value. + Unspecified: "unspecified", + // Test has not been completed, or the test type does not report pass/failure. + None: "none", + // Test was executed w/o any issues. + Passed: "passed", + // Test was executed, but there were issues. Issues may involve exceptions or failed assertions. + Failed: "failed", + // Test has completed, but we can't say if it passed or failed. May be used for aborted tests... + Inconclusive: "inconclusive", + // The test timed out + Timeout: "timeout", + // Test was aborted. This was not caused by a user gesture, but rather by a framework decision. + Aborted: "aborted", + // Test had it chance for been executed but was not, as ITestElement.IsRunnable == false. + Blocked: "blocked", + // Test was not executed. This was caused by a user gesture - e.g. user hit stop button. + NotExecuted: "notExecuted", + // To be used by Run level results. This is not a failure. + Warning: "warning", + // There was a system error while we were trying to execute a test. + Error: "error", + // Test is Not Applicable for execution. + NotApplicable: "notApplicable", + // Test is paused. + Paused: "paused", + // Test is currently executing. Added this for TCM charts + InProgress: "inProgress", + // Test is not impacted. Added fot TIA. + NotImpacted: "notImpacted", + MaxValue: "maxValue", +} + +// Assignments for the Test Point +type PointAssignment struct { + // Id of the Configuration Assigned to the Test Point + ConfigurationId *int `json:"configurationId,omitempty"` + // Name of the Configuration Assigned to the Test Point + ConfigurationName *string `json:"configurationName,omitempty"` + // Id of the Test Point + Id *int `json:"id,omitempty"` + // Tester Assigned to the Test Point + Tester *webapi.IdentityRef `json:"tester,omitempty"` +} + +type PointState string + +type pointStateValuesType struct { + None PointState + Ready PointState + Completed PointState + NotReady PointState + InProgress PointState + MaxValue PointState +} + +var PointStateValues = pointStateValuesType{ + // Default + None: "none", + // The test point needs to be executed in order for the test pass to be considered complete. Either the test has not been run before or the previous run failed. + Ready: "ready", + // The test has passed successfully and does not need to be re-run for the test pass to be considered complete. + Completed: "completed", + // The test point needs to be executed but is not able to. + NotReady: "notReady", + // The test is being executed. + InProgress: "inProgress", + MaxValue: "maxValue", +} + +// Results class for Test Point +type Results struct { + // Outcome of the Test Point + Outcome *Outcome `json:"outcome,omitempty"` +} + +type ResultState string + +type resultStateValuesType struct { + Unspecified ResultState + Pending ResultState + Queued ResultState + InProgress ResultState + Paused ResultState + Completed ResultState + MaxValue ResultState +} + +var ResultStateValues = resultStateValuesType{ + // Only used during an update to preserve the existing value. + Unspecified: "unspecified", + // Test is in the execution queue, was not started yet. + Pending: "pending", + // Test has been queued. This is applicable when a test case is queued for execution + Queued: "queued", + // Test is currently executing. + InProgress: "inProgress", + // Test has been paused. This is applicable when a test case is paused by the user (For e.g. Manual Tester can pause the execution of the manual test case) + Paused: "paused", + // Test has completed, but there is no quantitative measure of completeness. This may apply to load tests. + Completed: "completed", + MaxValue: "maxValue", +} + +// Source Test Plan information for Test Plan clone operation +type SourceTestPlanInfo struct { + // ID of the source Test Plan + Id *int `json:"id,omitempty"` + // Id of suites to be cloned inside source Test Plan + SuiteIds *[]int `json:"suiteIds,omitempty"` +} + +// Source Test Plan Response for Test Plan clone operation +type SourceTestplanResponse struct { + // ID of the test plan. + Id *int `json:"id,omitempty"` + // Name of the test plan. + Name *string `json:"name,omitempty"` + // project reference + Project *core.TeamProjectReference `json:"project,omitempty"` + // Id of suites to be cloned inside source Test Plan + SuiteIds *[]int `json:"suiteIds,omitempty"` +} + +// Source Test Suite information for Test Suite clone operation +type SourceTestSuiteInfo struct { + // Id of the Source Test Suite + Id *int `json:"id,omitempty"` +} + +// A suite entry defines properties for a test suite. +type SuiteEntry struct { + // Id of the suite entry in the test suite: either a test case id or child suite id. + Id *int `json:"id,omitempty"` + // Sequence number for the suite entry object in the test suite. + SequenceNumber *int `json:"sequenceNumber,omitempty"` + // Defines whether the entry is of type test case or suite. + SuiteEntryType *SuiteEntryTypes `json:"suiteEntryType,omitempty"` + // Id for the test suite. + SuiteId *int `json:"suiteId,omitempty"` +} + +type SuiteEntryTypes string + +type suiteEntryTypesValuesType struct { + TestCase SuiteEntryTypes + Suite SuiteEntryTypes +} + +var SuiteEntryTypesValues = suiteEntryTypesValuesType{ + // Test Case + TestCase: "testCase", + // Child Suite + Suite: "suite", +} + +// A suite entry defines properties for a test suite. +type SuiteEntryUpdateParams struct { + // Id of the suite entry in the test suite: either a test case id or child suite id. + Id *int `json:"id,omitempty"` + // Sequence number for the suite entry object in the test suite. + SequenceNumber *int `json:"sequenceNumber,omitempty"` + // Defines whether the entry is of type test case or suite. + SuiteEntryType *SuiteEntryTypes `json:"suiteEntryType,omitempty"` +} + +// [Flags] Option to get details in response +type SuiteExpand string + +type suiteExpandValuesType struct { + None SuiteExpand + Children SuiteExpand + DefaultTesters SuiteExpand +} + +var SuiteExpandValues = suiteExpandValuesType{ + // Dont include any of the expansions in output. + None: "none", + // Include children in response. + Children: "children", + // Include default testers in response. + DefaultTesters: "defaultTesters", +} + +// Create and Update Suite Test Case Parameters +type SuiteTestCaseCreateUpdateParameters struct { + // Configurations Ids + PointAssignments *[]Configuration `json:"pointAssignments,omitempty"` + // Id of Test Case to be updated or created + WorkItem *WorkItem `json:"workItem,omitempty"` +} + +// Test Case Class +type TestCase struct { + // Reference links + Links interface{} `json:"links,omitempty"` + // Order of the TestCase in the Suite + Order *int `json:"order,omitempty"` + // List of Points associated with the Test Case + PointAssignments *[]PointAssignment `json:"pointAssignments,omitempty"` + // Project under which the Test Case is + Project *core.TeamProjectReference `json:"project,omitempty"` + // Test Plan under which the Test Case is + TestPlan *TestPlanReference `json:"testPlan,omitempty"` + // Test Suite under which the Test Case is + TestSuite *TestSuiteReference `json:"testSuite,omitempty"` + // Work Item details of the TestCase + WorkItem *WorkItemDetails `json:"workItem,omitempty"` +} + +// Test Case Reference +type TestCaseReference struct { + // Identity to whom the test case is assigned + AssignedTo *webapi.IdentityRef `json:"assignedTo,omitempty"` + // Test Case Id + Id *int `json:"id,omitempty"` + // Test Case Name + Name *string `json:"name,omitempty"` + // State of the test case work item + State *string `json:"state,omitempty"` +} + +// Test configuration +type TestConfiguration struct { + // Description of the configuration + Description *string `json:"description,omitempty"` + // Is the configuration a default for the test plans + IsDefault *bool `json:"isDefault,omitempty"` + // Name of the configuration + Name *string `json:"name,omitempty"` + // State of the configuration + State *test.TestConfigurationState `json:"state,omitempty"` + // Dictionary of Test Variable, Selected Value + Values *[]test.NameValuePair `json:"values,omitempty"` + // Id of the configuration + Id *int `json:"id,omitempty"` + // Id of the test configuration variable + Project *core.TeamProjectReference `json:"project,omitempty"` +} + +// Test Configuration Create or Update Parameters +type TestConfigurationCreateUpdateParameters struct { + // Description of the configuration + Description *string `json:"description,omitempty"` + // Is the configuration a default for the test plans + IsDefault *bool `json:"isDefault,omitempty"` + // Name of the configuration + Name *string `json:"name,omitempty"` + // State of the configuration + State *test.TestConfigurationState `json:"state,omitempty"` + // Dictionary of Test Variable, Selected Value + Values *[]test.NameValuePair `json:"values,omitempty"` +} + +// Test Configuration Reference +type TestConfigurationReference struct { + // Id of the configuration + Id *int `json:"id,omitempty"` + // Name of the configuration + Name *string `json:"name,omitempty"` +} + +// The test plan resource. +type TestPlan struct { + // Area of the test plan. + AreaPath *string `json:"areaPath,omitempty"` + // The Build Definition that generates a build associated with this test plan. + BuildDefinition *BuildDefinitionReference `json:"buildDefinition,omitempty"` + // Build to be tested. + BuildId *int `json:"buildId,omitempty"` + // Description of the test plan. + Description *string `json:"description,omitempty"` + // End date for the test plan. + EndDate *azuredevops.Time `json:"endDate,omitempty"` + // Iteration path of the test plan. + Iteration *string `json:"iteration,omitempty"` + // Name of the test plan. + Name *string `json:"name,omitempty"` + // Owner of the test plan. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Release Environment to be used to deploy the build and run automated tests from this test plan. + ReleaseEnvironmentDefinition *test.ReleaseEnvironmentDefinitionReference `json:"releaseEnvironmentDefinition,omitempty"` + // Start date for the test plan. + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // State of the test plan. + State *string `json:"state,omitempty"` + // Value to configure how same tests across test suites under a test plan need to behave + TestOutcomeSettings *test.TestOutcomeSettings `json:"testOutcomeSettings,omitempty"` + // Revision of the test plan. + Revision *int `json:"revision,omitempty"` + // Relevant links + Links interface{} `json:"_links,omitempty"` + // ID of the test plan. + Id *int `json:"id,omitempty"` + // Previous build Id associated with the test plan + PreviousBuildId *int `json:"previousBuildId,omitempty"` + // Project which contains the test plan. + Project *core.TeamProjectReference `json:"project,omitempty"` + // Root test suite of the test plan. + RootSuite *TestSuiteReference `json:"rootSuite,omitempty"` + // Identity Reference for the last update of the test plan + UpdatedBy *webapi.IdentityRef `json:"updatedBy,omitempty"` + // Updated date of the test plan + UpdatedDate *azuredevops.Time `json:"updatedDate,omitempty"` +} + +// The test plan create parameters. +type TestPlanCreateParams struct { + // Area of the test plan. + AreaPath *string `json:"areaPath,omitempty"` + // The Build Definition that generates a build associated with this test plan. + BuildDefinition *BuildDefinitionReference `json:"buildDefinition,omitempty"` + // Build to be tested. + BuildId *int `json:"buildId,omitempty"` + // Description of the test plan. + Description *string `json:"description,omitempty"` + // End date for the test plan. + EndDate *azuredevops.Time `json:"endDate,omitempty"` + // Iteration path of the test plan. + Iteration *string `json:"iteration,omitempty"` + // Name of the test plan. + Name *string `json:"name,omitempty"` + // Owner of the test plan. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Release Environment to be used to deploy the build and run automated tests from this test plan. + ReleaseEnvironmentDefinition *test.ReleaseEnvironmentDefinitionReference `json:"releaseEnvironmentDefinition,omitempty"` + // Start date for the test plan. + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // State of the test plan. + State *string `json:"state,omitempty"` + // Value to configure how same tests across test suites under a test plan need to behave + TestOutcomeSettings *test.TestOutcomeSettings `json:"testOutcomeSettings,omitempty"` +} + +// The test plan detailed reference resource. Contains additional workitem realted information +type TestPlanDetailedReference struct { + // ID of the test plan. + Id *int `json:"id,omitempty"` + // Name of the test plan. + Name *string `json:"name,omitempty"` + // Area of the test plan. + AreaPath *string `json:"areaPath,omitempty"` + // End date for the test plan. + EndDate *azuredevops.Time `json:"endDate,omitempty"` + // Iteration path of the test plan. + Iteration *string `json:"iteration,omitempty"` + // Root Suite Id + RootSuiteId *int `json:"rootSuiteId,omitempty"` + // Start date for the test plan. + StartDate *azuredevops.Time `json:"startDate,omitempty"` +} + +// The test plan reference resource. +type TestPlanReference struct { + // ID of the test plan. + Id *int `json:"id,omitempty"` + // Name of the test plan. + Name *string `json:"name,omitempty"` +} + +// This data model is used in TestPlansHubRefreshDataProvider and populates the data required for initial page load +type TestPlansHubRefreshData struct { + IsAdvancedExtensionEnabled *bool `json:"isAdvancedExtensionEnabled,omitempty"` + SelectedSuiteId *int `json:"selectedSuiteId,omitempty"` + SelectedSuiteName *string `json:"selectedSuiteName,omitempty"` + TestCasePageSize *int `json:"testCasePageSize,omitempty"` + TestCases *[]TestCase `json:"testCases,omitempty"` + TestCasesContinuationToken *string `json:"testCasesContinuationToken,omitempty"` + TestPlan *TestPlanDetailedReference `json:"testPlan,omitempty"` + TestPointPageSize *int `json:"testPointPageSize,omitempty"` + TestPoints *[]TestPoint `json:"testPoints,omitempty"` + TestPointsContinuationToken *string `json:"testPointsContinuationToken,omitempty"` + TestSuites *[]TestSuite `json:"testSuites,omitempty"` + TestSuitesContinuationToken *string `json:"testSuitesContinuationToken,omitempty"` +} + +// The test plan update parameters. +type TestPlanUpdateParams struct { + // Area of the test plan. + AreaPath *string `json:"areaPath,omitempty"` + // The Build Definition that generates a build associated with this test plan. + BuildDefinition *BuildDefinitionReference `json:"buildDefinition,omitempty"` + // Build to be tested. + BuildId *int `json:"buildId,omitempty"` + // Description of the test plan. + Description *string `json:"description,omitempty"` + // End date for the test plan. + EndDate *azuredevops.Time `json:"endDate,omitempty"` + // Iteration path of the test plan. + Iteration *string `json:"iteration,omitempty"` + // Name of the test plan. + Name *string `json:"name,omitempty"` + // Owner of the test plan. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Release Environment to be used to deploy the build and run automated tests from this test plan. + ReleaseEnvironmentDefinition *test.ReleaseEnvironmentDefinitionReference `json:"releaseEnvironmentDefinition,omitempty"` + // Start date for the test plan. + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // State of the test plan. + State *string `json:"state,omitempty"` + // Value to configure how same tests across test suites under a test plan need to behave + TestOutcomeSettings *test.TestOutcomeSettings `json:"testOutcomeSettings,omitempty"` + // Revision of the test plan. + Revision *int `json:"revision,omitempty"` +} + +// Test Point Class +type TestPoint struct { + // Comment associated to the Test Point + Comment *string `json:"comment,omitempty"` + // Configuration associated with the Test Point + Configuration *TestConfigurationReference `json:"configuration,omitempty"` + // Id of the Test Point + Id *int `json:"id,omitempty"` + // Variable to decide whether the test case is Active or not + IsActive *bool `json:"isActive,omitempty"` + // Is the Test Point for Automated Test Case or Manual + IsAutomated *bool `json:"isAutomated,omitempty"` + // Last Reset to Active Time Stamp for the Test Point + LastResetToActive *azuredevops.Time `json:"lastResetToActive,omitempty"` + // Last Updated details for the Test Point + LastUpdatedBy *webapi.IdentityRef `json:"lastUpdatedBy,omitempty"` + // Last Update Time Stamp for the Test Point + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Reference links + Links interface{} `json:"links,omitempty"` + // Project under which the Test Point is + Project *core.TeamProjectReference `json:"project,omitempty"` + // Results associated to the Test Point + Results *TestPointResults `json:"results,omitempty"` + // Test Case Reference + TestCaseReference *TestCaseReference `json:"testCaseReference,omitempty"` + // Tester associated with the Test Point + Tester *webapi.IdentityRef `json:"tester,omitempty"` + // Test Plan under which the Test Point is + TestPlan *TestPlanReference `json:"testPlan,omitempty"` + // Test Suite under which the Test Point is + TestSuite *TestSuiteReference `json:"testSuite,omitempty"` +} + +// Test Point Count +type TestPointCount struct { + // Test Point Count + Count *int `json:"count,omitempty"` + // Test Plan under which the Test Points are + TestPlanId *int `json:"testPlanId,omitempty"` + // Test Suite under which the Test Points are + TestSuiteId *int `json:"testSuiteId,omitempty"` +} + +// Test Point Results +type TestPointResults struct { + // Failure Type for the Test Point + FailureType *FailureType `json:"failureType,omitempty"` + // Last Resolution State Id for the TEst Point + LastResolutionState *LastResolutionState `json:"lastResolutionState,omitempty"` + // Last Result Details for the Test Point + LastResultDetails *test.LastResultDetails `json:"lastResultDetails,omitempty"` + // Last Result Id + LastResultId *int `json:"lastResultId,omitempty"` + // Last Result State of the Test Point + LastResultState *ResultState `json:"lastResultState,omitempty"` + // Last RUn Build Number for the Test Point + LastRunBuildNumber *string `json:"lastRunBuildNumber,omitempty"` + // Last Test Run Id for the Test Point + LastTestRunId *int `json:"lastTestRunId,omitempty"` + // Outcome of the Test Point + Outcome *Outcome `json:"outcome,omitempty"` + // State of the Test Point + State *PointState `json:"state,omitempty"` +} + +// Test Point Update Parameters +type TestPointUpdateParams struct { + // Id of Test Point to be updated + Id *int `json:"id,omitempty"` + // Reset the Test Point to Active + IsActive *bool `json:"isActive,omitempty"` + // Results of the test point + Results *Results `json:"results,omitempty"` + // Tester of the Test Point + Tester *webapi.IdentityRef `json:"tester,omitempty"` +} + +// Test suite +type TestSuite struct { + // Test suite default configurations. + DefaultConfigurations *[]TestConfigurationReference `json:"defaultConfigurations,omitempty"` + // Test suite default testers. + DefaultTesters *[]webapi.IdentityRef `json:"defaultTesters,omitempty"` + // Default configuration was inherited or not. + InheritDefaultConfigurations *bool `json:"inheritDefaultConfigurations,omitempty"` + // Name of test suite. + Name *string `json:"name,omitempty"` + // Test suite parent shallow reference. + ParentSuite *TestSuiteReference `json:"parentSuite,omitempty"` + // Test suite query string, for dynamic suites. + QueryString *string `json:"queryString,omitempty"` + // Test suite requirement id. + RequirementId *int `json:"requirementId,omitempty"` + // Test suite type. + SuiteType *TestSuiteType `json:"suiteType,omitempty"` + // Links: self, testPoints, testCases, parent + Links interface{} `json:"_links,omitempty"` + // Child test suites of current test suite. + Children *[]TestSuite `json:"children,omitempty"` + // Boolean value dictating if Child test suites are present + HasChildren *bool `json:"hasChildren,omitempty"` + // Id of test suite. + Id *int `json:"id,omitempty"` + // Last error for test suite. + LastError *string `json:"lastError,omitempty"` + // Last populated date. + LastPopulatedDate *azuredevops.Time `json:"lastPopulatedDate,omitempty"` + // IdentityRef of user who has updated test suite recently. + LastUpdatedBy *webapi.IdentityRef `json:"lastUpdatedBy,omitempty"` + // Last update date. + LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"` + // Test plan to which the test suite belongs. + Plan *TestPlanReference `json:"plan,omitempty"` + // Test suite project shallow reference. + Project *core.TeamProjectReference `json:"project,omitempty"` + // Test suite revision. + Revision *int `json:"revision,omitempty"` +} + +// Test suite Create Parameters +type TestSuiteCreateParams struct { + // Test suite default configurations. + DefaultConfigurations *[]TestConfigurationReference `json:"defaultConfigurations,omitempty"` + // Test suite default testers. + DefaultTesters *[]webapi.IdentityRef `json:"defaultTesters,omitempty"` + // Default configuration was inherited or not. + InheritDefaultConfigurations *bool `json:"inheritDefaultConfigurations,omitempty"` + // Name of test suite. + Name *string `json:"name,omitempty"` + // Test suite parent shallow reference. + ParentSuite *TestSuiteReference `json:"parentSuite,omitempty"` + // Test suite query string, for dynamic suites. + QueryString *string `json:"queryString,omitempty"` + // Test suite requirement id. + RequirementId *int `json:"requirementId,omitempty"` + // Test suite type. + SuiteType *TestSuiteType `json:"suiteType,omitempty"` +} + +// Test Suite Create/Update Common Parameters +type TestSuiteCreateUpdateCommonParams struct { + // Test suite default configurations. + DefaultConfigurations *[]TestConfigurationReference `json:"defaultConfigurations,omitempty"` + // Test suite default testers. + DefaultTesters *[]webapi.IdentityRef `json:"defaultTesters,omitempty"` + // Default configuration was inherited or not. + InheritDefaultConfigurations *bool `json:"inheritDefaultConfigurations,omitempty"` + // Name of test suite. + Name *string `json:"name,omitempty"` + // Test suite parent shallow reference. + ParentSuite *TestSuiteReference `json:"parentSuite,omitempty"` + // Test suite query string, for dynamic suites. + QueryString *string `json:"queryString,omitempty"` +} + +// The test suite reference resource. +type TestSuiteReference struct { + // ID of the test suite. + Id *int `json:"id,omitempty"` + // Name of the test suite. + Name *string `json:"name,omitempty"` +} + +// Test Suite Reference with Project +type TestSuiteReferenceWithProject struct { + // ID of the test suite. + Id *int `json:"id,omitempty"` + // Name of the test suite. + Name *string `json:"name,omitempty"` + // Reference of destination Project + Project *core.TeamProjectReference `json:"project,omitempty"` +} + +// Type of TestSuite +type TestSuiteType string + +type testSuiteTypeValuesType struct { + None TestSuiteType + DynamicTestSuite TestSuiteType + StaticTestSuite TestSuiteType + RequirementTestSuite TestSuiteType +} + +var TestSuiteTypeValues = testSuiteTypeValuesType{ + // Default suite type + None: "none", + // Query Based test Suite + DynamicTestSuite: "dynamicTestSuite", + // Static Test Suite + StaticTestSuite: "staticTestSuite", + // Requirement based Test Suite + RequirementTestSuite: "requirementTestSuite", +} + +// Test Suite Update Parameters +type TestSuiteUpdateParams struct { + // Test suite default configurations. + DefaultConfigurations *[]TestConfigurationReference `json:"defaultConfigurations,omitempty"` + // Test suite default testers. + DefaultTesters *[]webapi.IdentityRef `json:"defaultTesters,omitempty"` + // Default configuration was inherited or not. + InheritDefaultConfigurations *bool `json:"inheritDefaultConfigurations,omitempty"` + // Name of test suite. + Name *string `json:"name,omitempty"` + // Test suite parent shallow reference. + ParentSuite *TestSuiteReference `json:"parentSuite,omitempty"` + // Test suite query string, for dynamic suites. + QueryString *string `json:"queryString,omitempty"` + // Test suite revision. + Revision *int `json:"revision,omitempty"` +} + +// Test Variable +type TestVariable struct { + // Description of the test variable + Description *string `json:"description,omitempty"` + // Name of the test variable + Name *string `json:"name,omitempty"` + // List of allowed values + Values *[]string `json:"values,omitempty"` + // Id of the test variable + Id *int `json:"id,omitempty"` + // Id of the test variable + Project *core.TeamProjectReference `json:"project,omitempty"` +} + +// Test Variable Create or Update Parameters +type TestVariableCreateUpdateParameters struct { + // Description of the test variable + Description *string `json:"description,omitempty"` + // Name of the test variable + Name *string `json:"name,omitempty"` + // List of allowed values + Values *[]string `json:"values,omitempty"` +} + +type UserFriendlyTestOutcome string + +type userFriendlyTestOutcomeValuesType struct { + InProgress UserFriendlyTestOutcome + Blocked UserFriendlyTestOutcome + Failed UserFriendlyTestOutcome + Passed UserFriendlyTestOutcome + Ready UserFriendlyTestOutcome + NotApplicable UserFriendlyTestOutcome + Paused UserFriendlyTestOutcome + MaxValue UserFriendlyTestOutcome +} + +var UserFriendlyTestOutcomeValues = userFriendlyTestOutcomeValuesType{ + InProgress: "inProgress", + Blocked: "blocked", + Failed: "failed", + Passed: "passed", + Ready: "ready", + NotApplicable: "notApplicable", + Paused: "paused", + MaxValue: "maxValue", +} + +// Work Item +type WorkItem struct { + // Id of the Work Item + Id *int `json:"id,omitempty"` +} + +// Work Item Class +type WorkItemDetails struct { + // Work Item Id + Id *int `json:"id,omitempty"` + // Work Item Name + Name *string `json:"name,omitempty"` + // Work Item Fields + WorkItemFields *[]interface{} `json:"workItemFields,omitempty"` +} diff --git a/azuredevops/testresults/client.go b/azuredevops/testresults/client.go new file mode 100644 index 00000000..7c3321f9 --- /dev/null +++ b/azuredevops/testresults/client.go @@ -0,0 +1,3102 @@ +// -------------------------------------------------------------------------------------------- +// 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 testresults + +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/test" + "io" + "net/http" + "net/url" + "strconv" + "strings" +) + +type Client interface { + // [Preview API] + AddTestResultsToTestRun(context.Context, AddTestResultsToTestRunArgs) (*[]test.TestCaseResult, error) + // [Preview API] + AddWorkItemToTestLinks(context.Context, AddWorkItemToTestLinksArgs) (*test.WorkItemToTestLinks, error) + // [Preview API] + CreateTestIterationResultAttachment(context.Context, CreateTestIterationResultAttachmentArgs) (*test.TestAttachmentReference, error) + // [Preview API] + CreateTestResultAttachment(context.Context, CreateTestResultAttachmentArgs) (*test.TestAttachmentReference, error) + // [Preview API] + CreateTestRun(context.Context, CreateTestRunArgs) (*test.TestRun, error) + // [Preview API] + CreateTestRunAttachment(context.Context, CreateTestRunAttachmentArgs) (*test.TestAttachmentReference, error) + // [Preview API] + CreateTestSettings(context.Context, CreateTestSettingsArgs) (*int, error) + // [Preview API] + CreateTestSubResultAttachment(context.Context, CreateTestSubResultAttachmentArgs) (*test.TestAttachmentReference, error) + // [Preview API] + DeleteTestMethodToWorkItemLink(context.Context, DeleteTestMethodToWorkItemLinkArgs) (*bool, error) + // [Preview API] + DeleteTestResultAttachment(context.Context, DeleteTestResultAttachmentArgs) error + // [Preview API] + DeleteTestRun(context.Context, DeleteTestRunArgs) error + // [Preview API] + DeleteTestRunAttachment(context.Context, DeleteTestRunAttachmentArgs) error + // [Preview API] + DeleteTestSettings(context.Context, DeleteTestSettingsArgs) error + // [Preview API] + GetBugsLinkedToTestResult(context.Context, GetBugsLinkedToTestResultArgs) (*[]test.WorkItemReference, error) + // [Preview API] + GetBuildCodeCoverage(context.Context, GetBuildCodeCoverageArgs) (*[]test.BuildCoverage, error) + // [Preview API] + GetCodeCoverageSummary(context.Context, GetCodeCoverageSummaryArgs) (*test.CodeCoverageSummary, error) + // [Preview API] + GetTestLogsForBuild(context.Context, GetTestLogsForBuildArgs) (*GetTestLogsForBuildResponseValue, error) + // [Preview API] + GetTestLogStoreEndpointDetailsForBuildLog(context.Context, GetTestLogStoreEndpointDetailsForBuildLogArgs) (*test.TestLogStoreEndpointDetails, error) + // [Preview API] + GetTestLogStoreEndpointDetailsForResultLog(context.Context, GetTestLogStoreEndpointDetailsForResultLogArgs) (*test.TestLogStoreEndpointDetails, error) + // [Preview API] + GetTestLogStoreEndpointDetailsForRunLog(context.Context, GetTestLogStoreEndpointDetailsForRunLogArgs) (*test.TestLogStoreEndpointDetails, error) + // [Preview API] + GetTestLogStoreEndpointDetailsForSubResultLog(context.Context, GetTestLogStoreEndpointDetailsForSubResultLogArgs) (*test.TestLogStoreEndpointDetails, error) + // [Preview API] Returns a test result attachment + GetTestResultAttachmentContent(context.Context, GetTestResultAttachmentContentArgs) (io.ReadCloser, error) + // [Preview API] + GetTestResultAttachments(context.Context, GetTestResultAttachmentsArgs) (*[]test.TestAttachment, error) + // [Preview API] Returns a test result attachment + GetTestResultAttachmentZip(context.Context, GetTestResultAttachmentZipArgs) (io.ReadCloser, error) + // [Preview API] + GetTestResultById(context.Context, GetTestResultByIdArgs) (*test.TestCaseResult, error) + // [Preview API] + GetTestResultDetailsForBuild(context.Context, GetTestResultDetailsForBuildArgs) (*test.TestResultsDetails, error) + // [Preview API] + GetTestResultDetailsForRelease(context.Context, GetTestResultDetailsForReleaseArgs) (*test.TestResultsDetails, error) + // [Preview API] + GetTestResultLogs(context.Context, GetTestResultLogsArgs) (*GetTestResultLogsResponseValue, error) + // [Preview API] + GetTestResults(context.Context, GetTestResultsArgs) (*[]test.TestCaseResult, error) + // [Preview API] + GetTestResultsByQuery(context.Context, GetTestResultsByQueryArgs) (*test.TestResultsQuery, error) + // [Preview API] + GetTestResultsByQueryWiql(context.Context, GetTestResultsByQueryWiqlArgs) (*[]test.TestCaseResult, error) + // [Preview API] Get TestResultsSettings data + GetTestResultsSettings(context.Context, GetTestResultsSettingsArgs) (*test.TestResultsSettings, error) + // [Preview API] Returns a test run attachment + GetTestRunAttachmentContent(context.Context, GetTestRunAttachmentContentArgs) (io.ReadCloser, error) + // [Preview API] + GetTestRunAttachments(context.Context, GetTestRunAttachmentsArgs) (*[]test.TestAttachment, error) + // [Preview API] Returns a test run attachment + GetTestRunAttachmentZip(context.Context, GetTestRunAttachmentZipArgs) (io.ReadCloser, error) + // [Preview API] + GetTestRunById(context.Context, GetTestRunByIdArgs) (*test.TestRun, error) + // [Preview API] + GetTestRunCodeCoverage(context.Context, GetTestRunCodeCoverageArgs) (*[]test.TestRunCoverage, error) + // [Preview API] + GetTestRunLogs(context.Context, GetTestRunLogsArgs) (*GetTestRunLogsResponseValue, error) + // [Preview API] + GetTestRuns(context.Context, GetTestRunsArgs) (*[]test.TestRun, error) + // Get test run statistics , used when we want to get summary of a run by outcome. + GetTestRunStatistics(context.Context, GetTestRunStatisticsArgs) (*test.TestRunStatistic, error) + // [Preview API] + GetTestSettingsById(context.Context, GetTestSettingsByIdArgs) (*test.TestSettings, error) + // [Preview API] Returns a test sub result attachment + GetTestSubResultAttachmentContent(context.Context, GetTestSubResultAttachmentContentArgs) (io.ReadCloser, error) + // [Preview API] Returns attachment references for test sub result. + GetTestSubResultAttachments(context.Context, GetTestSubResultAttachmentsArgs) (*[]test.TestAttachment, error) + // [Preview API] Returns a test sub result attachment + GetTestSubResultAttachmentZip(context.Context, GetTestSubResultAttachmentZipArgs) (io.ReadCloser, error) + // [Preview API] + GetTestSubResultLogs(context.Context, GetTestSubResultLogsArgs) (*GetTestSubResultLogsResponseValue, error) + // [Preview API] + QueryResultTrendForBuild(context.Context, QueryResultTrendForBuildArgs) (*[]test.AggregatedDataForResultTrend, error) + // [Preview API] + QueryResultTrendForRelease(context.Context, QueryResultTrendForReleaseArgs) (*[]test.AggregatedDataForResultTrend, error) + // [Preview API] Get history of a test method using TestHistoryQuery + QueryTestHistory(context.Context, QueryTestHistoryArgs) (*test.TestHistoryQuery, error) + // [Preview API] + QueryTestMethodLinkedWorkItems(context.Context, QueryTestMethodLinkedWorkItemsArgs) (*test.TestToWorkItemLinks, error) + // [Preview API] + QueryTestResultHistory(context.Context, QueryTestResultHistoryArgs) (*test.TestResultHistory, error) + // [Preview API] + QueryTestResultsReportForBuild(context.Context, QueryTestResultsReportForBuildArgs) (*test.TestResultSummary, error) + // [Preview API] + QueryTestResultsReportForRelease(context.Context, QueryTestResultsReportForReleaseArgs) (*test.TestResultSummary, error) + // [Preview API] + QueryTestResultsSummaryForReleases(context.Context, QueryTestResultsSummaryForReleasesArgs) (*[]test.TestResultSummary, error) + // [Preview API] + QueryTestResultWorkItems(context.Context, QueryTestResultWorkItemsArgs) (*[]test.WorkItemReference, error) + // [Preview API] Query Test Runs based on filters. Mandatory fields are minLastUpdatedDate and maxLastUpdatedDate. + QueryTestRuns(context.Context, QueryTestRunsArgs) (*QueryTestRunsResponseValue, error) + // [Preview API] + QueryTestSummaryByRequirement(context.Context, QueryTestSummaryByRequirementArgs) (*[]test.TestSummaryForWorkItem, error) + // [Preview API] + TestLogStoreEndpointDetailsForBuild(context.Context, TestLogStoreEndpointDetailsForBuildArgs) (*test.TestLogStoreEndpointDetails, error) + // [Preview API] + TestLogStoreEndpointDetailsForResult(context.Context, TestLogStoreEndpointDetailsForResultArgs) (*test.TestLogStoreEndpointDetails, error) + // [Preview API] + TestLogStoreEndpointDetailsForRun(context.Context, TestLogStoreEndpointDetailsForRunArgs) (*test.TestLogStoreEndpointDetails, error) + // [Preview API] http://(tfsserver):8080/tfs/DefaultCollection/_apis/test/CodeCoverage?buildId=10 Request: Json of code coverage summary + UpdateCodeCoverageSummary(context.Context, UpdateCodeCoverageSummaryArgs) error + // [Preview API] Update project settings of test results + UpdatePipelinesTestSettings(context.Context, UpdatePipelinesTestSettingsArgs) (*test.TestResultsSettings, error) + // [Preview API] + UpdateTestResults(context.Context, UpdateTestResultsArgs) (*[]test.TestCaseResult, error) + // [Preview API] + UpdateTestRun(context.Context, UpdateTestRunArgs) (*test.TestRun, 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, + } +} + +// [Preview API] +func (client *ClientImpl) AddTestResultsToTestRun(ctx context.Context, args AddTestResultsToTestRunArgs) (*[]test.TestCaseResult, error) { + if args.Results == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Results"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + body, marshalErr := json.Marshal(*args.Results) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("02afa165-e79a-4d70-8f0c-2af0f35b4e07") + 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 []test.TestCaseResult + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddTestResultsToTestRun function +type AddTestResultsToTestRunArgs struct { + // (required) + Results *[]test.TestCaseResult + // (required) Project ID or project name + Project *string + // (required) + RunId *int +} + +// [Preview API] +func (client *ClientImpl) AddWorkItemToTestLinks(ctx context.Context, args AddWorkItemToTestLinksArgs) (*test.WorkItemToTestLinks, error) { + if args.WorkItemToTestLinks == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemToTestLinks"} + } + 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.WorkItemToTestLinks) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("4e3abe63-ca46-4fe0-98b2-363f7ec7aa5f") + 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 test.WorkItemToTestLinks + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddWorkItemToTestLinks function +type AddWorkItemToTestLinksArgs struct { + // (required) + WorkItemToTestLinks *test.WorkItemToTestLinks + // (required) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) CreateTestIterationResultAttachment(ctx context.Context, args CreateTestIterationResultAttachmentArgs) (*test.TestAttachmentReference, error) { + if args.AttachmentRequestModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentRequestModel"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + queryParams := url.Values{} + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "iterationId"} + } + queryParams.Add("iterationId", strconv.Itoa(*args.IterationId)) + if args.ActionPath != nil { + queryParams.Add("actionPath", *args.ActionPath) + } + body, marshalErr := json.Marshal(*args.AttachmentRequestModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2a632e97-e014-4275-978f-8e5c4906d4b3") + 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 test.TestAttachmentReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestIterationResultAttachment function +type CreateTestIterationResultAttachmentArgs struct { + // (required) + AttachmentRequestModel *test.TestAttachmentRequestModel + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestCaseResultId *int + // (required) + IterationId *int + // (optional) + ActionPath *string +} + +// [Preview API] +func (client *ClientImpl) CreateTestResultAttachment(ctx context.Context, args CreateTestResultAttachmentArgs) (*test.TestAttachmentReference, error) { + if args.AttachmentRequestModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentRequestModel"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + body, marshalErr := json.Marshal(*args.AttachmentRequestModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2a632e97-e014-4275-978f-8e5c4906d4b3") + 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 test.TestAttachmentReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestResultAttachment function +type CreateTestResultAttachmentArgs struct { + // (required) + AttachmentRequestModel *test.TestAttachmentRequestModel + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestCaseResultId *int +} + +// [Preview API] +func (client *ClientImpl) CreateTestRun(ctx context.Context, args CreateTestRunArgs) (*test.TestRun, error) { + if args.TestRun == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestRun"} + } + 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.TestRun) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("364538f9-8062-4ce0-b024-75a0fb463f0d") + 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 test.TestRun + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestRun function +type CreateTestRunArgs struct { + // (required) + TestRun *test.RunCreateModel + // (required) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) CreateTestRunAttachment(ctx context.Context, args CreateTestRunAttachmentArgs) (*test.TestAttachmentReference, error) { + if args.AttachmentRequestModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentRequestModel"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + body, marshalErr := json.Marshal(*args.AttachmentRequestModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b5731898-8206-477a-a51d-3fdf116fc6bf") + 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 test.TestAttachmentReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestRunAttachment function +type CreateTestRunAttachmentArgs struct { + // (required) + AttachmentRequestModel *test.TestAttachmentRequestModel + // (required) Project ID or project name + Project *string + // (required) + RunId *int +} + +// [Preview API] +func (client *ClientImpl) CreateTestSettings(ctx context.Context, args CreateTestSettingsArgs) (*int, error) { + if args.TestSettings == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestSettings"} + } + 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.TestSettings) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("930bad47-f826-4099-9597-f44d0a9c735c") + 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 int + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestSettings function +type CreateTestSettingsArgs struct { + // (required) + TestSettings *test.TestSettings + // (required) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) CreateTestSubResultAttachment(ctx context.Context, args CreateTestSubResultAttachmentArgs) (*test.TestAttachmentReference, error) { + if args.AttachmentRequestModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentRequestModel"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + queryParams := url.Values{} + if args.TestSubResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testSubResultId"} + } + queryParams.Add("testSubResultId", strconv.Itoa(*args.TestSubResultId)) + body, marshalErr := json.Marshal(*args.AttachmentRequestModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2a632e97-e014-4275-978f-8e5c4906d4b3") + 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 test.TestAttachmentReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTestSubResultAttachment function +type CreateTestSubResultAttachmentArgs struct { + // (required) + AttachmentRequestModel *test.TestAttachmentRequestModel + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestCaseResultId *int + // (required) + TestSubResultId *int +} + +// [Preview API] +func (client *ClientImpl) DeleteTestMethodToWorkItemLink(ctx context.Context, args DeleteTestMethodToWorkItemLinkArgs) (*bool, 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.TestName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testName"} + } + queryParams.Add("testName", *args.TestName) + if args.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "workItemId"} + } + queryParams.Add("workItemId", strconv.Itoa(*args.WorkItemId)) + locationId, _ := uuid.Parse("cbd50bd7-f7ed-4e35-b127-4408ae6bfa2c") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, queryParams, 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 DeleteTestMethodToWorkItemLink function +type DeleteTestMethodToWorkItemLinkArgs struct { + // (required) Project ID or project name + Project *string + // (required) + TestName *string + // (required) + WorkItemId *int +} + +// [Preview API] +func (client *ClientImpl) DeleteTestResultAttachment(ctx context.Context, args DeleteTestResultAttachmentArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.AttachmentId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + locationId, _ := uuid.Parse("2a632e97-e014-4275-978f-8e5c4906d4b3") + _, 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 DeleteTestResultAttachment function +type DeleteTestResultAttachmentArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestCaseResultId *int + // (required) + AttachmentId *int +} + +// [Preview API] +func (client *ClientImpl) DeleteTestRun(ctx context.Context, args DeleteTestRunArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + locationId, _ := uuid.Parse("364538f9-8062-4ce0-b024-75a0fb463f0d") + _, 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 DeleteTestRun function +type DeleteTestRunArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int +} + +// [Preview API] +func (client *ClientImpl) DeleteTestRunAttachment(ctx context.Context, args DeleteTestRunAttachmentArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.AttachmentId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + locationId, _ := uuid.Parse("b5731898-8206-477a-a51d-3fdf116fc6bf") + _, 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 DeleteTestRunAttachment function +type DeleteTestRunAttachmentArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + AttachmentId *int +} + +// [Preview API] +func (client *ClientImpl) DeleteTestSettings(ctx context.Context, args DeleteTestSettingsArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.TestSettingsId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "testSettingsId"} + } + queryParams.Add("testSettingsId", strconv.Itoa(*args.TestSettingsId)) + locationId, _ := uuid.Parse("930bad47-f826-4099-9597-f44d0a9c735c") + _, 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 DeleteTestSettings function +type DeleteTestSettingsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + TestSettingsId *int +} + +// [Preview API] +func (client *ClientImpl) GetBugsLinkedToTestResult(ctx context.Context, args GetBugsLinkedToTestResultArgs) (*[]test.WorkItemReference, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + locationId, _ := uuid.Parse("d8dbf98f-eb34-4f8d-8365-47972af34f29") + 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 []test.WorkItemReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBugsLinkedToTestResult function +type GetBugsLinkedToTestResultArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestCaseResultId *int +} + +// [Preview API] +func (client *ClientImpl) GetBuildCodeCoverage(ctx context.Context, args GetBuildCodeCoverageArgs) (*[]test.BuildCoverage, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "buildId"} + } + queryParams.Add("buildId", strconv.Itoa(*args.BuildId)) + if args.Flags == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "flags"} + } + queryParams.Add("flags", strconv.Itoa(*args.Flags)) + locationId, _ := uuid.Parse("9b3e1ece-c6ab-4fbb-8167-8a32a0c92216") + 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 []test.BuildCoverage + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBuildCodeCoverage function +type GetBuildCodeCoverageArgs struct { + // (required) Project ID or project name + Project *string + // (required) + BuildId *int + // (required) + Flags *int +} + +// [Preview API] +func (client *ClientImpl) GetCodeCoverageSummary(ctx context.Context, args GetCodeCoverageSummaryArgs) (*test.CodeCoverageSummary, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "buildId"} + } + queryParams.Add("buildId", strconv.Itoa(*args.BuildId)) + if args.DeltaBuildId != nil { + queryParams.Add("deltaBuildId", strconv.Itoa(*args.DeltaBuildId)) + } + locationId, _ := uuid.Parse("9b3e1ece-c6ab-4fbb-8167-8a32a0c92216") + 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 test.CodeCoverageSummary + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCodeCoverageSummary function +type GetCodeCoverageSummaryArgs struct { + // (required) Project ID or project name + Project *string + // (required) + BuildId *int + // (optional) + DeltaBuildId *int +} + +// [Preview API] +func (client *ClientImpl) GetTestLogsForBuild(ctx context.Context, args GetTestLogsForBuildArgs) (*GetTestLogsForBuildResponseValue, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "buildId"} + } + queryParams.Add("buildId", strconv.Itoa(*args.BuildId)) + if args.Type == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "type"} + } + queryParams.Add("type", string(*args.Type)) + if args.DirectoryPath != nil { + queryParams.Add("directoryPath", *args.DirectoryPath) + } + if args.FileNamePrefix != nil { + queryParams.Add("fileNamePrefix", *args.FileNamePrefix) + } + if args.FetchMetaData != nil { + queryParams.Add("fetchMetaData", strconv.FormatBool(*args.FetchMetaData)) + } + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + additionalHeaders := make(map[string]string) + if args.ContinuationToken != nil { + additionalHeaders["x-ms-continuationtoken"] = *args.ContinuationToken + } + locationId, _ := uuid.Parse("dff8ce3a-e539-4817-a405-d968491a88f1") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseValue GetTestLogsForBuildResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetTestLogsForBuild function +type GetTestLogsForBuildArgs struct { + // (required) Project ID or project name + Project *string + // (required) + BuildId *int + // (required) + Type *test.TestLogType + // (optional) + DirectoryPath *string + // (optional) + FileNamePrefix *string + // (optional) + FetchMetaData *bool + // (optional) + Top *int + // (optional) Header to pass the continuationToken + ContinuationToken *string +} + +// Return type for the GetTestLogsForBuild function +type GetTestLogsForBuildResponseValue struct { + Value []test.TestLog + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] +func (client *ClientImpl) GetTestLogStoreEndpointDetailsForBuildLog(ctx context.Context, args GetTestLogStoreEndpointDetailsForBuildLogArgs) (*test.TestLogStoreEndpointDetails, 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.Build == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "build"} + } + queryParams.Add("build", strconv.Itoa(*args.Build)) + if args.Type == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "type"} + } + queryParams.Add("type", string(*args.Type)) + if args.FilePath == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "filePath"} + } + queryParams.Add("filePath", *args.FilePath) + locationId, _ := uuid.Parse("39b09be7-f0c9-4a83-a513-9ae31b45c56f") + 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 test.TestLogStoreEndpointDetails + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestLogStoreEndpointDetailsForBuildLog function +type GetTestLogStoreEndpointDetailsForBuildLogArgs struct { + // (required) Project ID or project name + Project *string + // (required) + Build *int + // (required) + Type *test.TestLogType + // (required) + FilePath *string +} + +// [Preview API] +func (client *ClientImpl) GetTestLogStoreEndpointDetailsForResultLog(ctx context.Context, args GetTestLogStoreEndpointDetailsForResultLogArgs) (*test.TestLogStoreEndpointDetails, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.ResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ResultId"} + } + routeValues["resultId"] = strconv.Itoa(*args.ResultId) + + queryParams := url.Values{} + if args.Type == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "type"} + } + queryParams.Add("type", string(*args.Type)) + if args.FilePath == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "filePath"} + } + queryParams.Add("filePath", *args.FilePath) + locationId, _ := uuid.Parse("da630b37-1236-45b5-945e-1d7bdb673850") + 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 test.TestLogStoreEndpointDetails + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestLogStoreEndpointDetailsForResultLog function +type GetTestLogStoreEndpointDetailsForResultLogArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + ResultId *int + // (required) + Type *test.TestLogType + // (required) + FilePath *string +} + +// [Preview API] +func (client *ClientImpl) GetTestLogStoreEndpointDetailsForRunLog(ctx context.Context, args GetTestLogStoreEndpointDetailsForRunLogArgs) (*test.TestLogStoreEndpointDetails, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + queryParams := url.Values{} + if args.Type == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "type"} + } + queryParams.Add("type", string(*args.Type)) + if args.FilePath == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "filePath"} + } + queryParams.Add("filePath", *args.FilePath) + locationId, _ := uuid.Parse("67eb3f92-6c97-4fd9-8b63-6cbdc7e526ea") + 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 test.TestLogStoreEndpointDetails + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestLogStoreEndpointDetailsForRunLog function +type GetTestLogStoreEndpointDetailsForRunLogArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + Type *test.TestLogType + // (required) + FilePath *string +} + +// [Preview API] +func (client *ClientImpl) GetTestLogStoreEndpointDetailsForSubResultLog(ctx context.Context, args GetTestLogStoreEndpointDetailsForSubResultLogArgs) (*test.TestLogStoreEndpointDetails, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.ResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ResultId"} + } + routeValues["resultId"] = strconv.Itoa(*args.ResultId) + + queryParams := url.Values{} + if args.SubResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "subResultId"} + } + queryParams.Add("subResultId", strconv.Itoa(*args.SubResultId)) + if args.Type == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "type"} + } + queryParams.Add("type", string(*args.Type)) + if args.FilePath == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "filePath"} + } + queryParams.Add("filePath", *args.FilePath) + locationId, _ := uuid.Parse("da630b37-1236-45b5-945e-1d7bdb673850") + 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 test.TestLogStoreEndpointDetails + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestLogStoreEndpointDetailsForSubResultLog function +type GetTestLogStoreEndpointDetailsForSubResultLogArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + ResultId *int + // (required) + SubResultId *int + // (required) + Type *test.TestLogType + // (required) + FilePath *string +} + +// [Preview API] Returns a test result attachment +func (client *ClientImpl) GetTestResultAttachmentContent(ctx context.Context, args GetTestResultAttachmentContentArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + locationId, _ := uuid.Parse("2a632e97-e014-4275-978f-8e5c4906d4b3") + 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 GetTestResultAttachmentContent function +type GetTestResultAttachmentContentArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestCaseResultId *int + // (required) + AttachmentId *int +} + +// [Preview API] +func (client *ClientImpl) GetTestResultAttachments(ctx context.Context, args GetTestResultAttachmentsArgs) (*[]test.TestAttachment, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + locationId, _ := uuid.Parse("2a632e97-e014-4275-978f-8e5c4906d4b3") + 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 []test.TestAttachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestResultAttachments function +type GetTestResultAttachmentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestCaseResultId *int +} + +// [Preview API] Returns a test result attachment +func (client *ClientImpl) GetTestResultAttachmentZip(ctx context.Context, args GetTestResultAttachmentZipArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + locationId, _ := uuid.Parse("2a632e97-e014-4275-978f-8e5c4906d4b3") + 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 GetTestResultAttachmentZip function +type GetTestResultAttachmentZipArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestCaseResultId *int + // (required) + AttachmentId *int +} + +// [Preview API] +func (client *ClientImpl) GetTestResultById(ctx context.Context, args GetTestResultByIdArgs) (*test.TestCaseResult, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestResultId"} + } + routeValues["testResultId"] = strconv.Itoa(*args.TestResultId) + + queryParams := url.Values{} + if args.DetailsToInclude != nil { + queryParams.Add("detailsToInclude", string(*args.DetailsToInclude)) + } + locationId, _ := uuid.Parse("02afa165-e79a-4d70-8f0c-2af0f35b4e07") + 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 test.TestCaseResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestResultById function +type GetTestResultByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestResultId *int + // (optional) + DetailsToInclude *test.ResultDetails +} + +// [Preview API] +func (client *ClientImpl) GetTestResultDetailsForBuild(ctx context.Context, args GetTestResultDetailsForBuildArgs) (*test.TestResultsDetails, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "buildId"} + } + queryParams.Add("buildId", strconv.Itoa(*args.BuildId)) + if args.PublishContext != nil { + queryParams.Add("publishContext", *args.PublishContext) + } + if args.GroupBy != nil { + queryParams.Add("groupBy", *args.GroupBy) + } + if args.Filter != nil { + queryParams.Add("$filter", *args.Filter) + } + if args.Orderby != nil { + queryParams.Add("$orderby", *args.Orderby) + } + if args.ShouldIncludeResults != nil { + queryParams.Add("shouldIncludeResults", strconv.FormatBool(*args.ShouldIncludeResults)) + } + if args.QueryRunSummaryForInProgress != nil { + queryParams.Add("queryRunSummaryForInProgress", strconv.FormatBool(*args.QueryRunSummaryForInProgress)) + } + locationId, _ := uuid.Parse("a518c749-4524-45b2-a7ef-1ac009b312cd") + 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 test.TestResultsDetails + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestResultDetailsForBuild function +type GetTestResultDetailsForBuildArgs struct { + // (required) Project ID or project name + Project *string + // (required) + BuildId *int + // (optional) + PublishContext *string + // (optional) + GroupBy *string + // (optional) + Filter *string + // (optional) + Orderby *string + // (optional) + ShouldIncludeResults *bool + // (optional) + QueryRunSummaryForInProgress *bool +} + +// [Preview API] +func (client *ClientImpl) GetTestResultDetailsForRelease(ctx context.Context, args GetTestResultDetailsForReleaseArgs) (*test.TestResultsDetails, 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.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "releaseId"} + } + queryParams.Add("releaseId", strconv.Itoa(*args.ReleaseId)) + if args.ReleaseEnvId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "releaseEnvId"} + } + queryParams.Add("releaseEnvId", strconv.Itoa(*args.ReleaseEnvId)) + if args.PublishContext != nil { + queryParams.Add("publishContext", *args.PublishContext) + } + if args.GroupBy != nil { + queryParams.Add("groupBy", *args.GroupBy) + } + if args.Filter != nil { + queryParams.Add("$filter", *args.Filter) + } + if args.Orderby != nil { + queryParams.Add("$orderby", *args.Orderby) + } + if args.ShouldIncludeResults != nil { + queryParams.Add("shouldIncludeResults", strconv.FormatBool(*args.ShouldIncludeResults)) + } + if args.QueryRunSummaryForInProgress != nil { + queryParams.Add("queryRunSummaryForInProgress", strconv.FormatBool(*args.QueryRunSummaryForInProgress)) + } + locationId, _ := uuid.Parse("19a8183a-69fb-47d7-bfbf-1b6b0d921294") + 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 test.TestResultsDetails + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestResultDetailsForRelease function +type GetTestResultDetailsForReleaseArgs struct { + // (required) Project ID or project name + Project *string + // (required) + ReleaseId *int + // (required) + ReleaseEnvId *int + // (optional) + PublishContext *string + // (optional) + GroupBy *string + // (optional) + Filter *string + // (optional) + Orderby *string + // (optional) + ShouldIncludeResults *bool + // (optional) + QueryRunSummaryForInProgress *bool +} + +// [Preview API] +func (client *ClientImpl) GetTestResultLogs(ctx context.Context, args GetTestResultLogsArgs) (*GetTestResultLogsResponseValue, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.ResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ResultId"} + } + routeValues["resultId"] = strconv.Itoa(*args.ResultId) + + queryParams := url.Values{} + if args.Type == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "type"} + } + queryParams.Add("type", string(*args.Type)) + if args.DirectoryPath != nil { + queryParams.Add("directoryPath", *args.DirectoryPath) + } + if args.FileNamePrefix != nil { + queryParams.Add("fileNamePrefix", *args.FileNamePrefix) + } + if args.FetchMetaData != nil { + queryParams.Add("fetchMetaData", strconv.FormatBool(*args.FetchMetaData)) + } + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + additionalHeaders := make(map[string]string) + if args.ContinuationToken != nil { + additionalHeaders["x-ms-continuationtoken"] = *args.ContinuationToken + } + locationId, _ := uuid.Parse("714caaac-ae1e-4869-8323-9bc0f5120dbf") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseValue GetTestResultLogsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetTestResultLogs function +type GetTestResultLogsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + ResultId *int + // (required) + Type *test.TestLogType + // (optional) + DirectoryPath *string + // (optional) + FileNamePrefix *string + // (optional) + FetchMetaData *bool + // (optional) + Top *int + // (optional) Header to pass the continuationToken + ContinuationToken *string +} + +// Return type for the GetTestResultLogs function +type GetTestResultLogsResponseValue struct { + Value []test.TestLog + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] +func (client *ClientImpl) GetTestResults(ctx context.Context, args GetTestResultsArgs) (*[]test.TestCaseResult, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + queryParams := url.Values{} + if args.DetailsToInclude != nil { + queryParams.Add("detailsToInclude", string(*args.DetailsToInclude)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Outcomes != nil { + var stringList []string + for _, item := range *args.Outcomes { + stringList = append(stringList, string(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("outcomes", listAsString) + } + locationId, _ := uuid.Parse("02afa165-e79a-4d70-8f0c-2af0f35b4e07") + 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 []test.TestCaseResult + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestResults function +type GetTestResultsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (optional) + DetailsToInclude *test.ResultDetails + // (optional) + Skip *int + // (optional) + Top *int + // (optional) + Outcomes *[]test.TestOutcome +} + +// [Preview API] +func (client *ClientImpl) GetTestResultsByQuery(ctx context.Context, args GetTestResultsByQueryArgs) (*test.TestResultsQuery, error) { + if args.Query == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Query"} + } + 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.Query) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("14033a2c-af25-4af1-9e39-8ef6900482e3") + 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 test.TestResultsQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestResultsByQuery function +type GetTestResultsByQueryArgs struct { + // (required) + Query *test.TestResultsQuery + // (required) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) GetTestResultsByQueryWiql(ctx context.Context, args GetTestResultsByQueryWiqlArgs) (*[]test.TestCaseResult, error) { + if args.QueryModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.QueryModel"} + } + 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.IncludeResultDetails != nil { + queryParams.Add("includeResultDetails", strconv.FormatBool(*args.IncludeResultDetails)) + } + if args.IncludeIterationDetails != nil { + queryParams.Add("includeIterationDetails", strconv.FormatBool(*args.IncludeIterationDetails)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + body, marshalErr := json.Marshal(*args.QueryModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("5ea78be3-2f5a-4110-8034-c27f24c62db1") + 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 []test.TestCaseResult + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestResultsByQueryWiql function +type GetTestResultsByQueryWiqlArgs struct { + // (required) + QueryModel *test.QueryModel + // (required) Project ID or project name + Project *string + // (optional) + IncludeResultDetails *bool + // (optional) + IncludeIterationDetails *bool + // (optional) + Skip *int + // (optional) + Top *int +} + +// [Preview API] Get TestResultsSettings data +func (client *ClientImpl) GetTestResultsSettings(ctx context.Context, args GetTestResultsSettingsArgs) (*test.TestResultsSettings, 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.SettingsType != nil { + queryParams.Add("settingsType", string(*args.SettingsType)) + } + locationId, _ := uuid.Parse("7319952e-e5a9-4e19-a006-84f3be8b7c68") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.3", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue test.TestResultsSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestResultsSettings function +type GetTestResultsSettingsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) + SettingsType *test.TestResultsSettingsType +} + +// [Preview API] Returns a test run attachment +func (client *ClientImpl) GetTestRunAttachmentContent(ctx context.Context, args GetTestRunAttachmentContentArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + locationId, _ := uuid.Parse("b5731898-8206-477a-a51d-3fdf116fc6bf") + 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 GetTestRunAttachmentContent function +type GetTestRunAttachmentContentArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + AttachmentId *int +} + +// [Preview API] +func (client *ClientImpl) GetTestRunAttachments(ctx context.Context, args GetTestRunAttachmentsArgs) (*[]test.TestAttachment, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + locationId, _ := uuid.Parse("b5731898-8206-477a-a51d-3fdf116fc6bf") + 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 []test.TestAttachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRunAttachments function +type GetTestRunAttachmentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int +} + +// [Preview API] Returns a test run attachment +func (client *ClientImpl) GetTestRunAttachmentZip(ctx context.Context, args GetTestRunAttachmentZipArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + locationId, _ := uuid.Parse("b5731898-8206-477a-a51d-3fdf116fc6bf") + 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 GetTestRunAttachmentZip function +type GetTestRunAttachmentZipArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + AttachmentId *int +} + +// [Preview API] +func (client *ClientImpl) GetTestRunById(ctx context.Context, args GetTestRunByIdArgs) (*test.TestRun, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + queryParams := url.Values{} + if args.IncludeDetails != nil { + queryParams.Add("includeDetails", strconv.FormatBool(*args.IncludeDetails)) + } + if args.IncludeTags != nil { + queryParams.Add("includeTags", strconv.FormatBool(*args.IncludeTags)) + } + locationId, _ := uuid.Parse("364538f9-8062-4ce0-b024-75a0fb463f0d") + 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 test.TestRun + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRunById function +type GetTestRunByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (optional) + IncludeDetails *bool + // (optional) + IncludeTags *bool +} + +// [Preview API] +func (client *ClientImpl) GetTestRunCodeCoverage(ctx context.Context, args GetTestRunCodeCoverageArgs) (*[]test.TestRunCoverage, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + queryParams := url.Values{} + if args.Flags == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "flags"} + } + queryParams.Add("flags", strconv.Itoa(*args.Flags)) + locationId, _ := uuid.Parse("5641efbc-6f9b-401a-baeb-d3da22489e5e") + 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 []test.TestRunCoverage + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRunCodeCoverage function +type GetTestRunCodeCoverageArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + Flags *int +} + +// [Preview API] +func (client *ClientImpl) GetTestRunLogs(ctx context.Context, args GetTestRunLogsArgs) (*GetTestRunLogsResponseValue, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + queryParams := url.Values{} + if args.Type == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "type"} + } + queryParams.Add("type", string(*args.Type)) + if args.DirectoryPath != nil { + queryParams.Add("directoryPath", *args.DirectoryPath) + } + if args.FileNamePrefix != nil { + queryParams.Add("fileNamePrefix", *args.FileNamePrefix) + } + if args.FetchMetaData != nil { + queryParams.Add("fetchMetaData", strconv.FormatBool(*args.FetchMetaData)) + } + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + additionalHeaders := make(map[string]string) + if args.ContinuationToken != nil { + additionalHeaders["x-ms-continuationtoken"] = *args.ContinuationToken + } + locationId, _ := uuid.Parse("5b47b946-e875-4c9a-acdc-2a20996caebe") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseValue GetTestRunLogsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetTestRunLogs function +type GetTestRunLogsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + Type *test.TestLogType + // (optional) + DirectoryPath *string + // (optional) + FileNamePrefix *string + // (optional) + FetchMetaData *bool + // (optional) + Top *int + // (optional) Header to pass the continuationToken + ContinuationToken *string +} + +// Return type for the GetTestRunLogs function +type GetTestRunLogsResponseValue struct { + Value []test.TestLog + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] +func (client *ClientImpl) GetTestRuns(ctx context.Context, args GetTestRunsArgs) (*[]test.TestRun, 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.BuildUri != nil { + queryParams.Add("buildUri", *args.BuildUri) + } + if args.Owner != nil { + queryParams.Add("owner", *args.Owner) + } + if args.TmiRunId != nil { + queryParams.Add("tmiRunId", *args.TmiRunId) + } + if args.PlanId != nil { + queryParams.Add("planId", strconv.Itoa(*args.PlanId)) + } + if args.IncludeRunDetails != nil { + queryParams.Add("includeRunDetails", strconv.FormatBool(*args.IncludeRunDetails)) + } + if args.Automated != nil { + queryParams.Add("automated", strconv.FormatBool(*args.Automated)) + } + 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("364538f9-8062-4ce0-b024-75a0fb463f0d") + 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 []test.TestRun + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRuns function +type GetTestRunsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) + BuildUri *string + // (optional) + Owner *string + // (optional) + TmiRunId *string + // (optional) + PlanId *int + // (optional) + IncludeRunDetails *bool + // (optional) + Automated *bool + // (optional) + Skip *int + // (optional) + Top *int +} + +// Get test run statistics , used when we want to get summary of a run by outcome. +func (client *ClientImpl) GetTestRunStatistics(ctx context.Context, args GetTestRunStatisticsArgs) (*test.TestRunStatistic, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + locationId, _ := uuid.Parse("82b986e8-ca9e-4a89-b39e-f65c69bc104a") + 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 test.TestRunStatistic + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestRunStatistics function +type GetTestRunStatisticsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the run to get. + RunId *int +} + +// [Preview API] +func (client *ClientImpl) GetTestSettingsById(ctx context.Context, args GetTestSettingsByIdArgs) (*test.TestSettings, 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.TestSettingsId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testSettingsId"} + } + queryParams.Add("testSettingsId", strconv.Itoa(*args.TestSettingsId)) + locationId, _ := uuid.Parse("930bad47-f826-4099-9597-f44d0a9c735c") + 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 test.TestSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestSettingsById function +type GetTestSettingsByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) + TestSettingsId *int +} + +// [Preview API] Returns a test sub result attachment +func (client *ClientImpl) GetTestSubResultAttachmentContent(ctx context.Context, args GetTestSubResultAttachmentContentArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + queryParams := url.Values{} + if args.TestSubResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testSubResultId"} + } + queryParams.Add("testSubResultId", strconv.Itoa(*args.TestSubResultId)) + locationId, _ := uuid.Parse("2a632e97-e014-4275-978f-8e5c4906d4b3") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/octet-stream", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetTestSubResultAttachmentContent function +type GetTestSubResultAttachmentContentArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestCaseResultId *int + // (required) + AttachmentId *int + // (required) + TestSubResultId *int +} + +// [Preview API] Returns attachment references for test sub result. +func (client *ClientImpl) GetTestSubResultAttachments(ctx context.Context, args GetTestSubResultAttachmentsArgs) (*[]test.TestAttachment, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + + queryParams := url.Values{} + if args.TestSubResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testSubResultId"} + } + queryParams.Add("testSubResultId", strconv.Itoa(*args.TestSubResultId)) + locationId, _ := uuid.Parse("2a632e97-e014-4275-978f-8e5c4906d4b3") + 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 []test.TestAttachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTestSubResultAttachments function +type GetTestSubResultAttachmentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestCaseResultId *int + // (required) + TestSubResultId *int +} + +// [Preview API] Returns a test sub result attachment +func (client *ClientImpl) GetTestSubResultAttachmentZip(ctx context.Context, args GetTestSubResultAttachmentZipArgs) (io.ReadCloser, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.TestCaseResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestCaseResultId"} + } + routeValues["testCaseResultId"] = strconv.Itoa(*args.TestCaseResultId) + if args.AttachmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttachmentId"} + } + routeValues["attachmentId"] = strconv.Itoa(*args.AttachmentId) + + queryParams := url.Values{} + if args.TestSubResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testSubResultId"} + } + queryParams.Add("testSubResultId", strconv.Itoa(*args.TestSubResultId)) + locationId, _ := uuid.Parse("2a632e97-e014-4275-978f-8e5c4906d4b3") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetTestSubResultAttachmentZip function +type GetTestSubResultAttachmentZipArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestCaseResultId *int + // (required) + AttachmentId *int + // (required) + TestSubResultId *int +} + +// [Preview API] +func (client *ClientImpl) GetTestSubResultLogs(ctx context.Context, args GetTestSubResultLogsArgs) (*GetTestSubResultLogsResponseValue, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.ResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ResultId"} + } + routeValues["resultId"] = strconv.Itoa(*args.ResultId) + + queryParams := url.Values{} + if args.SubResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "subResultId"} + } + queryParams.Add("subResultId", strconv.Itoa(*args.SubResultId)) + if args.Type == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "type"} + } + queryParams.Add("type", string(*args.Type)) + if args.DirectoryPath != nil { + queryParams.Add("directoryPath", *args.DirectoryPath) + } + if args.FileNamePrefix != nil { + queryParams.Add("fileNamePrefix", *args.FileNamePrefix) + } + if args.FetchMetaData != nil { + queryParams.Add("fetchMetaData", strconv.FormatBool(*args.FetchMetaData)) + } + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + additionalHeaders := make(map[string]string) + if args.ContinuationToken != nil { + additionalHeaders["x-ms-continuationtoken"] = *args.ContinuationToken + } + locationId, _ := uuid.Parse("714caaac-ae1e-4869-8323-9bc0f5120dbf") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseValue GetTestSubResultLogsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetTestSubResultLogs function +type GetTestSubResultLogsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + ResultId *int + // (required) + SubResultId *int + // (required) + Type *test.TestLogType + // (optional) + DirectoryPath *string + // (optional) + FileNamePrefix *string + // (optional) + FetchMetaData *bool + // (optional) + Top *int + // (optional) Header to pass the continuationToken + ContinuationToken *string +} + +// Return type for the GetTestSubResultLogs function +type GetTestSubResultLogsResponseValue struct { + Value []test.TestLog + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] +func (client *ClientImpl) QueryResultTrendForBuild(ctx context.Context, args QueryResultTrendForBuildArgs) (*[]test.AggregatedDataForResultTrend, error) { + if args.Filter == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Filter"} + } + 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.Filter) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("0886a7ae-315a-4dba-9122-bcce93301f3a") + 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 []test.AggregatedDataForResultTrend + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryResultTrendForBuild function +type QueryResultTrendForBuildArgs struct { + // (required) + Filter *test.TestResultTrendFilter + // (required) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) QueryResultTrendForRelease(ctx context.Context, args QueryResultTrendForReleaseArgs) (*[]test.AggregatedDataForResultTrend, error) { + if args.Filter == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Filter"} + } + 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.Filter) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("107f23c3-359a-460a-a70c-63ee739f9f9a") + 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 []test.AggregatedDataForResultTrend + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryResultTrendForRelease function +type QueryResultTrendForReleaseArgs struct { + // (required) + Filter *test.TestResultTrendFilter + // (required) Project ID or project name + Project *string +} + +// [Preview API] Get history of a test method using TestHistoryQuery +func (client *ClientImpl) QueryTestHistory(ctx context.Context, args QueryTestHistoryArgs) (*test.TestHistoryQuery, error) { + if args.Filter == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Filter"} + } + 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.Filter) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2a41bd6a-8118-4403-b74e-5ba7492aed9d") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue test.TestHistoryQuery + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryTestHistory function +type QueryTestHistoryArgs struct { + // (required) TestHistoryQuery to get history + Filter *test.TestHistoryQuery + // (required) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) QueryTestMethodLinkedWorkItems(ctx context.Context, args QueryTestMethodLinkedWorkItemsArgs) (*test.TestToWorkItemLinks, 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.TestName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testName"} + } + queryParams.Add("testName", *args.TestName) + locationId, _ := uuid.Parse("cbd50bd7-f7ed-4e35-b127-4408ae6bfa2c") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue test.TestToWorkItemLinks + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryTestMethodLinkedWorkItems function +type QueryTestMethodLinkedWorkItemsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + TestName *string +} + +// [Preview API] +func (client *ClientImpl) QueryTestResultHistory(ctx context.Context, args QueryTestResultHistoryArgs) (*test.TestResultHistory, error) { + if args.Filter == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Filter"} + } + 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.Filter) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bdf7a97b-0395-4da8-9d5d-f957619327d1") + 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 test.TestResultHistory + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryTestResultHistory function +type QueryTestResultHistoryArgs struct { + // (required) + Filter *test.ResultsFilter + // (required) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) QueryTestResultsReportForBuild(ctx context.Context, args QueryTestResultsReportForBuildArgs) (*test.TestResultSummary, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "buildId"} + } + queryParams.Add("buildId", strconv.Itoa(*args.BuildId)) + if args.PublishContext != nil { + queryParams.Add("publishContext", *args.PublishContext) + } + if args.IncludeFailureDetails != nil { + queryParams.Add("includeFailureDetails", strconv.FormatBool(*args.IncludeFailureDetails)) + } + if args.BuildToCompare != nil { + if args.BuildToCompare.Id != nil { + queryParams.Add("buildToCompare.id", strconv.Itoa(*args.BuildToCompare.Id)) + } + if args.BuildToCompare.DefinitionId != nil { + queryParams.Add("buildToCompare.definitionId", strconv.Itoa(*args.BuildToCompare.DefinitionId)) + } + if args.BuildToCompare.Number != nil { + queryParams.Add("buildToCompare.number", *args.BuildToCompare.Number) + } + if args.BuildToCompare.Uri != nil { + queryParams.Add("buildToCompare.uri", *args.BuildToCompare.Uri) + } + if args.BuildToCompare.BuildSystem != nil { + queryParams.Add("buildToCompare.buildSystem", *args.BuildToCompare.BuildSystem) + } + if args.BuildToCompare.BranchName != nil { + queryParams.Add("buildToCompare.branchName", *args.BuildToCompare.BranchName) + } + if args.BuildToCompare.RepositoryId != nil { + queryParams.Add("buildToCompare.repositoryId", *args.BuildToCompare.RepositoryId) + } + } + locationId, _ := uuid.Parse("e009fa95-95a5-4ad4-9681-590043ce2423") + 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 test.TestResultSummary + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryTestResultsReportForBuild function +type QueryTestResultsReportForBuildArgs struct { + // (required) Project ID or project name + Project *string + // (required) + BuildId *int + // (optional) + PublishContext *string + // (optional) + IncludeFailureDetails *bool + // (optional) + BuildToCompare *test.BuildReference +} + +// [Preview API] +func (client *ClientImpl) QueryTestResultsReportForRelease(ctx context.Context, args QueryTestResultsReportForReleaseArgs) (*test.TestResultSummary, 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.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "releaseId"} + } + queryParams.Add("releaseId", strconv.Itoa(*args.ReleaseId)) + if args.ReleaseEnvId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "releaseEnvId"} + } + queryParams.Add("releaseEnvId", strconv.Itoa(*args.ReleaseEnvId)) + if args.PublishContext != nil { + queryParams.Add("publishContext", *args.PublishContext) + } + if args.IncludeFailureDetails != nil { + queryParams.Add("includeFailureDetails", strconv.FormatBool(*args.IncludeFailureDetails)) + } + if args.ReleaseToCompare != nil { + if args.ReleaseToCompare.Id != nil { + queryParams.Add("releaseToCompare.id", strconv.Itoa(*args.ReleaseToCompare.Id)) + } + if args.ReleaseToCompare.Name != nil { + queryParams.Add("releaseToCompare.name", *args.ReleaseToCompare.Name) + } + if args.ReleaseToCompare.EnvironmentId != nil { + queryParams.Add("releaseToCompare.environmentId", strconv.Itoa(*args.ReleaseToCompare.EnvironmentId)) + } + if args.ReleaseToCompare.EnvironmentName != nil { + queryParams.Add("releaseToCompare.environmentName", *args.ReleaseToCompare.EnvironmentName) + } + if args.ReleaseToCompare.DefinitionId != nil { + queryParams.Add("releaseToCompare.definitionId", strconv.Itoa(*args.ReleaseToCompare.DefinitionId)) + } + if args.ReleaseToCompare.EnvironmentDefinitionId != nil { + queryParams.Add("releaseToCompare.environmentDefinitionId", strconv.Itoa(*args.ReleaseToCompare.EnvironmentDefinitionId)) + } + if args.ReleaseToCompare.EnvironmentDefinitionName != nil { + queryParams.Add("releaseToCompare.environmentDefinitionName", *args.ReleaseToCompare.EnvironmentDefinitionName) + } + if args.ReleaseToCompare.CreationDate != nil { + queryParams.Add("releaseToCompare.creationDate", (*args.ReleaseToCompare.CreationDate).String()) + } + if args.ReleaseToCompare.EnvironmentCreationDate != nil { + queryParams.Add("releaseToCompare.environmentCreationDate", (*args.ReleaseToCompare.EnvironmentCreationDate).String()) + } + if args.ReleaseToCompare.Attempt != nil { + queryParams.Add("releaseToCompare.attempt", strconv.Itoa(*args.ReleaseToCompare.Attempt)) + } + } + locationId, _ := uuid.Parse("f10f9577-2c04-45ab-8c99-b26567a7cd55") + 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 test.TestResultSummary + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryTestResultsReportForRelease function +type QueryTestResultsReportForReleaseArgs struct { + // (required) Project ID or project name + Project *string + // (required) + ReleaseId *int + // (required) + ReleaseEnvId *int + // (optional) + PublishContext *string + // (optional) + IncludeFailureDetails *bool + // (optional) + ReleaseToCompare *test.ReleaseReference +} + +// [Preview API] +func (client *ClientImpl) QueryTestResultsSummaryForReleases(ctx context.Context, args QueryTestResultsSummaryForReleasesArgs) (*[]test.TestResultSummary, error) { + if args.Releases == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Releases"} + } + 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.Releases) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("f10f9577-2c04-45ab-8c99-b26567a7cd55") + 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 []test.TestResultSummary + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryTestResultsSummaryForReleases function +type QueryTestResultsSummaryForReleasesArgs struct { + // (required) + Releases *[]test.ReleaseReference + // (required) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) QueryTestResultWorkItems(ctx context.Context, args QueryTestResultWorkItemsArgs) (*[]test.WorkItemReference, 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.WorkItemCategory == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "workItemCategory"} + } + queryParams.Add("workItemCategory", *args.WorkItemCategory) + if args.AutomatedTestName != nil { + queryParams.Add("automatedTestName", *args.AutomatedTestName) + } + if args.TestCaseId != nil { + queryParams.Add("testCaseId", strconv.Itoa(*args.TestCaseId)) + } + if args.MaxCompleteDate != nil { + queryParams.Add("maxCompleteDate", (*args.MaxCompleteDate).String()) + } + if args.Days != nil { + queryParams.Add("days", strconv.Itoa(*args.Days)) + } + if args.WorkItemCount != nil { + queryParams.Add("$workItemCount", strconv.Itoa(*args.WorkItemCount)) + } + locationId, _ := uuid.Parse("f7401a26-331b-44fe-a470-f7ed35138e4a") + 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 []test.WorkItemReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryTestResultWorkItems function +type QueryTestResultWorkItemsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + WorkItemCategory *string + // (optional) + AutomatedTestName *string + // (optional) + TestCaseId *int + // (optional) + MaxCompleteDate *azuredevops.Time + // (optional) + Days *int + // (optional) + WorkItemCount *int +} + +// [Preview API] Query Test Runs based on filters. Mandatory fields are minLastUpdatedDate and maxLastUpdatedDate. +func (client *ClientImpl) QueryTestRuns(ctx context.Context, args QueryTestRunsArgs) (*QueryTestRunsResponseValue, 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.MinLastUpdatedDate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "minLastUpdatedDate"} + } + queryParams.Add("minLastUpdatedDate", (*args.MinLastUpdatedDate).String()) + if args.MaxLastUpdatedDate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "maxLastUpdatedDate"} + } + queryParams.Add("maxLastUpdatedDate", (*args.MaxLastUpdatedDate).String()) + if args.State != nil { + queryParams.Add("state", string(*args.State)) + } + if args.PlanIds != nil { + var stringList []string + for _, item := range *args.PlanIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("planIds", listAsString) + } + if args.IsAutomated != nil { + queryParams.Add("isAutomated", strconv.FormatBool(*args.IsAutomated)) + } + if args.PublishContext != nil { + queryParams.Add("publishContext", string(*args.PublishContext)) + } + if args.BuildIds != nil { + var stringList []string + for _, item := range *args.BuildIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("buildIds", listAsString) + } + if args.BuildDefIds != nil { + var stringList []string + for _, item := range *args.BuildDefIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("buildDefIds", listAsString) + } + if args.BranchName != nil { + queryParams.Add("branchName", *args.BranchName) + } + if args.ReleaseIds != nil { + var stringList []string + for _, item := range *args.ReleaseIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseIds", listAsString) + } + if args.ReleaseDefIds != nil { + var stringList []string + for _, item := range *args.ReleaseDefIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseDefIds", listAsString) + } + if args.ReleaseEnvIds != nil { + var stringList []string + for _, item := range *args.ReleaseEnvIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseEnvIds", listAsString) + } + if args.ReleaseEnvDefIds != nil { + var stringList []string + for _, item := range *args.ReleaseEnvDefIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseEnvDefIds", listAsString) + } + if args.RunTitle != nil { + queryParams.Add("runTitle", *args.RunTitle) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("364538f9-8062-4ce0-b024-75a0fb463f0d") + 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 QueryTestRunsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the QueryTestRuns function +type QueryTestRunsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Minimum Last Modified Date of run to be queried (Mandatory). + MinLastUpdatedDate *azuredevops.Time + // (required) Maximum Last Modified Date of run to be queried (Mandatory, difference between min and max date can be atmost 7 days). + MaxLastUpdatedDate *azuredevops.Time + // (optional) Current state of the Runs to be queried. + State *test.TestRunState + // (optional) Plan Ids of the Runs to be queried, comma separated list of valid ids. + PlanIds *[]int + // (optional) Automation type of the Runs to be queried. + IsAutomated *bool + // (optional) PublishContext of the Runs to be queried. + PublishContext *test.TestRunPublishContext + // (optional) Build Ids of the Runs to be queried, comma separated list of valid ids. + BuildIds *[]int + // (optional) Build Definition Ids of the Runs to be queried, comma separated list of valid ids. + BuildDefIds *[]int + // (optional) Source Branch name of the Runs to be queried. + BranchName *string + // (optional) Release Ids of the Runs to be queried, comma separated list of valid ids. + ReleaseIds *[]int + // (optional) Release Definition Ids of the Runs to be queried, comma separated list of valid ids. + ReleaseDefIds *[]int + // (optional) Release Environment Ids of the Runs to be queried, comma separated list of valid ids. + ReleaseEnvIds *[]int + // (optional) Release Environment Definition Ids of the Runs to be queried, comma separated list of valid ids. + ReleaseEnvDefIds *[]int + // (optional) Run Title of the Runs to be queried. + RunTitle *string + // (optional) Number of runs to be queried. Limit is 100 + Top *int + // (optional) continuationToken received from previous batch or null for first batch. It is not supposed to be created (or altered, if received from last batch) by user. + ContinuationToken *string +} + +// Return type for the QueryTestRuns function +type QueryTestRunsResponseValue struct { + Value []test.TestRun + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] +func (client *ClientImpl) QueryTestSummaryByRequirement(ctx context.Context, args QueryTestSummaryByRequirementArgs) (*[]test.TestSummaryForWorkItem, error) { + if args.ResultsContext == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ResultsContext"} + } + 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.WorkItemIds != nil { + var stringList []string + for _, item := range *args.WorkItemIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("workItemIds", listAsString) + } + body, marshalErr := json.Marshal(*args.ResultsContext) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("3b7fd26f-c335-4e55-afc1-a588f5e2af3c") + 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 []test.TestSummaryForWorkItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryTestSummaryByRequirement function +type QueryTestSummaryByRequirementArgs struct { + // (required) + ResultsContext *test.TestResultsContext + // (required) Project ID or project name + Project *string + // (optional) + WorkItemIds *[]int +} + +// [Preview API] +func (client *ClientImpl) TestLogStoreEndpointDetailsForBuild(ctx context.Context, args TestLogStoreEndpointDetailsForBuildArgs) (*test.TestLogStoreEndpointDetails, 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.BuildId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "buildId"} + } + queryParams.Add("buildId", strconv.Itoa(*args.BuildId)) + if args.TestLogStoreOperationType == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testLogStoreOperationType"} + } + queryParams.Add("testLogStoreOperationType", string(*args.TestLogStoreOperationType)) + locationId, _ := uuid.Parse("39b09be7-f0c9-4a83-a513-9ae31b45c56f") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue test.TestLogStoreEndpointDetails + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the TestLogStoreEndpointDetailsForBuild function +type TestLogStoreEndpointDetailsForBuildArgs struct { + // (required) Project ID or project name + Project *string + // (required) + BuildId *int + // (required) + TestLogStoreOperationType *test.TestLogStoreOperationType +} + +// [Preview API] +func (client *ClientImpl) TestLogStoreEndpointDetailsForResult(ctx context.Context, args TestLogStoreEndpointDetailsForResultArgs) (*test.TestLogStoreEndpointDetails, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + if args.ResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ResultId"} + } + routeValues["resultId"] = strconv.Itoa(*args.ResultId) + + queryParams := url.Values{} + if args.SubResultId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "subResultId"} + } + queryParams.Add("subResultId", strconv.Itoa(*args.SubResultId)) + if args.FilePath == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "filePath"} + } + queryParams.Add("filePath", *args.FilePath) + if args.Type == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "type"} + } + queryParams.Add("type", string(*args.Type)) + locationId, _ := uuid.Parse("da630b37-1236-45b5-945e-1d7bdb673850") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue test.TestLogStoreEndpointDetails + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the TestLogStoreEndpointDetailsForResult function +type TestLogStoreEndpointDetailsForResultArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + ResultId *int + // (required) + SubResultId *int + // (required) + FilePath *string + // (required) + Type *test.TestLogType +} + +// [Preview API] +func (client *ClientImpl) TestLogStoreEndpointDetailsForRun(ctx context.Context, args TestLogStoreEndpointDetailsForRunArgs) (*test.TestLogStoreEndpointDetails, 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.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + queryParams := url.Values{} + if args.TestLogStoreOperationType == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "testLogStoreOperationType"} + } + queryParams.Add("testLogStoreOperationType", string(*args.TestLogStoreOperationType)) + if args.FilePath != nil { + queryParams.Add("filePath", *args.FilePath) + } + if args.Type != nil { + queryParams.Add("type", string(*args.Type)) + } + locationId, _ := uuid.Parse("67eb3f92-6c97-4fd9-8b63-6cbdc7e526ea") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue test.TestLogStoreEndpointDetails + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the TestLogStoreEndpointDetailsForRun function +type TestLogStoreEndpointDetailsForRunArgs struct { + // (required) Project ID or project name + Project *string + // (required) + RunId *int + // (required) + TestLogStoreOperationType *test.TestLogStoreOperationType + // (optional) + FilePath *string + // (optional) + Type *test.TestLogType +} + +// [Preview API] http://(tfsserver):8080/tfs/DefaultCollection/_apis/test/CodeCoverage?buildId=10 Request: Json of code coverage summary +func (client *ClientImpl) UpdateCodeCoverageSummary(ctx context.Context, args UpdateCodeCoverageSummaryArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.BuildId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "buildId"} + } + queryParams.Add("buildId", strconv.Itoa(*args.BuildId)) + body, marshalErr := json.Marshal(*args.CoverageData) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("9b3e1ece-c6ab-4fbb-8167-8a32a0c92216") + _, 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 err + } + + return nil +} + +// Arguments for the UpdateCodeCoverageSummary function +type UpdateCodeCoverageSummaryArgs struct { + // (required) Project ID or project name + Project *string + // (required) + BuildId *int + // (optional) + CoverageData *test.CodeCoverageData +} + +// [Preview API] Update project settings of test results +func (client *ClientImpl) UpdatePipelinesTestSettings(ctx context.Context, args UpdatePipelinesTestSettingsArgs) (*test.TestResultsSettings, error) { + if args.TestResultsUpdateSettings == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TestResultsUpdateSettings"} + } + 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.TestResultsUpdateSettings) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("7319952e-e5a9-4e19-a006-84f3be8b7c68") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.3", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue test.TestResultsSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdatePipelinesTestSettings function +type UpdatePipelinesTestSettingsArgs struct { + // (required) + TestResultsUpdateSettings *test.TestResultsUpdateSettings + // (required) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) UpdateTestResults(ctx context.Context, args UpdateTestResultsArgs) (*[]test.TestCaseResult, error) { + if args.Results == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Results"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + body, marshalErr := json.Marshal(*args.Results) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("02afa165-e79a-4d70-8f0c-2af0f35b4e07") + 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 []test.TestCaseResult + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestResults function +type UpdateTestResultsArgs struct { + // (required) + Results *[]test.TestCaseResult + // (required) Project ID or project name + Project *string + // (required) + RunId *int +} + +// [Preview API] +func (client *ClientImpl) UpdateTestRun(ctx context.Context, args UpdateTestRunArgs) (*test.TestRun, error) { + if args.RunUpdateModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunUpdateModel"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.RunId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RunId"} + } + routeValues["runId"] = strconv.Itoa(*args.RunId) + + body, marshalErr := json.Marshal(*args.RunUpdateModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("364538f9-8062-4ce0-b024-75a0fb463f0d") + 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 test.TestRun + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTestRun function +type UpdateTestRunArgs struct { + // (required) + RunUpdateModel *test.RunUpdateModel + // (required) Project ID or project name + Project *string + // (required) + RunId *int +} diff --git a/azuredevops/testresults/models.go b/azuredevops/testresults/models.go new file mode 100644 index 00000000..7bf37918 --- /dev/null +++ b/azuredevops/testresults/models.go @@ -0,0 +1,15 @@ +// -------------------------------------------------------------------------------------------- +// 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 testresults + +type Attachment struct { + CompressionType *string `json:"compressionType,omitempty"` + FileName *string `json:"fileName,omitempty"` + Stream interface{} `json:"stream,omitempty"` +} diff --git a/azuredevops/testservice/models.go b/azuredevops/testservice/models.go new file mode 100644 index 00000000..5d14dba2 --- /dev/null +++ b/azuredevops/testservice/models.go @@ -0,0 +1,757 @@ +// -------------------------------------------------------------------------------------------- +// 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 testservice + +import ( + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type AgentGroup struct { + // User that created the agent group + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Time agent group was created + CreationTime *azuredevops.Time `json:"creationTime,omitempty"` + // Id of the agent group + GroupId *string `json:"groupId,omitempty"` + // The name of the agent group + GroupName *string `json:"groupName,omitempty"` + MachineAccessData *[]AgentGroupAccessData `json:"machineAccessData,omitempty"` + // Machine configuration + MachineConfiguration *WebApiUserLoadTestMachineInput `json:"machineConfiguration,omitempty"` + // Tenant Id + TenantId *string `json:"tenantId,omitempty"` +} + +type AgentGroupAccessData struct { + // Type Specific details + Details *string `json:"details,omitempty"` + // Access string + StorageConnectionString *string `json:"storageConnectionString,omitempty"` + // Endpoint for the service + StorageEndPoint *string `json:"storageEndPoint,omitempty"` + // Identifier for the storage (eg. table name) + StorageName *string `json:"storageName,omitempty"` + // Type of the store (table, queue, blob) + StorageType *string `json:"storageType,omitempty"` +} + +type Application struct { + // Unique Id of the Application Component + ApplicationId *string `json:"applicationId,omitempty"` + // Description of the Application component + Description *string `json:"description,omitempty"` + // The Name of the Application component + Name *string `json:"name,omitempty"` + // Path identifier of the Application component + Path *string `json:"path,omitempty"` + // Character used to separate paths for counters + PathSeperator *string `json:"pathSeperator,omitempty"` + // Type identifier of the Application component under test + Type *string `json:"type,omitempty"` + // Version of the Application Component + Version *string `json:"version,omitempty"` +} + +type ApplicationCounters struct { + // The unique Id of the Application that the counter belongs + ApplicationId *string `json:"applicationId,omitempty"` + // Description of autCounter + Description *string `json:"description,omitempty"` + // The unique Id for the AutCounter + Id *string `json:"id,omitempty"` + // Whether the autCounter is a default counter or not + IsDefault *bool `json:"isDefault,omitempty"` + // Name of the AutCounter + Name *string `json:"name,omitempty"` + // The Path of the the autcounter wrt to hierarchy + Path *string `json:"path,omitempty"` +} + +type ApplicationType struct { + // Helper link url + ActionUriLink *string `json:"actionUriLink,omitempty"` + // The link that points to aut results site + AutPortalLink *string `json:"autPortalLink,omitempty"` + // true if application results collection is enabled for this tenant + IsEnabled *bool `json:"isEnabled,omitempty"` + // the max no. of application components allowed for collection per run + MaxComponentsAllowedForCollection *int `json:"maxComponentsAllowedForCollection,omitempty"` + // The max no. of counters that can be collected per aut + MaxCountersAllowed *int `json:"maxCountersAllowed,omitempty"` + // Application Type + Type *string `json:"type,omitempty"` +} + +type BrowserMix struct { + BrowserName *string `json:"browserName,omitempty"` + BrowserPercentage *float32 `json:"browserPercentage,omitempty"` +} + +type CltCustomerIntelligenceData struct { + Area *string `json:"area,omitempty"` + Feature *string `json:"feature,omitempty"` + Properties *map[string]interface{} `json:"properties,omitempty"` +} + +type CounterGroup struct { + GroupName *string `json:"groupName,omitempty"` + Url *string `json:"url,omitempty"` +} + +type CounterInstanceSamples struct { + Count *int `json:"count,omitempty"` + CounterInstanceId *string `json:"counterInstanceId,omitempty"` + // The time of next refresh + NextRefreshTime *azuredevops.Time `json:"nextRefreshTime,omitempty"` + Values *[]CounterSample `json:"values,omitempty"` +} + +type CounterSample struct { + BaseValue *uint64 `json:"baseValue,omitempty"` + ComputedValue *float32 `json:"computedValue,omitempty"` + CounterFrequency *uint64 `json:"counterFrequency,omitempty"` + CounterInstanceId *string `json:"counterInstanceId,omitempty"` + CounterType *string `json:"counterType,omitempty"` + IntervalEndDate *azuredevops.Time `json:"intervalEndDate,omitempty"` + IntervalNumber *int `json:"intervalNumber,omitempty"` + RawValue *uint64 `json:"rawValue,omitempty"` + SystemFrequency *uint64 `json:"systemFrequency,omitempty"` + TimeStamp *uint64 `json:"timeStamp,omitempty"` +} + +type CounterSampleQueryDetails struct { + // The instanceId for which samples are required + CounterInstanceId *string `json:"counterInstanceId,omitempty"` + FromInterval *int `json:"fromInterval,omitempty"` + ToInterval *int `json:"toInterval,omitempty"` +} + +type CounterSamplesResult struct { + // Count of the samples + Count *int `json:"count,omitempty"` + // Maximum number of samples returned in this object + MaxBatchSize *int `json:"maxBatchSize,omitempty"` + // Count of the samples + TotalSamplesCount *int `json:"totalSamplesCount,omitempty"` + // The result samples + Values *[]CounterInstanceSamples `json:"values,omitempty"` +} + +type Diagnostics struct { + DiagnosticStoreConnectionString *string `json:"diagnosticStoreConnectionString,omitempty"` + LastModifiedTime *azuredevops.Time `json:"lastModifiedTime,omitempty"` + RelativePathToDiagnosticFiles *string `json:"relativePathToDiagnosticFiles,omitempty"` +} + +type DropAccessData struct { + DropContainerUrl *string `json:"dropContainerUrl,omitempty"` + // The SaSkey to use for the drop. + SasKey *string `json:"sasKey,omitempty"` +} + +type ErrorDetails struct { + LastErrorDate *azuredevops.Time `json:"lastErrorDate,omitempty"` + MessageText *string `json:"messageText,omitempty"` + Occurrences *int `json:"occurrences,omitempty"` + Request *string `json:"request,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StackTrace *string `json:"stackTrace,omitempty"` + TestCaseName *string `json:"testCaseName,omitempty"` +} + +type LoadGenerationGeoLocation struct { + Location *string `json:"location,omitempty"` + Percentage *int `json:"percentage,omitempty"` +} + +type LoadTest struct { +} + +type LoadTestDefinition struct { + AgentCount *int `json:"agentCount,omitempty"` + BrowserMixs *[]BrowserMix `json:"browserMixs,omitempty"` + CoreCount *int `json:"coreCount,omitempty"` + CoresPerAgent *int `json:"coresPerAgent,omitempty"` + LoadGenerationGeoLocations *[]LoadGenerationGeoLocation `json:"loadGenerationGeoLocations,omitempty"` + LoadPatternName *string `json:"loadPatternName,omitempty"` + LoadTestName *string `json:"loadTestName,omitempty"` + MaxVusers *int `json:"maxVusers,omitempty"` + RunDuration *int `json:"runDuration,omitempty"` + SamplingRate *int `json:"samplingRate,omitempty"` + ThinkTime *int `json:"thinkTime,omitempty"` + Urls *[]string `json:"urls,omitempty"` +} + +type LoadTestErrorDetails struct { + LastErrorDate *azuredevops.Time `json:"lastErrorDate,omitempty"` + MessageText *string `json:"messageText,omitempty"` + Occurrences *int `json:"occurrences,omitempty"` + Request *string `json:"request,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StackTrace *string `json:"stackTrace,omitempty"` + SubType *string `json:"subType,omitempty"` + TestCaseName *string `json:"testCaseName,omitempty"` + Type *string `json:"type,omitempty"` +} + +type LoadTestErrors struct { + Count *int `json:"count,omitempty"` + Occurrences *int `json:"occurrences,omitempty"` + Types *[]interface{} `json:"types,omitempty"` + Url *string `json:"url,omitempty"` +} + +type LoadTestMachineType string + +type loadTestMachineTypeValuesType struct { + Default LoadTestMachineType + CltLoadAgent LoadTestMachineType + UserLoadAgent LoadTestMachineType +} + +var LoadTestMachineTypeValues = loadTestMachineTypeValuesType{ + Default: "default", + CltLoadAgent: "cltLoadAgent", + UserLoadAgent: "userLoadAgent", +} + +type LoadTestRunDetails struct { + AgentCount *int `json:"agentCount,omitempty"` + CoreCount *int `json:"coreCount,omitempty"` + CoresPerAgent *int `json:"coresPerAgent,omitempty"` + Duration *int `json:"duration,omitempty"` + LoadGeneratorMachinesType *LoadTestMachineType `json:"loadGeneratorMachinesType,omitempty"` + SamplingInterval *int `json:"samplingInterval,omitempty"` + WarmUpDuration *int `json:"warmUpDuration,omitempty"` + VirtualUserCount *int `json:"virtualUserCount,omitempty"` +} + +type LoadTestRunSettings struct { + AgentCount *int `json:"agentCount,omitempty"` + CoreCount *int `json:"coreCount,omitempty"` + CoresPerAgent *int `json:"coresPerAgent,omitempty"` + Duration *int `json:"duration,omitempty"` + LoadGeneratorMachinesType *LoadTestMachineType `json:"loadGeneratorMachinesType,omitempty"` + SamplingInterval *int `json:"samplingInterval,omitempty"` + WarmUpDuration *int `json:"warmUpDuration,omitempty"` +} + +type LoadTestTypes string + +type loadTestTypesValuesType struct { + VisualStudioLoadTest LoadTestTypes + JMeter LoadTestTypes + OldLoadTestFile LoadTestTypes +} + +var LoadTestTypesValues = loadTestTypesValuesType{ + VisualStudioLoadTest: "visualStudioLoadTest", + JMeter: "jMeter", + OldLoadTestFile: "oldLoadTestFile", +} + +type MessageSource string + +type messageSourceValuesType struct { + SetupScript MessageSource + CleanupScript MessageSource + Validation MessageSource + Other MessageSource + AutCounterCollection MessageSource +} + +var MessageSourceValues = messageSourceValuesType{ + SetupScript: "setupScript", + CleanupScript: "cleanupScript", + Validation: "validation", + Other: "other", + AutCounterCollection: "autCounterCollection", +} + +type MessageType string + +type messageTypeValuesType struct { + Info MessageType + Output MessageType + Error MessageType + Warning MessageType + Critical MessageType +} + +var MessageTypeValues = messageTypeValuesType{ + Info: "info", + Output: "output", + Error: "error", + Warning: "warning", + Critical: "critical", +} + +type OverridableRunSettings struct { + LoadGeneratorMachinesType *LoadTestMachineType `json:"loadGeneratorMachinesType,omitempty"` + StaticAgentRunSettings *StaticAgentRunSetting `json:"staticAgentRunSettings,omitempty"` +} + +type PageSummary struct { + AveragePageTime *float64 `json:"averagePageTime,omitempty"` + PageUrl *string `json:"pageUrl,omitempty"` + PercentagePagesMeetingGoal *int `json:"percentagePagesMeetingGoal,omitempty"` + PercentileData *[]SummaryPercentileData `json:"percentileData,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + TestName *string `json:"testName,omitempty"` + TotalPages *int `json:"totalPages,omitempty"` +} + +type ProcessorArchitecture string + +type processorArchitectureValuesType struct { + None ProcessorArchitecture + Msil ProcessorArchitecture + X86 ProcessorArchitecture + Ia64 ProcessorArchitecture + Amd64 ProcessorArchitecture + Arm ProcessorArchitecture +} + +var ProcessorArchitectureValues = processorArchitectureValuesType{ + None: "none", + Msil: "msil", + X86: "x86", + Ia64: "ia64", + Amd64: "amd64", + Arm: "arm", +} + +type RequestSummary struct { + AverageResponseTime *float64 `json:"averageResponseTime,omitempty"` + FailedRequests *int `json:"failedRequests,omitempty"` + PassedRequests *int `json:"passedRequests,omitempty"` + PercentileData *[]SummaryPercentileData `json:"percentileData,omitempty"` + RequestsPerSec *float64 `json:"requestsPerSec,omitempty"` + RequestUrl *string `json:"requestUrl,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + TestName *string `json:"testName,omitempty"` + TotalRequests *int `json:"totalRequests,omitempty"` +} + +type ScenarioSummary struct { + MaxUserLoad *int `json:"maxUserLoad,omitempty"` + MinUserLoad *int `json:"minUserLoad,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` +} + +type StaticAgent struct { + AgentGroupId *string `json:"agentGroupId,omitempty"` + AgentGroupName *string `json:"agentGroupName,omitempty"` + LastHeartBeat *azuredevops.Time `json:"lastHeartBeat,omitempty"` + Name *string `json:"name,omitempty"` + State *string `json:"state,omitempty"` +} + +type StaticAgentRunSetting struct { + LoadGeneratorMachinesType *LoadTestMachineType `json:"loadGeneratorMachinesType,omitempty"` + StaticAgentGroupName *string `json:"staticAgentGroupName,omitempty"` +} + +type SubType struct { + Count *int `json:"count,omitempty"` + ErrorDetailList *[]ErrorDetails `json:"errorDetailList,omitempty"` + Occurrences *int `json:"occurrences,omitempty"` + SubTypeName *string `json:"subTypeName,omitempty"` + Url *string `json:"url,omitempty"` +} + +type SummaryPercentileData struct { + Percentile *int `json:"percentile,omitempty"` + PercentileValue *float64 `json:"percentileValue,omitempty"` +} + +type TestDefinition struct { + // Data for accessing the drop and not persisted in storage + AccessData *DropAccessData `json:"accessData,omitempty"` + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + Id *string `json:"id,omitempty"` + LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` + LastModifiedDate *azuredevops.Time `json:"lastModifiedDate,omitempty"` + LoadTestType *LoadTestTypes `json:"loadTestType,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + // Geo location from where load is generated + LoadGenerationGeoLocations *[]LoadGenerationGeoLocation `json:"loadGenerationGeoLocations,omitempty"` + LoadTestDefinitionSource *string `json:"loadTestDefinitionSource,omitempty"` + RunSettings *LoadTestRunSettings `json:"runSettings,omitempty"` + StaticAgentRunSettings *StaticAgentRunSetting `json:"staticAgentRunSettings,omitempty"` + TestDetails *LoadTest `json:"testDetails,omitempty"` +} + +type TestDefinitionBasic struct { + // Data for accessing the drop and not persisted in storage + AccessData *DropAccessData `json:"accessData,omitempty"` + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + Id *string `json:"id,omitempty"` + LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` + LastModifiedDate *azuredevops.Time `json:"lastModifiedDate,omitempty"` + LoadTestType *LoadTestTypes `json:"loadTestType,omitempty"` + Name *string `json:"name,omitempty"` +} + +type TestDrop struct { + // Data for accessing the drop and not persisted in storage + AccessData *DropAccessData `json:"accessData,omitempty"` + // Time at which the drop is created + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Identifies the type of drop + DropType *string `json:"dropType,omitempty"` + // Drop Id + Id *string `json:"id,omitempty"` + // LoadTest definition of the run for which testdrop is created + LoadTestDefinition *LoadTestDefinition `json:"loadTestDefinition,omitempty"` + // Test Run Id + TestRunId *string `json:"testRunId,omitempty"` +} + +// An abstracted reference to some other resource. This class is used to provide the load test data contracts with a uniform way to reference other resources in a way that provides easy traversal through links. +type TestDropRef struct { + // Id of the resource + Id *string `json:"id,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` +} + +type TestResults struct { + // The uri to the test run results file. + CloudLoadTestSolutionUrl *string `json:"cloudLoadTestSolutionUrl,omitempty"` + CounterGroups *[]CounterGroup `json:"counterGroups,omitempty"` + // The object contains diagnostic details + Diagnostics *Diagnostics `json:"diagnostics,omitempty"` + // The uri to the test run results file. + ResultsUrl *string `json:"resultsUrl,omitempty"` +} + +type TestResultsSummary struct { + OverallPageSummary *PageSummary `json:"overallPageSummary,omitempty"` + OverallRequestSummary *RequestSummary `json:"overallRequestSummary,omitempty"` + OverallScenarioSummary *ScenarioSummary `json:"overallScenarioSummary,omitempty"` + OverallTestSummary *TestSummary `json:"overallTestSummary,omitempty"` + OverallTransactionSummary *TransactionSummary `json:"overallTransactionSummary,omitempty"` + TopSlowPages *[]PageSummary `json:"topSlowPages,omitempty"` + TopSlowRequests *[]RequestSummary `json:"topSlowRequests,omitempty"` + TopSlowTests *[]TestSummary `json:"topSlowTests,omitempty"` + TopSlowTransactions *[]TransactionSummary `json:"topSlowTransactions,omitempty"` +} + +type TestRun struct { + // Vss User identity who created the test run. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets the creation time of the test run + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Vss User identity who deleted the test run. + DeletedBy *webapi.IdentityRef `json:"deletedBy,omitempty"` + // Gets the deleted time of the test run + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Gets the finish time of the test run + FinishedDate *azuredevops.Time `json:"finishedDate,omitempty"` + // Gets the unique identifier for the test run definition. + Id *string `json:"id,omitempty"` + LoadGenerationGeoLocations *[]LoadGenerationGeoLocation `json:"loadGenerationGeoLocations,omitempty"` + // Gets the load test file of the test run definition. + LoadTestFileName *string `json:"loadTestFileName,omitempty"` + // Gets the name of the test run definition. + Name *string `json:"name,omitempty"` + // Gets the number of the test run (unique within a tenant) + RunNumber *int `json:"runNumber,omitempty"` + // Test run source like Ibiza,VSO,BuildVNext, etc. + RunSource *string `json:"runSource,omitempty"` + // Run specific details. + RunSpecificDetails *LoadTestRunDetails `json:"runSpecificDetails,omitempty"` + // Run type like VisualStudioLoadTest or JMeterLoadTest + RunType *TestRunType `json:"runType,omitempty"` + // State of the test run. + State *TestRunState `json:"state,omitempty"` + Url *string `json:"url,omitempty"` + // Message associated to state change, contains details of infrastructure error. + AbortMessage *TestRunAbortMessage `json:"abortMessage,omitempty"` + // true if aut counter collection could not start due to some critical error for this run. + AutInitializationError *bool `json:"autInitializationError,omitempty"` + // Whether run is chargeable or not Its chargeable once we configured agent and sent start signal + Chargeable *bool `json:"chargeable,omitempty"` + // Whether run is chargeable or not The Charged VUser Minutes for the RUN + ChargedVUserminutes *int `json:"chargedVUserminutes,omitempty"` + // Test run description. + Description *string `json:"description,omitempty"` + // Gets the time when the test run execution finished + ExecutionFinishedDate *azuredevops.Time `json:"executionFinishedDate,omitempty"` + // Gets the time when the test run warmup finished(if warmup was specified) and load test started + ExecutionStartedDate *azuredevops.Time `json:"executionStartedDate,omitempty"` + // Gets the time when the test run was queued + QueuedDate *azuredevops.Time `json:"queuedDate,omitempty"` + // Retention state of the run + RetentionState *TestRunRetentionState `json:"retentionState,omitempty"` + RunSourceIdentifier *string `json:"runSourceIdentifier,omitempty"` + // The uri to the run source. + RunSourceUrl *string `json:"runSourceUrl,omitempty"` + // Vss User identity who created the test run. + StartedBy *webapi.IdentityRef `json:"startedBy,omitempty"` + // When the test run started execution. + StartedDate *azuredevops.Time `json:"startedDate,omitempty"` + // Vss User identity who created the test run. + StoppedBy *webapi.IdentityRef `json:"stoppedBy,omitempty"` + // SubState is more granular description of the state + SubState *TestRunSubState `json:"subState,omitempty"` + SupersedeRunSettings *OverridableRunSettings `json:"supersedeRunSettings,omitempty"` + // Drop associated with this test run + TestDrop *TestDropRef `json:"testDrop,omitempty"` + // The Test settings for the test run + TestSettings *TestSettings `json:"testSettings,omitempty"` + // Gets the time when the test run warmup started + WarmUpStartedDate *azuredevops.Time `json:"warmUpStartedDate,omitempty"` + // The uri to the vso detailed result. + WebResultUrl *string `json:"webResultUrl,omitempty"` +} + +type TestRunAbortMessage struct { + Action *string `json:"action,omitempty"` + Cause *string `json:"cause,omitempty"` + Details *[]string `json:"details,omitempty"` + LoggedDate *azuredevops.Time `json:"loggedDate,omitempty"` + Source *string `json:"source,omitempty"` +} + +type TestRunBasic struct { + // Vss User identity who created the test run. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets the creation time of the test run + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Vss User identity who deleted the test run. + DeletedBy *webapi.IdentityRef `json:"deletedBy,omitempty"` + // Gets the deleted time of the test run + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Gets the finish time of the test run + FinishedDate *azuredevops.Time `json:"finishedDate,omitempty"` + // Gets the unique identifier for the test run definition. + Id *string `json:"id,omitempty"` + LoadGenerationGeoLocations *[]LoadGenerationGeoLocation `json:"loadGenerationGeoLocations,omitempty"` + // Gets the load test file of the test run definition. + LoadTestFileName *string `json:"loadTestFileName,omitempty"` + // Gets the name of the test run definition. + Name *string `json:"name,omitempty"` + // Gets the number of the test run (unique within a tenant) + RunNumber *int `json:"runNumber,omitempty"` + // Test run source like Ibiza,VSO,BuildVNext, etc. + RunSource *string `json:"runSource,omitempty"` + // Run specific details. + RunSpecificDetails *LoadTestRunDetails `json:"runSpecificDetails,omitempty"` + // Run type like VisualStudioLoadTest or JMeterLoadTest + RunType *TestRunType `json:"runType,omitempty"` + // State of the test run. + State *TestRunState `json:"state,omitempty"` + Url *string `json:"url,omitempty"` +} + +type TestRunCounterInstance struct { + // CategoryName for this counter + CategoryName *string `json:"categoryName,omitempty"` + // Combination of source and SourceInstanceId + CounterInstanceId *string `json:"counterInstanceId,omitempty"` + // Name of the counter Eg: Errors/Sec + CounterName *string `json:"counterName,omitempty"` + // Units for this counter. Empty string for mere numbers + CounterUnits *string `json:"counterUnits,omitempty"` + // Instance Name Eg: _Avg,_Total etc + InstanceName *string `json:"instanceName,omitempty"` + // true if this counter instance is a default counter + IsPreselectedCounter *bool `json:"isPreselectedCounter,omitempty"` + // Machine from where this counter was collected Used in case of machine specific counters like - Agent CPU and memory etc. + MachineName *string `json:"machineName,omitempty"` + // Counter Groups to which this counter instance is part of + PartOfCounterGroups *[]string `json:"partOfCounterGroups,omitempty"` + // Summary result for this counter instance + SummaryData *WebInstanceSummaryData `json:"summaryData,omitempty"` + // A unique name for this counter instance + UniqueName *string `json:"uniqueName,omitempty"` +} + +type TestRunMessage struct { + // Agent Id + AgentId *string `json:"agentId,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + LoggedDate *azuredevops.Time `json:"loggedDate,omitempty"` + Message *string `json:"message,omitempty"` + // Message Id + MessageId *string `json:"messageId,omitempty"` + MessageSource *MessageSource `json:"messageSource,omitempty"` + MessageType *MessageType `json:"messageType,omitempty"` + // Id of the test run + TestRunId *string `json:"testRunId,omitempty"` + Url *string `json:"url,omitempty"` +} + +type TestRunRetentionState string + +type testRunRetentionStateValuesType struct { + None TestRunRetentionState + MarkedForDeletion TestRunRetentionState + Deleted TestRunRetentionState + Retain TestRunRetentionState +} + +var TestRunRetentionStateValues = testRunRetentionStateValuesType{ + None: "none", + MarkedForDeletion: "markedForDeletion", + Deleted: "deleted", + Retain: "retain", +} + +type TestRunState string + +type testRunStateValuesType struct { + Pending TestRunState + Queued TestRunState + InProgress TestRunState + Stopping TestRunState + Completed TestRunState + Aborted TestRunState + Error TestRunState +} + +var TestRunStateValues = testRunStateValuesType{ + Pending: "pending", + Queued: "queued", + InProgress: "inProgress", + Stopping: "stopping", + Completed: "completed", + Aborted: "aborted", + Error: "error", +} + +type TestRunSubState string + +type testRunSubStateValuesType struct { + None TestRunSubState + ValidatingTestRun TestRunSubState + AcquiringResources TestRunSubState + ConfiguringAgents TestRunSubState + ExecutingSetupScript TestRunSubState + WarmingUp TestRunSubState + RunningTest TestRunSubState + ExecutingCleanupScript TestRunSubState + CollectingResults TestRunSubState + Success TestRunSubState + PartialSuccess TestRunSubState +} + +var TestRunSubStateValues = testRunSubStateValuesType{ + None: "none", + ValidatingTestRun: "validatingTestRun", + AcquiringResources: "acquiringResources", + ConfiguringAgents: "configuringAgents", + ExecutingSetupScript: "executingSetupScript", + WarmingUp: "warmingUp", + RunningTest: "runningTest", + ExecutingCleanupScript: "executingCleanupScript", + CollectingResults: "collectingResults", + Success: "success", + PartialSuccess: "partialSuccess", +} + +type TestRunType string + +type testRunTypeValuesType struct { + VisualStudioLoadTest TestRunType + JMeterLoadTest TestRunType +} + +var TestRunTypeValues = testRunTypeValuesType{ + VisualStudioLoadTest: "visualStudioLoadTest", + JMeterLoadTest: "jMeterLoadTest", +} + +type TestSettings struct { + // Cleanup command + CleanupCommand *string `json:"cleanupCommand,omitempty"` + // Processor Architecture chosen + HostProcessPlatform *ProcessorArchitecture `json:"hostProcessPlatform,omitempty"` + // Setup command + SetupCommand *string `json:"setupCommand,omitempty"` +} + +type TestSummary struct { + AverageTestTime *float64 `json:"averageTestTime,omitempty"` + FailedTests *int `json:"failedTests,omitempty"` + PassedTests *int `json:"passedTests,omitempty"` + PercentileData *[]SummaryPercentileData `json:"percentileData,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + TestName *string `json:"testName,omitempty"` + TotalTests *int `json:"totalTests,omitempty"` +} + +type TransactionSummary struct { + AverageResponseTime *float64 `json:"averageResponseTime,omitempty"` + AverageTransactionTime *float64 `json:"averageTransactionTime,omitempty"` + PercentileData *[]SummaryPercentileData `json:"percentileData,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + TestName *string `json:"testName,omitempty"` + TotalTransactions *int `json:"totalTransactions,omitempty"` + TransactionName *string `json:"transactionName,omitempty"` +} + +type Type struct { + Count *int `json:"count,omitempty"` + Occurrences *int `json:"occurrences,omitempty"` + SubTypes *[]SubType `json:"subTypes,omitempty"` + TypeName *string `json:"typeName,omitempty"` + Url *string `json:"url,omitempty"` +} + +type WebApiLoadTestMachineInput struct { + MachineGroupId *string `json:"machineGroupId,omitempty"` + MachineType *LoadTestMachineType `json:"machineType,omitempty"` + SetupConfiguration *WebApiSetupParamaters `json:"setupConfiguration,omitempty"` + SupportedRunTypes *[]TestRunType `json:"supportedRunTypes,omitempty"` +} + +type WebApiMachineConfiguration string + +type webApiMachineConfigurationValuesType struct { + UseXcopyTmiAgent WebApiMachineConfiguration + DisablingStrongNameVerification WebApiMachineConfiguration + TempFolderPath WebApiMachineConfiguration + ConfigureTcpParameters WebApiMachineConfiguration +} + +var WebApiMachineConfigurationValues = webApiMachineConfigurationValuesType{ + UseXcopyTmiAgent: "useXcopyTmiAgent", + DisablingStrongNameVerification: "disablingStrongNameVerification", + TempFolderPath: "tempFolderPath", + ConfigureTcpParameters: "configureTcpParameters", +} + +type WebApiSetupParamaters struct { + Configurations *map[WebApiMachineConfiguration]string `json:"configurations,omitempty"` +} + +// This can eventually evolve as the ultimate JSON file that user can use to configure their machine(s) against CLT +type WebApiUserLoadTestMachineInput struct { + MachineGroupId *string `json:"machineGroupId,omitempty"` + MachineType *LoadTestMachineType `json:"machineType,omitempty"` + SetupConfiguration *WebApiSetupParamaters `json:"setupConfiguration,omitempty"` + SupportedRunTypes *[]TestRunType `json:"supportedRunTypes,omitempty"` + AgentGroupName *string `json:"agentGroupName,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + UserLoadAgentResourcesUri *string `json:"userLoadAgentResourcesUri,omitempty"` + VstsAccountUri *string `json:"vstsAccountUri,omitempty"` +} + +type WebInstanceSummaryData struct { + Average *float64 `json:"average,omitempty"` + Max *float64 `json:"max,omitempty"` + Min *float64 `json:"min,omitempty"` +} diff --git a/azuredevops/tfvc/client.go b/azuredevops/tfvc/client.go new file mode 100644 index 00000000..521b13e1 --- /dev/null +++ b/azuredevops/tfvc/client.go @@ -0,0 +1,1212 @@ +// -------------------------------------------------------------------------------------------- +// 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 tfvc + +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/git" + "io" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("8aa40520-446d-40e6-89f6-9c9f9ce44c48") + +type Client interface { + // Create a new changeset. + CreateChangeset(context.Context, CreateChangesetArgs) (*git.TfvcChangesetRef, error) + // Returns changesets for a given list of changeset Ids. + GetBatchedChangesets(context.Context, GetBatchedChangesetsArgs) (*[]git.TfvcChangesetRef, error) + // Get a single branch hierarchy at the given path with parents or children as specified. + GetBranch(context.Context, GetBranchArgs) (*git.TfvcBranch, error) + // Get a collection of branch roots -- first-level children, branches with no parents. + GetBranches(context.Context, GetBranchesArgs) (*[]git.TfvcBranch, error) + // Get branch hierarchies below the specified scopePath + GetBranchRefs(context.Context, GetBranchRefsArgs) (*[]git.TfvcBranchRef, error) + // Retrieve a Tfvc Changeset + GetChangeset(context.Context, GetChangesetArgs) (*git.TfvcChangeset, error) + // Retrieve Tfvc changes for a given changeset. + GetChangesetChanges(context.Context, GetChangesetChangesArgs) (*GetChangesetChangesResponseValue, error) + // Retrieve Tfvc Changesets + GetChangesets(context.Context, GetChangesetsArgs) (*[]git.TfvcChangesetRef, error) + // Retrieves the work items associated with a particular changeset. + GetChangesetWorkItems(context.Context, GetChangesetWorkItemsArgs) (*[]git.AssociatedWorkItem, 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) (*git.TfvcItem, 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 a list of Tfvc items + GetItems(context.Context, GetItemsArgs) (*[]git.TfvcItem, error) + // Post for retrieving a set of items given a list of paths or a long path. Allows for specifying the recursionLevel and version descriptors for each path. + GetItemsBatch(context.Context, GetItemsBatchArgs) (*[][]git.TfvcItem, error) + // Post for retrieving a set of items given a list of paths or a long path. Allows for specifying the recursionLevel and version descriptors for each path. + GetItemsBatchZip(context.Context, GetItemsBatchZipArgs) (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. + 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) + // Get a single deep label. + GetLabel(context.Context, GetLabelArgs) (*git.TfvcLabel, error) + // Get items under a label. + GetLabelItems(context.Context, GetLabelItemsArgs) (*[]git.TfvcItem, error) + // Get a collection of shallow label references. + GetLabels(context.Context, GetLabelsArgs) (*[]git.TfvcLabelRef, error) + // Get a single deep shelveset. + GetShelveset(context.Context, GetShelvesetArgs) (*git.TfvcShelveset, error) + // Get changes included in a shelveset. + GetShelvesetChanges(context.Context, GetShelvesetChangesArgs) (*[]git.TfvcChange, error) + // Return a collection of shallow shelveset references. + GetShelvesets(context.Context, GetShelvesetsArgs) (*[]git.TfvcShelvesetRef, error) + // Get work items associated with a shelveset. + GetShelvesetWorkItems(context.Context, GetShelvesetWorkItemsArgs) (*[]git.AssociatedWorkItem, 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 new changeset. +func (client *ClientImpl) CreateChangeset(ctx context.Context, args CreateChangesetArgs) (*git.TfvcChangesetRef, error) { + if args.Changeset == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Changeset"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.Changeset) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("0bc8f0a4-6bfb-42a9-ba84-139da7b99c49") + 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 git.TfvcChangesetRef + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateChangeset function +type CreateChangesetArgs struct { + // (required) + Changeset *git.TfvcChangeset + // (optional) Project ID or project name + Project *string +} + +// Returns changesets for a given list of changeset Ids. +func (client *ClientImpl) GetBatchedChangesets(ctx context.Context, args GetBatchedChangesetsArgs) (*[]git.TfvcChangesetRef, error) { + if args.ChangesetsRequestData == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ChangesetsRequestData"} + } + body, marshalErr := json.Marshal(*args.ChangesetsRequestData) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b7e7c173-803c-4fea-9ec8-31ee35c5502a") + 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 []git.TfvcChangesetRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBatchedChangesets function +type GetBatchedChangesetsArgs struct { + // (required) List of changeset IDs. + ChangesetsRequestData *git.TfvcChangesetsRequestData +} + +// Get a single branch hierarchy at the given path with parents or children as specified. +func (client *ClientImpl) GetBranch(ctx context.Context, args GetBranchArgs) (*git.TfvcBranch, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + if args.IncludeParent != nil { + queryParams.Add("includeParent", strconv.FormatBool(*args.IncludeParent)) + } + if args.IncludeChildren != nil { + queryParams.Add("includeChildren", strconv.FormatBool(*args.IncludeChildren)) + } + locationId, _ := uuid.Parse("bc1f417e-239d-42e7-85e1-76e80cb2d6eb") + 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 git.TfvcBranch + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBranch function +type GetBranchArgs struct { + // (required) Full path to the branch. Default: $/ Examples: $/, $/MyProject, $/MyProject/SomeFolder. + Path *string + // (optional) Project ID or project name + Project *string + // (optional) Return the parent branch, if there is one. Default: False + IncludeParent *bool + // (optional) Return child branches, if there are any. Default: False + IncludeChildren *bool +} + +// Get a collection of branch roots -- first-level children, branches with no parents. +func (client *ClientImpl) GetBranches(ctx context.Context, args GetBranchesArgs) (*[]git.TfvcBranch, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.IncludeParent != nil { + queryParams.Add("includeParent", strconv.FormatBool(*args.IncludeParent)) + } + if args.IncludeChildren != nil { + queryParams.Add("includeChildren", strconv.FormatBool(*args.IncludeChildren)) + } + if args.IncludeDeleted != nil { + queryParams.Add("includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + locationId, _ := uuid.Parse("bc1f417e-239d-42e7-85e1-76e80cb2d6eb") + 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 []git.TfvcBranch + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBranches function +type GetBranchesArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) Return the parent branch, if there is one. Default: False + IncludeParent *bool + // (optional) Return the child branches for each root branch. Default: False + IncludeChildren *bool + // (optional) Return deleted branches. Default: False + IncludeDeleted *bool + // (optional) Return links. Default: False + IncludeLinks *bool +} + +// Get branch hierarchies below the specified scopePath +func (client *ClientImpl) GetBranchRefs(ctx context.Context, args GetBranchRefsArgs) (*[]git.TfvcBranchRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.ScopePath == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "scopePath"} + } + queryParams.Add("scopePath", *args.ScopePath) + if args.IncludeDeleted != nil { + queryParams.Add("includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + locationId, _ := uuid.Parse("bc1f417e-239d-42e7-85e1-76e80cb2d6eb") + 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 []git.TfvcBranchRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBranchRefs function +type GetBranchRefsArgs struct { + // (required) Full path to the branch. Default: $/ Examples: $/, $/MyProject, $/MyProject/SomeFolder. + ScopePath *string + // (optional) Project ID or project name + Project *string + // (optional) Return deleted branches. Default: False + IncludeDeleted *bool + // (optional) Return links. Default: False + IncludeLinks *bool +} + +// Retrieve a Tfvc Changeset +func (client *ClientImpl) GetChangeset(ctx context.Context, args GetChangesetArgs) (*git.TfvcChangeset, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + queryParams := url.Values{} + if args.MaxChangeCount != nil { + queryParams.Add("maxChangeCount", strconv.Itoa(*args.MaxChangeCount)) + } + if args.IncludeDetails != nil { + queryParams.Add("includeDetails", strconv.FormatBool(*args.IncludeDetails)) + } + if args.IncludeWorkItems != nil { + queryParams.Add("includeWorkItems", strconv.FormatBool(*args.IncludeWorkItems)) + } + if args.MaxCommentLength != nil { + queryParams.Add("maxCommentLength", strconv.Itoa(*args.MaxCommentLength)) + } + if args.IncludeSourceRename != nil { + queryParams.Add("includeSourceRename", strconv.FormatBool(*args.IncludeSourceRename)) + } + if args.Skip != nil { + queryParams.Add("$skip", strconv.Itoa(*args.Skip)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Orderby != nil { + queryParams.Add("$orderby", *args.Orderby) + } + if args.SearchCriteria != nil { + if args.SearchCriteria.ItemPath != nil { + queryParams.Add("searchCriteria.itemPath", *args.SearchCriteria.ItemPath) + } + if args.SearchCriteria.Author != nil { + queryParams.Add("searchCriteria.author", *args.SearchCriteria.Author) + } + 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.FromId != nil { + queryParams.Add("searchCriteria.fromId", strconv.Itoa(*args.SearchCriteria.FromId)) + } + if args.SearchCriteria.ToId != nil { + queryParams.Add("searchCriteria.toId", strconv.Itoa(*args.SearchCriteria.ToId)) + } + if args.SearchCriteria.FollowRenames != nil { + queryParams.Add("searchCriteria.followRenames", strconv.FormatBool(*args.SearchCriteria.FollowRenames)) + } + if args.SearchCriteria.IncludeLinks != nil { + queryParams.Add("searchCriteria.includeLinks", strconv.FormatBool(*args.SearchCriteria.IncludeLinks)) + } + } + locationId, _ := uuid.Parse("0bc8f0a4-6bfb-42a9-ba84-139da7b99c49") + 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 git.TfvcChangeset + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetChangeset function +type GetChangesetArgs struct { + // (required) Changeset Id to retrieve. + Id *int + // (optional) Project ID or project name + Project *string + // (optional) Number of changes to return (maximum 100 changes) Default: 0 + MaxChangeCount *int + // (optional) Include policy details and check-in notes in the response. Default: false + IncludeDetails *bool + // (optional) Include workitems. Default: false + IncludeWorkItems *bool + // (optional) Include details about associated work items in the response. Default: null + MaxCommentLength *int + // (optional) Include renames. Default: false + IncludeSourceRename *bool + // (optional) Number of results to skip. Default: null + Skip *int + // (optional) The maximum number of results to return. Default: null + Top *int + // (optional) Results are sorted by ID in descending order by default. Use id asc to sort by ID in ascending order. + Orderby *string + // (optional) Following criteria available (.itemPath, .version, .versionType, .versionOption, .author, .fromId, .toId, .fromDate, .toDate) Default: null + SearchCriteria *git.TfvcChangesetSearchCriteria +} + +// Retrieve Tfvc changes for a given changeset. +func (client *ClientImpl) GetChangesetChanges(ctx context.Context, args GetChangesetChangesArgs) (*GetChangesetChangesResponseValue, error) { + routeValues := make(map[string]string) + if args.Id != nil { + routeValues["id"] = strconv.Itoa(*args.Id) + } + + 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.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + locationId, _ := uuid.Parse("f32b86f2-15b9-4fe6-81b1-6f8938617ee5") + 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 GetChangesetChangesResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetChangesetChanges function +type GetChangesetChangesArgs struct { + // (optional) ID of the changeset. Default: null + Id *int + // (optional) Number of results to skip. Default: null + Skip *int + // (optional) The maximum number of results to return. Default: null + Top *int + // (optional) Return the next page of results. Default: null + ContinuationToken *string +} + +// Return type for the GetChangesetChanges function +type GetChangesetChangesResponseValue struct { + Value []git.TfvcChange + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// Retrieve Tfvc Changesets +func (client *ClientImpl) GetChangesets(ctx context.Context, args GetChangesetsArgs) (*[]git.TfvcChangesetRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + 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.Orderby != nil { + queryParams.Add("$orderby", *args.Orderby) + } + if args.SearchCriteria != nil { + if args.SearchCriteria.ItemPath != nil { + queryParams.Add("searchCriteria.itemPath", *args.SearchCriteria.ItemPath) + } + if args.SearchCriteria.Author != nil { + queryParams.Add("searchCriteria.author", *args.SearchCriteria.Author) + } + 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.FromId != nil { + queryParams.Add("searchCriteria.fromId", strconv.Itoa(*args.SearchCriteria.FromId)) + } + if args.SearchCriteria.ToId != nil { + queryParams.Add("searchCriteria.toId", strconv.Itoa(*args.SearchCriteria.ToId)) + } + if args.SearchCriteria.FollowRenames != nil { + queryParams.Add("searchCriteria.followRenames", strconv.FormatBool(*args.SearchCriteria.FollowRenames)) + } + if args.SearchCriteria.IncludeLinks != nil { + queryParams.Add("searchCriteria.includeLinks", strconv.FormatBool(*args.SearchCriteria.IncludeLinks)) + } + } + locationId, _ := uuid.Parse("0bc8f0a4-6bfb-42a9-ba84-139da7b99c49") + 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 []git.TfvcChangesetRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetChangesets function +type GetChangesetsArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) Include details about associated work items in the response. Default: null + MaxCommentLength *int + // (optional) Number of results to skip. Default: null + Skip *int + // (optional) The maximum number of results to return. Default: null + Top *int + // (optional) Results are sorted by ID in descending order by default. Use id asc to sort by ID in ascending order. + Orderby *string + // (optional) Following criteria available (.itemPath, .version, .versionType, .versionOption, .author, .fromId, .toId, .fromDate, .toDate) Default: null + SearchCriteria *git.TfvcChangesetSearchCriteria +} + +// Retrieves the work items associated with a particular changeset. +func (client *ClientImpl) GetChangesetWorkItems(ctx context.Context, args GetChangesetWorkItemsArgs) (*[]git.AssociatedWorkItem, error) { + routeValues := make(map[string]string) + if args.Id != nil { + routeValues["id"] = strconv.Itoa(*args.Id) + } + + locationId, _ := uuid.Parse("64ae0bea-1d71-47c9-a9e5-fe73f5ea0ff4") + 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 []git.AssociatedWorkItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetChangesetWorkItems function +type GetChangesetWorkItemsArgs struct { + // (optional) ID of the changeset. Default: null + Id *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) (*git.TfvcItem, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.ScopePath != nil { + queryParams.Add("scopePath", *args.ScopePath) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.VersionDescriptor != nil { + if args.VersionDescriptor.VersionOption != nil { + queryParams.Add("versionDescriptor.versionOption", string(*args.VersionDescriptor.VersionOption)) + } + 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.IncludeContent != nil { + queryParams.Add("includeContent", strconv.FormatBool(*args.IncludeContent)) + } + locationId, _ := uuid.Parse("ba9fc436-9a38-4578-89d6-e4f3241f5040") + 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 git.TfvcItem + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetItem function +type GetItemArgs struct { + // (required) Version control path of an individual item to return. + Path *string + // (optional) Project ID or project name + Project *string + // (optional) file name of item returned. + FileName *string + // (optional) If true, create a downloadable attachment. + Download *bool + // (optional) Version control path of a folder to return multiple items. + ScopePath *string + // (optional) None (just the item), or OneLevel (contents of a folder). + RecursionLevel *git.VersionControlRecursionType + // (optional) Version descriptor. Default is null. + VersionDescriptor *git.TfvcVersionDescriptor + // (optional) Set to true to include item content when requesting json. Default is false. + IncludeContent *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 + } + + queryParams := url.Values{} + if args.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.ScopePath != nil { + queryParams.Add("scopePath", *args.ScopePath) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.VersionDescriptor != nil { + if args.VersionDescriptor.VersionOption != nil { + queryParams.Add("versionDescriptor.versionOption", string(*args.VersionDescriptor.VersionOption)) + } + 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.IncludeContent != nil { + queryParams.Add("includeContent", strconv.FormatBool(*args.IncludeContent)) + } + locationId, _ := uuid.Parse("ba9fc436-9a38-4578-89d6-e4f3241f5040") + 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) Version control path of an individual item to return. + Path *string + // (optional) Project ID or project name + Project *string + // (optional) file name of item returned. + FileName *string + // (optional) If true, create a downloadable attachment. + Download *bool + // (optional) Version control path of a folder to return multiple items. + ScopePath *string + // (optional) None (just the item), or OneLevel (contents of a folder). + RecursionLevel *git.VersionControlRecursionType + // (optional) Version descriptor. Default is null. + VersionDescriptor *git.TfvcVersionDescriptor + // (optional) Set to true to include item content when requesting json. Default is false. + IncludeContent *bool +} + +// Get a list of Tfvc items +func (client *ClientImpl) GetItems(ctx context.Context, args GetItemsArgs) (*[]git.TfvcItem, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.ScopePath != nil { + queryParams.Add("scopePath", *args.ScopePath) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.IncludeLinks != nil { + queryParams.Add("includeLinks", strconv.FormatBool(*args.IncludeLinks)) + } + if args.VersionDescriptor != nil { + if args.VersionDescriptor.VersionOption != nil { + queryParams.Add("versionDescriptor.versionOption", string(*args.VersionDescriptor.VersionOption)) + } + 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) + } + } + locationId, _ := uuid.Parse("ba9fc436-9a38-4578-89d6-e4f3241f5040") + 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 []git.TfvcItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetItems function +type GetItemsArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) Version control path of a folder to return multiple items. + ScopePath *string + // (optional) None (just the item), or OneLevel (contents of a folder). + RecursionLevel *git.VersionControlRecursionType + // (optional) True to include links. + IncludeLinks *bool + // (optional) + VersionDescriptor *git.TfvcVersionDescriptor +} + +// Post for retrieving a set of items given a list of paths or a long path. Allows for specifying the recursionLevel and version descriptors for each path. +func (client *ClientImpl) GetItemsBatch(ctx context.Context, args GetItemsBatchArgs) (*[][]git.TfvcItem, error) { + if args.ItemRequestData == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ItemRequestData"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.ItemRequestData) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("fe6f827b-5f64-480f-b8af-1eca3b80e833") + 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 [][]git.TfvcItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetItemsBatch function +type GetItemsBatchArgs struct { + // (required) + ItemRequestData *git.TfvcItemRequestData + // (optional) Project ID or project name + Project *string +} + +// Post for retrieving a set of items given a list of paths or a long path. Allows for specifying the recursionLevel and version descriptors for each path. +func (client *ClientImpl) GetItemsBatchZip(ctx context.Context, args GetItemsBatchZipArgs) (io.ReadCloser, error) { + if args.ItemRequestData == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ItemRequestData"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.ItemRequestData) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("fe6f827b-5f64-480f-b8af-1eca3b80e833") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetItemsBatchZip function +type GetItemsBatchZipArgs struct { + // (required) + ItemRequestData *git.TfvcItemRequestData + // (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 + } + + queryParams := url.Values{} + if args.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.ScopePath != nil { + queryParams.Add("scopePath", *args.ScopePath) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.VersionDescriptor != nil { + if args.VersionDescriptor.VersionOption != nil { + queryParams.Add("versionDescriptor.versionOption", string(*args.VersionDescriptor.VersionOption)) + } + 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.IncludeContent != nil { + queryParams.Add("includeContent", strconv.FormatBool(*args.IncludeContent)) + } + locationId, _ := uuid.Parse("ba9fc436-9a38-4578-89d6-e4f3241f5040") + 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) Version control path of an individual item to return. + Path *string + // (optional) Project ID or project name + Project *string + // (optional) file name of item returned. + FileName *string + // (optional) If true, create a downloadable attachment. + Download *bool + // (optional) Version control path of a folder to return multiple items. + ScopePath *string + // (optional) None (just the item), or OneLevel (contents of a folder). + RecursionLevel *git.VersionControlRecursionType + // (optional) Version descriptor. Default is null. + VersionDescriptor *git.TfvcVersionDescriptor + // (optional) Set to true to include item content when requesting json. Default is false. + IncludeContent *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 + } + + queryParams := url.Values{} + if args.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + if args.ScopePath != nil { + queryParams.Add("scopePath", *args.ScopePath) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.VersionDescriptor != nil { + if args.VersionDescriptor.VersionOption != nil { + queryParams.Add("versionDescriptor.versionOption", string(*args.VersionDescriptor.VersionOption)) + } + 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.IncludeContent != nil { + queryParams.Add("includeContent", strconv.FormatBool(*args.IncludeContent)) + } + locationId, _ := uuid.Parse("ba9fc436-9a38-4578-89d6-e4f3241f5040") + 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) Version control path of an individual item to return. + Path *string + // (optional) Project ID or project name + Project *string + // (optional) file name of item returned. + FileName *string + // (optional) If true, create a downloadable attachment. + Download *bool + // (optional) Version control path of a folder to return multiple items. + ScopePath *string + // (optional) None (just the item), or OneLevel (contents of a folder). + RecursionLevel *git.VersionControlRecursionType + // (optional) Version descriptor. Default is null. + VersionDescriptor *git.TfvcVersionDescriptor + // (optional) Set to true to include item content when requesting json. Default is false. + IncludeContent *bool +} + +// Get a single deep label. +func (client *ClientImpl) GetLabel(ctx context.Context, args GetLabelArgs) (*git.TfvcLabel, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.LabelId == nil || *args.LabelId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.LabelId"} + } + routeValues["labelId"] = *args.LabelId + + queryParams := url.Values{} + if args.RequestData == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "requestData"} + } + if args.RequestData.LabelScope != nil { + queryParams.Add("requestData.labelScope", *args.RequestData.LabelScope) + } + if args.RequestData.Name != nil { + queryParams.Add("requestData.name", *args.RequestData.Name) + } + if args.RequestData.Owner != nil { + queryParams.Add("requestData.owner", *args.RequestData.Owner) + } + if args.RequestData.ItemLabelFilter != nil { + queryParams.Add("requestData.itemLabelFilter", *args.RequestData.ItemLabelFilter) + } + if args.RequestData.MaxItemCount != nil { + queryParams.Add("requestData.maxItemCount", strconv.Itoa(*args.RequestData.MaxItemCount)) + } + if args.RequestData.IncludeLinks != nil { + queryParams.Add("requestData.includeLinks", strconv.FormatBool(*args.RequestData.IncludeLinks)) + } + locationId, _ := uuid.Parse("a5d9bd7f-b661-4d0e-b9be-d9c16affae54") + 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 git.TfvcLabel + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetLabel function +type GetLabelArgs struct { + // (required) Unique identifier of label + LabelId *string + // (required) maxItemCount + RequestData *git.TfvcLabelRequestData + // (optional) Project ID or project name + Project *string +} + +// Get items under a label. +func (client *ClientImpl) GetLabelItems(ctx context.Context, args GetLabelItemsArgs) (*[]git.TfvcItem, error) { + routeValues := make(map[string]string) + if args.LabelId == nil || *args.LabelId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.LabelId"} + } + routeValues["labelId"] = *args.LabelId + + 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("06166e34-de17-4b60-8cd1-23182a346fda") + 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 []git.TfvcItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetLabelItems function +type GetLabelItemsArgs struct { + // (required) Unique identifier of label + LabelId *string + // (optional) Max number of items to return + Top *int + // (optional) Number of items to skip + Skip *int +} + +// Get a collection of shallow label references. +func (client *ClientImpl) GetLabels(ctx context.Context, args GetLabelsArgs) (*[]git.TfvcLabelRef, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.RequestData == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "requestData"} + } + if args.RequestData.LabelScope != nil { + queryParams.Add("requestData.labelScope", *args.RequestData.LabelScope) + } + if args.RequestData.Name != nil { + queryParams.Add("requestData.name", *args.RequestData.Name) + } + if args.RequestData.Owner != nil { + queryParams.Add("requestData.owner", *args.RequestData.Owner) + } + if args.RequestData.ItemLabelFilter != nil { + queryParams.Add("requestData.itemLabelFilter", *args.RequestData.ItemLabelFilter) + } + if args.RequestData.MaxItemCount != nil { + queryParams.Add("requestData.maxItemCount", strconv.Itoa(*args.RequestData.MaxItemCount)) + } + if args.RequestData.IncludeLinks != nil { + queryParams.Add("requestData.includeLinks", strconv.FormatBool(*args.RequestData.IncludeLinks)) + } + 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("a5d9bd7f-b661-4d0e-b9be-d9c16affae54") + 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 []git.TfvcLabelRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetLabels function +type GetLabelsArgs struct { + // (required) labelScope, name, owner, and itemLabelFilter + RequestData *git.TfvcLabelRequestData + // (optional) Project ID or project name + Project *string + // (optional) Max number of labels to return, defaults to 100 when undefined + Top *int + // (optional) Number of labels to skip + Skip *int +} + +// Get a single deep shelveset. +func (client *ClientImpl) GetShelveset(ctx context.Context, args GetShelvesetArgs) (*git.TfvcShelveset, error) { + queryParams := url.Values{} + if args.ShelvesetId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "shelvesetId"} + } + queryParams.Add("shelvesetId", *args.ShelvesetId) + if args.RequestData != nil { + if args.RequestData.Name != nil { + queryParams.Add("requestData.name", *args.RequestData.Name) + } + if args.RequestData.Owner != nil { + queryParams.Add("requestData.owner", *args.RequestData.Owner) + } + if args.RequestData.MaxCommentLength != nil { + queryParams.Add("requestData.maxCommentLength", strconv.Itoa(*args.RequestData.MaxCommentLength)) + } + if args.RequestData.MaxChangeCount != nil { + queryParams.Add("requestData.maxChangeCount", strconv.Itoa(*args.RequestData.MaxChangeCount)) + } + if args.RequestData.IncludeDetails != nil { + queryParams.Add("requestData.includeDetails", strconv.FormatBool(*args.RequestData.IncludeDetails)) + } + if args.RequestData.IncludeWorkItems != nil { + queryParams.Add("requestData.includeWorkItems", strconv.FormatBool(*args.RequestData.IncludeWorkItems)) + } + if args.RequestData.IncludeLinks != nil { + queryParams.Add("requestData.includeLinks", strconv.FormatBool(*args.RequestData.IncludeLinks)) + } + } + locationId, _ := uuid.Parse("e36d44fb-e907-4b0a-b194-f83f1ed32ad3") + 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 git.TfvcShelveset + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetShelveset function +type GetShelvesetArgs struct { + // (required) Shelveset's unique ID + ShelvesetId *string + // (optional) includeDetails, includeWorkItems, maxChangeCount, and maxCommentLength + RequestData *git.TfvcShelvesetRequestData +} + +// Get changes included in a shelveset. +func (client *ClientImpl) GetShelvesetChanges(ctx context.Context, args GetShelvesetChangesArgs) (*[]git.TfvcChange, error) { + queryParams := url.Values{} + if args.ShelvesetId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "shelvesetId"} + } + queryParams.Add("shelvesetId", *args.ShelvesetId) + 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("dbaf075b-0445-4c34-9e5b-82292f856522") + 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 []git.TfvcChange + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetShelvesetChanges function +type GetShelvesetChangesArgs struct { + // (required) Shelveset's unique ID + ShelvesetId *string + // (optional) Max number of changes to return + Top *int + // (optional) Number of changes to skip + Skip *int +} + +// Return a collection of shallow shelveset references. +func (client *ClientImpl) GetShelvesets(ctx context.Context, args GetShelvesetsArgs) (*[]git.TfvcShelvesetRef, error) { + queryParams := url.Values{} + if args.RequestData != nil { + if args.RequestData.Name != nil { + queryParams.Add("requestData.name", *args.RequestData.Name) + } + if args.RequestData.Owner != nil { + queryParams.Add("requestData.owner", *args.RequestData.Owner) + } + if args.RequestData.MaxCommentLength != nil { + queryParams.Add("requestData.maxCommentLength", strconv.Itoa(*args.RequestData.MaxCommentLength)) + } + if args.RequestData.MaxChangeCount != nil { + queryParams.Add("requestData.maxChangeCount", strconv.Itoa(*args.RequestData.MaxChangeCount)) + } + if args.RequestData.IncludeDetails != nil { + queryParams.Add("requestData.includeDetails", strconv.FormatBool(*args.RequestData.IncludeDetails)) + } + if args.RequestData.IncludeWorkItems != nil { + queryParams.Add("requestData.includeWorkItems", strconv.FormatBool(*args.RequestData.IncludeWorkItems)) + } + if args.RequestData.IncludeLinks != nil { + queryParams.Add("requestData.includeLinks", strconv.FormatBool(*args.RequestData.IncludeLinks)) + } + } + 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("e36d44fb-e907-4b0a-b194-f83f1ed32ad3") + 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 []git.TfvcShelvesetRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetShelvesets function +type GetShelvesetsArgs struct { + // (optional) name, owner, and maxCommentLength + RequestData *git.TfvcShelvesetRequestData + // (optional) Max number of shelvesets to return + Top *int + // (optional) Number of shelvesets to skip + Skip *int +} + +// Get work items associated with a shelveset. +func (client *ClientImpl) GetShelvesetWorkItems(ctx context.Context, args GetShelvesetWorkItemsArgs) (*[]git.AssociatedWorkItem, error) { + queryParams := url.Values{} + if args.ShelvesetId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "shelvesetId"} + } + queryParams.Add("shelvesetId", *args.ShelvesetId) + locationId, _ := uuid.Parse("a7a0c1c1-373e-425a-b031-a519474d743d") + 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 []git.AssociatedWorkItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetShelvesetWorkItems function +type GetShelvesetWorkItemsArgs struct { + // (required) Shelveset's unique ID + ShelvesetId *string +} diff --git a/azuredevops/tokenadmin/client.go b/azuredevops/tokenadmin/client.go new file mode 100644 index 00000000..88d9dbee --- /dev/null +++ b/azuredevops/tokenadmin/client.go @@ -0,0 +1,140 @@ +// -------------------------------------------------------------------------------------------- +// 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 tokenadmin + +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("af68438b-ed04-4407-9eb6-f1dbae3f922e") + +type Client interface { + // [Preview API] Creates a revocation rule to prevent the further usage of any OAuth authorizations that were created before the current point in time and which match the conditions in the rule. + CreateRevocationRule(context.Context, CreateRevocationRuleArgs) error + // [Preview API] Lists of all the session token details of the personal access tokens (PATs) for a particular user. + ListPersonalAccessTokens(context.Context, ListPersonalAccessTokensArgs) (*TokenAdminPagedSessionTokens, error) + // [Preview API] Revokes the listed OAuth authorizations. + RevokeAuthorizations(context.Context, RevokeAuthorizationsArgs) 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] Creates a revocation rule to prevent the further usage of any OAuth authorizations that were created before the current point in time and which match the conditions in the rule. +func (client *ClientImpl) CreateRevocationRule(ctx context.Context, args CreateRevocationRuleArgs) error { + if args.RevocationRule == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.RevocationRule"} + } + body, marshalErr := json.Marshal(*args.RevocationRule) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("ee4afb16-e7ab-4ed8-9d4b-4ef3e78f97e4") + _, 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 err + } + + return nil +} + +// Arguments for the CreateRevocationRule function +type CreateRevocationRuleArgs struct { + // (required) The revocation rule to create. The rule must specify a space-separated list of scopes, after which preexisting OAuth authorizations that match that any of the scopes will be rejected. For a list of all OAuth scopes supported by VSTS, see: https://docs.microsoft.com/en-us/vsts/integrate/get-started/authentication/oauth?view=vsts#scopes The rule may also specify the time before which to revoke tokens. + RevocationRule *TokenAdminRevocationRule +} + +// [Preview API] Lists of all the session token details of the personal access tokens (PATs) for a particular user. +func (client *ClientImpl) ListPersonalAccessTokens(ctx context.Context, args ListPersonalAccessTokensArgs) (*TokenAdminPagedSessionTokens, error) { + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + + queryParams := url.Values{} + if args.PageSize != nil { + queryParams.Add("pageSize", strconv.Itoa(*args.PageSize)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.IsPublic != nil { + queryParams.Add("isPublic", strconv.FormatBool(*args.IsPublic)) + } + locationId, _ := uuid.Parse("af68438b-ed04-4407-9eb6-f1dbae3f922e") + 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 TokenAdminPagedSessionTokens + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListPersonalAccessTokens function +type ListPersonalAccessTokensArgs struct { + // (required) The descriptor of the target user. + SubjectDescriptor *string + // (optional) The maximum number of results to return on each page. + PageSize *int + // (optional) An opaque data blob that allows the next page of data to resume immediately after where the previous page ended. The only reliable way to know if there is more data left is the presence of a continuation token. + ContinuationToken *string + // (optional) Set to false for PAT tokens and true for SSH tokens. + IsPublic *bool +} + +// [Preview API] Revokes the listed OAuth authorizations. +func (client *ClientImpl) RevokeAuthorizations(ctx context.Context, args RevokeAuthorizationsArgs) error { + if args.Revocations == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Revocations"} + } + queryParams := url.Values{} + if args.IsPublic != nil { + queryParams.Add("isPublic", strconv.FormatBool(*args.IsPublic)) + } + body, marshalErr := json.Marshal(*args.Revocations) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("a9c08b2c-5466-4e22-8626-1ff304ffdf0f") + _, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the RevokeAuthorizations function +type RevokeAuthorizationsArgs struct { + // (required) The list of objects containing the authorization IDs of the OAuth authorizations, such as session tokens retrieved by listed a users PATs, that should be revoked. + Revocations *[]TokenAdminRevocation + // (optional) Set to false for PAT tokens and true for SSH tokens. + IsPublic *bool +} diff --git a/azuredevops/tokenadmin/models.go b/azuredevops/tokenadmin/models.go new file mode 100644 index 00000000..bd41e782 --- /dev/null +++ b/azuredevops/tokenadmin/models.go @@ -0,0 +1,37 @@ +// -------------------------------------------------------------------------------------------- +// 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 tokenadmin + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/delegatedauthorization" +) + +// A paginated list of session tokens. Session tokens correspond to OAuth credentials such as personal access tokens (PATs) and other OAuth authorizations. +type TokenAdminPagedSessionTokens struct { + // The continuation token that can be used to retrieve the next page of session tokens, or null if there is no next page. + ContinuationToken *uuid.UUID `json:"continuationToken,omitempty"` + // The list of all session tokens in the current page. + Value *[]delegatedauthorization.SessionToken `json:"value,omitempty"` +} + +// A request to revoke a particular delegated authorization. +type TokenAdminRevocation struct { + // The authorization ID of the OAuth authorization to revoke. + AuthorizationId *uuid.UUID `json:"authorizationId,omitempty"` +} + +// A rule which is applied to disable any incoming delegated authorization which matches the given properties. +type TokenAdminRevocationRule struct { + // A datetime cutoff. Tokens created before this time will be rejected. This is an optional parameter. If omitted, defaults to the time at which the rule was created. + CreatedBefore *azuredevops.Time `json:"createdBefore,omitempty"` + // A string containing a space-delimited list of OAuth scopes. A token matching any one of the scopes will be rejected. For a list of all OAuth scopes supported by Azure DevOps, see: https://docs.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?view=azure-devops#scopes This is a mandatory parameter. + Scopes *string `json:"scopes,omitempty"` +} diff --git a/azuredevops/tokenadministration/client.go b/azuredevops/tokenadministration/client.go new file mode 100644 index 00000000..64acb3a2 --- /dev/null +++ b/azuredevops/tokenadministration/client.go @@ -0,0 +1,167 @@ +// -------------------------------------------------------------------------------------------- +// 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 tokenadministration + +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/tokenadmin" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("95935461-9e54-44bd-b9fb-04f4dd05d640") + +type Client interface { + // [Preview API] Revokes the listed OAuth authorizations. + ListIdentitiesWithGlobalAccessTokens(context.Context, ListIdentitiesWithGlobalAccessTokensArgs) (*[]uuid.UUID, error) + // [Preview API] Lists of all the session token details of the personal access tokens (PATs) for a particular user. + ListPersonalAccessTokens(context.Context, ListPersonalAccessTokensArgs) (*tokenadmin.TokenAdminPagedSessionTokens, error) + // [Preview API] Revokes the listed OAuth authorizations. + RevokeAuthorizations(context.Context, RevokeAuthorizationsArgs) (*[]delegatedauthorization.SessionToken, 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] Revokes the listed OAuth authorizations. +func (client *ClientImpl) ListIdentitiesWithGlobalAccessTokens(ctx context.Context, args ListIdentitiesWithGlobalAccessTokensArgs) (*[]uuid.UUID, error) { + if args.Revocations == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Revocations"} + } + queryParams := url.Values{} + if args.IsPublic != nil { + queryParams.Add("isPublic", strconv.FormatBool(*args.IsPublic)) + } + body, marshalErr := json.Marshal(*args.Revocations) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("30d3a12b-66c3-4669-b016-ecb0706c8d0f") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, queryParams, bytes.NewReader(body), "application/json", "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 ListIdentitiesWithGlobalAccessTokens function +type ListIdentitiesWithGlobalAccessTokensArgs struct { + // (required) The list of identities containing the authorization IDs of the OAuth authorizations, such as session tokens retrieved by listed a users PATs, that should be checked for global access tokens. + Revocations *[]tokenadmin.TokenAdminRevocation + // (optional) Set to false for PAT tokens and true for SSH tokens. + IsPublic *bool +} + +// [Preview API] Lists of all the session token details of the personal access tokens (PATs) for a particular user. +func (client *ClientImpl) ListPersonalAccessTokens(ctx context.Context, args ListPersonalAccessTokensArgs) (*tokenadmin.TokenAdminPagedSessionTokens, error) { + if args.Audience == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Audience"} + } + routeValues := make(map[string]string) + if args.SubjectDescriptor == nil || *args.SubjectDescriptor == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SubjectDescriptor"} + } + routeValues["subjectDescriptor"] = *args.SubjectDescriptor + + queryParams := url.Values{} + if args.PageSize != nil { + queryParams.Add("pageSize", strconv.Itoa(*args.PageSize)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.IsPublic != nil { + queryParams.Add("isPublic", strconv.FormatBool(*args.IsPublic)) + } + body, marshalErr := json.Marshal(*args.Audience) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1bb7db14-87c5-4762-bf77-a70ad34a9ab3") + 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 tokenadmin.TokenAdminPagedSessionTokens + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ListPersonalAccessTokens function +type ListPersonalAccessTokensArgs struct { + // (required) + Audience *[]string + // (required) The descriptor of the target user. + SubjectDescriptor *string + // (optional) The maximum number of results to return on each page. + PageSize *int + // (optional) An opaque data blob that allows the next page of data to resume immediately after where the previous page ended. The only reliable way to know if there is more data left is the presence of a continuation token. + ContinuationToken *string + // (optional) Set to false for PAT tokens and true for SSH tokens. + IsPublic *bool +} + +// [Preview API] Revokes the listed OAuth authorizations. +func (client *ClientImpl) RevokeAuthorizations(ctx context.Context, args RevokeAuthorizationsArgs) (*[]delegatedauthorization.SessionToken, error) { + if args.Revocations == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Revocations"} + } + queryParams := url.Values{} + if args.HostId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "hostId"} + } + queryParams.Add("hostId", (*args.HostId).String()) + if args.IsPublic != nil { + queryParams.Add("isPublic", strconv.FormatBool(*args.IsPublic)) + } + body, marshalErr := json.Marshal(*args.Revocations) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a2e4520b-1cc8-4526-871e-f3a8f865f221") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []delegatedauthorization.SessionToken + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the RevokeAuthorizations function +type RevokeAuthorizationsArgs struct { + // (required) The list of objects containing the authorization IDs of the OAuth authorizations, such as session tokens retrieved by listed a users PATs, that should be revoked. + Revocations *TokenAdministrationRevocation + // (required) Host Id to display on the notification page to manage tokens. + HostId *uuid.UUID + // (optional) Set to false for PAT tokens and true for SSH tokens. + IsPublic *bool +} diff --git a/azuredevops/tokenadministration/models.go b/azuredevops/tokenadministration/models.go new file mode 100644 index 00000000..5ed79341 --- /dev/null +++ b/azuredevops/tokenadministration/models.go @@ -0,0 +1,20 @@ +// -------------------------------------------------------------------------------------------- +// 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 tokenadministration + +import ( + "github.com/google/uuid" +) + +type TokenAdministrationRevocation struct { + // A list of audience (target accounts) to limit the revocations to + Audience *[]string `json:"audience,omitempty"` + // A list of authorization ID of the OAuth authorization to revoke. + AuthorizationIds *[]uuid.UUID `json:"authorizationIds,omitempty"` +} diff --git a/azuredevops/universal/client.go b/azuredevops/universal/client.go new file mode 100644 index 00000000..c5fb8b72 --- /dev/null +++ b/azuredevops/universal/client.go @@ -0,0 +1,291 @@ +// -------------------------------------------------------------------------------------------- +// 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 universal + +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("d397749b-f115-4027-b6dd-77a65dd10d21") + +type Client interface { + // [Preview API] Delete a package version from a feed's recycle bin. + DeletePackageVersion(context.Context, DeletePackageVersionArgs) (*Package, error) + // [Preview API] Delete a package version from the recycle bin. + DeletePackageVersionFromRecycleBin(context.Context, DeletePackageVersionFromRecycleBinArgs) error + // [Preview API] Show information about a package version. + GetPackageVersion(context.Context, GetPackageVersionArgs) (*Package, error) + // [Preview API] Get information about a package version in the recycle bin. + GetPackageVersionMetadataFromRecycleBin(context.Context, GetPackageVersionMetadataFromRecycleBinArgs) (*UPackPackageVersionDeletionState, error) + // [Preview API] Restore a package version from the recycle bin to its associated feed. + RestorePackageVersionFromRecycleBin(context.Context, RestorePackageVersionFromRecycleBinArgs) error + // [Preview API] Update information for a package version. + UpdatePackageVersion(context.Context, UpdatePackageVersionArgs) 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] Delete a package version from a feed's recycle bin. +func (client *ClientImpl) DeletePackageVersion(ctx context.Context, args DeletePackageVersionArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("72f61ca4-e07c-4eca-be75-6c0b2f3f4051") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the DeletePackageVersion function +type DeletePackageVersionArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Delete a package version from the recycle bin. +func (client *ClientImpl) DeletePackageVersionFromRecycleBin(ctx context.Context, args DeletePackageVersionFromRecycleBinArgs) error { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("3ba455ae-31e6-409e-849f-56c66888d004") + _, 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 DeletePackageVersionFromRecycleBin function +type DeletePackageVersionFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Show information about a package version. +func (client *ClientImpl) GetPackageVersion(ctx context.Context, args GetPackageVersionArgs) (*Package, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + queryParams := url.Values{} + if args.ShowDeleted != nil { + queryParams.Add("showDeleted", strconv.FormatBool(*args.ShowDeleted)) + } + locationId, _ := uuid.Parse("72f61ca4-e07c-4eca-be75-6c0b2f3f4051") + 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 Package + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersion function +type GetPackageVersionArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string + // (optional) True to show information for deleted versions + ShowDeleted *bool +} + +// [Preview API] Get information about a package version in the recycle bin. +func (client *ClientImpl) GetPackageVersionMetadataFromRecycleBin(ctx context.Context, args GetPackageVersionMetadataFromRecycleBinArgs) (*UPackPackageVersionDeletionState, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + locationId, _ := uuid.Parse("3ba455ae-31e6-409e-849f-56c66888d004") + 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 UPackPackageVersionDeletionState + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersionMetadataFromRecycleBin function +type GetPackageVersionMetadataFromRecycleBinArgs struct { + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Restore a package version from the recycle bin to its associated feed. +func (client *ClientImpl) RestorePackageVersionFromRecycleBin(ctx context.Context, args RestorePackageVersionFromRecycleBinArgs) error { + if args.PackageVersionDetails == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionDetails"} + } + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + body, marshalErr := json.Marshal(*args.PackageVersionDetails) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("3ba455ae-31e6-409e-849f-56c66888d004") + _, 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 err + } + + return nil +} + +// Arguments for the RestorePackageVersionFromRecycleBin function +type RestorePackageVersionFromRecycleBinArgs struct { + // (required) Set the 'Deleted' property to 'false' to restore the package. + PackageVersionDetails *UPackRecycleBinPackageVersionDetails + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} + +// [Preview API] Update information for a package version. +func (client *ClientImpl) UpdatePackageVersion(ctx context.Context, args UpdatePackageVersionArgs) error { + if args.PackageVersionDetails == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.PackageVersionDetails"} + } + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + body, marshalErr := json.Marshal(*args.PackageVersionDetails) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("72f61ca4-e07c-4eca-be75-6c0b2f3f4051") + _, 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 err + } + + return nil +} + +// Arguments for the UpdatePackageVersion function +type UpdatePackageVersionArgs struct { + // (required) + PackageVersionDetails *PackageVersionDetails + // (required) Name or ID of the feed. + FeedId *string + // (required) Name of the package. + PackageName *string + // (required) Version of the package. + PackageVersion *string +} diff --git a/azuredevops/universal/models.go b/azuredevops/universal/models.go new file mode 100644 index 00000000..aa11fbd5 --- /dev/null +++ b/azuredevops/universal/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 universal + +import ( + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/packagingshared" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +// Package version metadata for a Universal package +type Package struct { + // Related REST links. + Links interface{} `json:"_links,omitempty"` + // If and when the package was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Package Id. + Id *string `json:"id,omitempty"` + // The display name of the package. + Name *string `json:"name,omitempty"` + // If and when the package was permanently deleted. + PermanentlyDeletedDate *azuredevops.Time `json:"permanentlyDeletedDate,omitempty"` + // The version of the package. + Version *string `json:"version,omitempty"` +} + +type PackageVersionDetails struct { + // The view to which the package version will be added + Views *webapi.JsonPatchOperation `json:"views,omitempty"` +} + +// Describes UPack batch operation types. +type UPackBatchOperationType string + +type uPackBatchOperationTypeValuesType struct { + Promote UPackBatchOperationType + Delete UPackBatchOperationType + PermanentDelete UPackBatchOperationType + RestoreToFeed UPackBatchOperationType +} + +var UPackBatchOperationTypeValues = uPackBatchOperationTypeValuesType{ + // Promote package versions to a release view. If constructing a UPackPackagesBatchRequest object with this type, use BatchPromoteData for its Data property. Not supported in the Recycle Bin. + Promote: "promote", + // Move package versions to the feed's Recycle Bin. Not supported in the Recycle Bin. + Delete: "delete", + // Permanently delete package versions. Only supported in the Recycle Bin. + PermanentDelete: "permanentDelete", + // Restore deleted package versions to the feed. Only supported in the Recycle Bin. + RestoreToFeed: "restoreToFeed", +} + +// Describes intent when calling the API GetPackageMetadata. +type UPackGetPackageMetadataIntent string + +type uPackGetPackageMetadataIntentValuesType struct { + FetchMetadataOnly UPackGetPackageMetadataIntent + Download UPackGetPackageMetadataIntent +} + +var UPackGetPackageMetadataIntentValues = uPackGetPackageMetadataIntentValuesType{ + // Default. The call intends only to retrieve the package metadata. + FetchMetadataOnly: "fetchMetadataOnly", + // The call is part of the download flow. + Download: "download", +} + +// A batch of operations to apply to package versions. +type UPackPackagesBatchRequest struct { + // Data required to perform the operation. This is optional based on the type of the operation. Use BatchPromoteData if performing a promote operation. + Data interface{} `json:"data,omitempty"` + // Type of operation that needs to be performed on packages. + Operation *UPackBatchOperationType `json:"operation,omitempty"` + // The packages onto which the operation will be performed. + Packages *[]packagingshared.MinimalPackageDetails `json:"packages,omitempty"` +} + +// Deletion state of a Universal package. +type UPackPackageVersionDeletionState struct { + // UTC date the package was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Name of the package. + Name *string `json:"name,omitempty"` + // Version of the package. + Version *string `json:"version,omitempty"` +} + +type UPackRecycleBinPackageVersionDetails struct { + // Setting to false will undo earlier deletion and restore the package to feed. + Deleted *bool `json:"deleted,omitempty"` +} diff --git a/azuredevops/upackpackaging/client.go b/azuredevops/upackpackaging/client.go new file mode 100644 index 00000000..234a4a6c --- /dev/null +++ b/azuredevops/upackpackaging/client.go @@ -0,0 +1,162 @@ +// -------------------------------------------------------------------------------------------- +// 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 upackpackaging + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" +) + +var ResourceAreaId, _ = uuid.Parse("d397749b-f115-4027-b6dd-77a65dd10d21") + +type Client interface { + // [Preview API] + AddPackage(context.Context, AddPackageArgs) error + // [Preview API] + GetPackageMetadata(context.Context, GetPackageMetadataArgs) (*UPackPackageMetadata, error) + // [Preview API] + GetPackageVersionsMetadata(context.Context, GetPackageVersionsMetadataArgs) (*UPackLimitedPackageMetadataListResponse, 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) AddPackage(ctx context.Context, args AddPackageArgs) error { + if args.Metadata == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Metadata"} + } + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + body, marshalErr := json.Marshal(*args.Metadata) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("4cdb2ced-0758-4651-8032-010f070dd7e5") + _, 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 AddPackage function +type AddPackageArgs struct { + // (required) + Metadata *UPackPackagePushMetadata + // (required) + FeedId *string + // (required) + PackageName *string + // (required) + PackageVersion *string +} + +// [Preview API] +func (client *ClientImpl) GetPackageMetadata(ctx context.Context, args GetPackageMetadataArgs) (*UPackPackageMetadata, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + if args.PackageVersion == nil || *args.PackageVersion == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageVersion"} + } + routeValues["packageVersion"] = *args.PackageVersion + + queryParams := url.Values{} + if args.Intent != nil { + queryParams.Add("intent", string(*args.Intent)) + } + locationId, _ := uuid.Parse("4cdb2ced-0758-4651-8032-010f070dd7e5") + 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 UPackPackageMetadata + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageMetadata function +type GetPackageMetadataArgs struct { + // (required) + FeedId *string + // (required) + PackageName *string + // (required) + PackageVersion *string + // (optional) + Intent *UPackGetPackageMetadataIntent +} + +// [Preview API] +func (client *ClientImpl) GetPackageVersionsMetadata(ctx context.Context, args GetPackageVersionsMetadataArgs) (*UPackLimitedPackageMetadataListResponse, error) { + routeValues := make(map[string]string) + if args.FeedId == nil || *args.FeedId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FeedId"} + } + routeValues["feedId"] = *args.FeedId + if args.PackageName == nil || *args.PackageName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PackageName"} + } + routeValues["packageName"] = *args.PackageName + + locationId, _ := uuid.Parse("4cdb2ced-0758-4651-8032-010f070dd7e5") + 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 UPackLimitedPackageMetadataListResponse + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPackageVersionsMetadata function +type GetPackageVersionsMetadataArgs struct { + // (required) + FeedId *string + // (required) + PackageName *string +} diff --git a/azuredevops/upackpackaging/models.go b/azuredevops/upackpackaging/models.go new file mode 100644 index 00000000..79b8efe0 --- /dev/null +++ b/azuredevops/upackpackaging/models.go @@ -0,0 +1,83 @@ +// -------------------------------------------------------------------------------------------- +// 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 upackpackaging + +import ( + "github.com/microsoft/azure-devops-go-api/azuredevops" +) + +// Describes UPack batch operation types. +type UPackBatchOperationType string + +type uPackBatchOperationTypeValuesType struct { + Promote UPackBatchOperationType + Delete UPackBatchOperationType + PermanentDelete UPackBatchOperationType + RestoreToFeed UPackBatchOperationType +} + +var UPackBatchOperationTypeValues = uPackBatchOperationTypeValuesType{ + // Promote package versions to a release view. If constructing a UPackPackagesBatchRequest object with this type, use BatchPromoteData for its Data property. Not supported in the Recycle Bin. + Promote: "promote", + // Move package versions to the feed's Recycle Bin. Not supported in the Recycle Bin. + Delete: "delete", + // Permanently delete package versions. Only supported in the Recycle Bin. + PermanentDelete: "permanentDelete", + // Restore deleted package versions to the feed. Only supported in the Recycle Bin. + RestoreToFeed: "restoreToFeed", +} + +// Describes intent when calling the API GetPackageMetadata. +type UPackGetPackageMetadataIntent string + +type uPackGetPackageMetadataIntentValuesType struct { + FetchMetadataOnly UPackGetPackageMetadataIntent + Download UPackGetPackageMetadataIntent +} + +var UPackGetPackageMetadataIntentValues = uPackGetPackageMetadataIntentValuesType{ + // Default. The call intends only to retrieve the package metadata. + FetchMetadataOnly: "fetchMetadataOnly", + // The call is part of the download flow. + Download: "download", +} + +type UPackLimitedPackageMetadata struct { + Version *string `json:"version,omitempty"` +} + +type UPackLimitedPackageMetadataListResponse struct { + Count *int `json:"count,omitempty"` + Value *[]UPackLimitedPackageMetadata `json:"value,omitempty"` +} + +type UPackPackageMetadata struct { + Description *string `json:"description,omitempty"` + ManifestId *string `json:"manifestId,omitempty"` + SuperRootId *string `json:"superRootId,omitempty"` + Version *string `json:"version,omitempty"` +} + +type UPackPackagePushMetadata struct { + Description *string `json:"description,omitempty"` + ManifestId *string `json:"manifestId,omitempty"` + SuperRootId *string `json:"superRootId,omitempty"` + Version *string `json:"version,omitempty"` + ProofNodes *[]string `json:"proofNodes,omitempty"` +} + +// Deletion state of a Universal package. +type UPackPackageVersionDeletionState struct { + // UTC date the package was deleted. + DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` + // Name of the package. + Name *string `json:"name,omitempty"` + // Version of the package. + Version *string `json:"version,omitempty"` +} diff --git a/azuredevops/version.go b/azuredevops/version.go new file mode 100644 index 00000000..443147c5 --- /dev/null +++ b/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/azuredevops/versionnegotiation.go b/azuredevops/versionnegotiation.go new file mode 100644 index 00000000..f1a2a2f3 --- /dev/null +++ b/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/azuredevops/versionnegotiation_test.go b/azuredevops/versionnegotiation_test.go new file mode 100644 index 00000000..c96d30f4 --- /dev/null +++ b/azuredevops/versionnegotiation_test.go @@ -0,0 +1,86 @@ +package azuredevops + +import ( + "testing" +) + +func TestNegotiateRequestVersion_NonReleasedApi(t *testing.T) { + // key is requested version, value is expected negotiated version + tests := make(map[string]string) + tests[""] = "" + tests["2.2-preview.4"] = "2.2-preview.3" + tests["2.2-preview"] = "2.2-preview" + tests["2.2-preview.3"] = "2.2-preview.3" + tests["2.2-preview.2"] = "2.2-preview.2" + tests["2.1-preview.4"] = "2.1-preview.3" + tests["2.1-preview.3"] = "2.1-preview.3" + tests["1.0-preview.3"] = "1.0-preview.3" + tests["2.2"] = "2.2-preview" + tests["1.0"] = "1.0-preview" + tests["2.2-preview"] = "2.2-preview" + tests["1.0-preview"] = "1.0-preview" + tests["2.3-preview"] = "2.2-preview" + tests["3.0-preview"] = "2.2-preview" + + for requested, expected := range tests { + compareVersions(t, unreleasedApiResourceLocation, requested, expected) + } +} + +func TestNegotiateRequestVersion_ReleasedApi(t *testing.T) { + // key is requested version, value is expected negotiated version + tests := make(map[string]string) + tests[""] = "" + tests["2.2-preview.4"] = "2.2-preview.3" + tests["2.2-preview"] = "2.2-preview" + tests["2.2-preview.3"] = "2.2-preview.3" + tests["2.2-preview.2"] = "2.2-preview.2" + tests["2.1-preview.4"] = "2.1-preview.3" + tests["2.1-preview.3"] = "2.1-preview.3" + tests["1.0-preview.3"] = "1.0-preview.3" + tests["2.2-preview"] = "2.2-preview" + tests["1.0-preview"] = "1.0-preview" + tests["2.3-preview"] = "2.2-preview" + tests["3.0-preview"] = "2.2-preview" + tests["3.0"] = "2.2-preview" + tests["2.3"] = "2.2-preview" + tests["2.2"] = "2.2-preview" + tests["2.1"] = "2.1" + tests["2.0"] = "2.0" + tests["1.0"] = "1.0" + + for requested, expected := range tests { + compareVersions(t, releasedApiResourceLocation, requested, expected) + } +} + +func compareVersions(t *testing.T, apiResourceLocation *ApiResourceLocation, requestedVersion string, expectedVersion string) { + negotiatedVersion, err := negotiateRequestVersion(apiResourceLocation, requestedVersion) + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + if negotiatedVersion != expectedVersion { + t.Errorf("Negotiated version did not match expected. Requested: %v Expected: %v Actual: %v", requestedVersion, expectedVersion, negotiatedVersion) + } +} + +var resourceVersionThree = 3 +var version00 = "0.0" +var version10 = "1.0" +var version20 = "2.0" +var version21 = "2.1" +var version22 = "2.2" + +var unreleasedApiResourceLocation = &ApiResourceLocation{ + ResourceVersion: &resourceVersionThree, + MinVersion: &version10, + MaxVersion: &version22, + ReleasedVersion: &version00, +} + +var releasedApiResourceLocation = &ApiResourceLocation{ + ResourceVersion: &resourceVersionThree, + MinVersion: &version20, + MaxVersion: &version22, + ReleasedVersion: &version21, +} diff --git a/azuredevops/webapi/models.go b/azuredevops/webapi/models.go new file mode 100644 index 00000000..b653f7d9 --- /dev/null +++ b/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/azuredevops/wiki/client.go b/azuredevops/wiki/client.go new file mode 100644 index 00000000..18d288eb --- /dev/null +++ b/azuredevops/wiki/client.go @@ -0,0 +1,962 @@ +// -------------------------------------------------------------------------------------------- +// 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 wiki + +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/git" + "io" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("bf7d82a0-8aa5-4613-94ef-6172a5ea01f3") + +type Client interface { + // Creates an attachment in the wiki. + CreateAttachment(context.Context, CreateAttachmentArgs) (*WikiAttachmentResponse, error) + // Creates or edits a wiki page. + CreateOrUpdatePage(context.Context, CreateOrUpdatePageArgs) (*WikiPageResponse, error) + // Creates a page move operation that updates the path and order of the page as provided in the parameters. + CreatePageMove(context.Context, CreatePageMoveArgs) (*WikiPageMoveResponse, error) + // Creates the wiki resource. + CreateWiki(context.Context, CreateWikiArgs) (*WikiV2, error) + // Deletes a wiki page. + DeletePage(context.Context, DeletePageArgs) (*WikiPageResponse, error) + // [Preview API] Deletes a wiki page. + DeletePageById(context.Context, DeletePageByIdArgs) (*WikiPageResponse, error) + // Deletes the wiki corresponding to the wiki name or Id provided. + DeleteWiki(context.Context, DeleteWikiArgs) (*WikiV2, error) + // Gets all wikis in a project or collection. + GetAllWikis(context.Context, GetAllWikisArgs) (*[]WikiV2, error) + // Gets metadata or content of the wiki page for the provided path. Content negotiation is done based on the `Accept` header sent in the request. + GetPage(context.Context, GetPageArgs) (*WikiPageResponse, error) + // [Preview API] Gets metadata or content of the wiki page for the provided page id. Content negotiation is done based on the `Accept` header sent in the request. + GetPageById(context.Context, GetPageByIdArgs) (*WikiPageResponse, error) + // [Preview API] Gets metadata or content of the wiki page for the provided page id. Content negotiation is done based on the `Accept` header sent in the request. + GetPageByIdText(context.Context, GetPageByIdTextArgs) (io.ReadCloser, error) + // [Preview API] Gets metadata or content of the wiki page for the provided page id. Content negotiation is done based on the `Accept` header sent in the request. + GetPageByIdZip(context.Context, GetPageByIdZipArgs) (io.ReadCloser, error) + // Gets metadata or content of the wiki page for the provided path. Content negotiation is done based on the `Accept` header sent in the request. + GetPageText(context.Context, GetPageTextArgs) (io.ReadCloser, error) + // Gets metadata or content of the wiki page for the provided path. Content negotiation is done based on the `Accept` header sent in the request. + GetPageZip(context.Context, GetPageZipArgs) (io.ReadCloser, error) + // Gets the wiki corresponding to the wiki name or Id provided. + GetWiki(context.Context, GetWikiArgs) (*WikiV2, error) + // [Preview API] Edits a wiki page. + UpdatePageById(context.Context, UpdatePageByIdArgs) (*WikiPageResponse, error) + // Updates the wiki corresponding to the wiki Id or name provided using the update parameters. + UpdateWiki(context.Context, UpdateWikiArgs) (*WikiV2, 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 +} + +// Creates an attachment in the wiki. +func (client *ClientImpl) CreateAttachment(ctx context.Context, args CreateAttachmentArgs) (*WikiAttachmentResponse, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + + queryParams := url.Values{} + if args.Name == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "name"} + } + queryParams.Add("name", *args.Name) + 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("c4382d8d-fefc-40e0-92c5-49852e9e17c0") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, queryParams, args.UploadStream, "application/octet-stream", "application/json", nil) + if err != nil { + return nil, err + } + + var responseBodyValue WikiAttachment + err = client.Client.UnmarshalBody(resp, &responseBodyValue) + + var responseValue *WikiAttachmentResponse + if err == nil { + responseValue = &WikiAttachmentResponse{ + Attachment: &responseBodyValue, + ETag: &[]string{resp.Header.Get("ETag")}, + } + } + + return responseValue, err +} + +// Arguments for the CreateAttachment function +type CreateAttachmentArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (required) Wiki attachment name. + Name *string + // (optional) GitVersionDescriptor for the page. (Optional in case of ProjectWiki). + VersionDescriptor *git.GitVersionDescriptor +} + +// Creates or edits a wiki page. +func (client *ClientImpl) CreateOrUpdatePage(ctx context.Context, args CreateOrUpdatePageArgs) (*WikiPageResponse, error) { + if args.Parameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Parameters"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + + queryParams := url.Values{} + if args.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + if args.Comment != nil { + queryParams.Add("comment", *args.Comment) + } + 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)) + } + } + additionalHeaders := make(map[string]string) + if args.Version != nil { + additionalHeaders["If-Match"] = *args.Version + } + body, marshalErr := json.Marshal(*args.Parameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("25d3fbc7-fe3d-46cb-b5a5-0b6f79caf27b") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseBodyValue WikiPage + err = client.Client.UnmarshalBody(resp, &responseBodyValue) + + var responseValue *WikiPageResponse + if err == nil { + responseValue = &WikiPageResponse{ + Page: &responseBodyValue, + ETag: &[]string{resp.Header.Get("ETag")}, + } + } + + return responseValue, err +} + +// Arguments for the CreateOrUpdatePage function +type CreateOrUpdatePageArgs struct { + // (required) Wiki create or update operation parameters. + Parameters *WikiPageCreateOrUpdateParameters + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (required) Wiki page path. + Path *string + // (required) Version of the page on which the change is to be made. Mandatory for `Edit` scenario. To be populated in the If-Match header of the request. + Version *string + // (optional) Comment to be associated with the page operation. + Comment *string + // (optional) GitVersionDescriptor for the page. (Optional in case of ProjectWiki). + VersionDescriptor *git.GitVersionDescriptor +} + +// Creates a page move operation that updates the path and order of the page as provided in the parameters. +func (client *ClientImpl) CreatePageMove(ctx context.Context, args CreatePageMoveArgs) (*WikiPageMoveResponse, error) { + if args.PageMoveParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PageMoveParameters"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + + queryParams := url.Values{} + if args.Comment != nil { + queryParams.Add("comment", *args.Comment) + } + 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)) + } + } + body, marshalErr := json.Marshal(*args.PageMoveParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e37bbe71-cbae-49e5-9a4e-949143b9d910") + 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 responseBodyValue WikiPageMove + err = client.Client.UnmarshalBody(resp, &responseBodyValue) + + var responseValue *WikiPageMoveResponse + if err == nil { + responseValue = &WikiPageMoveResponse{ + PageMove: &responseBodyValue, + ETag: &[]string{resp.Header.Get("ETag")}, + } + } + + return responseValue, err +} + +// Arguments for the CreatePageMove function +type CreatePageMoveArgs struct { + // (required) Page more operation parameters. + PageMoveParameters *WikiPageMoveParameters + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (optional) Comment that is to be associated with this page move. + Comment *string + // (optional) GitVersionDescriptor for the page. (Optional in case of ProjectWiki). + VersionDescriptor *git.GitVersionDescriptor +} + +// Creates the wiki resource. +func (client *ClientImpl) CreateWiki(ctx context.Context, args CreateWikiArgs) (*WikiV2, error) { + if args.WikiCreateParams == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WikiCreateParams"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.WikiCreateParams) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("288d122c-dbd4-451d-aa5f-7dbbba070728") + 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 WikiV2 + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateWiki function +type CreateWikiArgs struct { + // (required) Parameters for the wiki creation. + WikiCreateParams *WikiCreateParametersV2 + // (optional) Project ID or project name + Project *string +} + +// Deletes a wiki page. +func (client *ClientImpl) DeletePage(ctx context.Context, args DeletePageArgs) (*WikiPageResponse, 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.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + + queryParams := url.Values{} + if args.Path == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "path"} + } + queryParams.Add("path", *args.Path) + if args.Comment != nil { + queryParams.Add("comment", *args.Comment) + } + 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("25d3fbc7-fe3d-46cb-b5a5-0b6f79caf27b") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseBodyValue WikiPage + err = client.Client.UnmarshalBody(resp, &responseBodyValue) + + var responseValue *WikiPageResponse + if err == nil { + responseValue = &WikiPageResponse{ + Page: &responseBodyValue, + ETag: &[]string{resp.Header.Get("ETag")}, + } + } + + return responseValue, err +} + +// Arguments for the DeletePage function +type DeletePageArgs struct { + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (required) Wiki page path. + Path *string + // (optional) Comment to be associated with this page delete. + Comment *string + // (optional) GitVersionDescriptor for the page. (Optional in case of ProjectWiki). + VersionDescriptor *git.GitVersionDescriptor +} + +// [Preview API] Deletes a wiki page. +func (client *ClientImpl) DeletePageById(ctx context.Context, args DeletePageByIdArgs) (*WikiPageResponse, 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.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + queryParams := url.Values{} + if args.Comment != nil { + queryParams.Add("comment", *args.Comment) + } + locationId, _ := uuid.Parse("ceddcf75-1068-452d-8b13-2d4d76e1f970") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseBodyValue WikiPage + err = client.Client.UnmarshalBody(resp, &responseBodyValue) + + var responseValue *WikiPageResponse + if err == nil { + responseValue = &WikiPageResponse{ + Page: &responseBodyValue, + ETag: &[]string{resp.Header.Get("ETag")}, + } + } + + return responseValue, err +} + +// Arguments for the DeletePageById function +type DeletePageByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (required) Wiki page id. + Id *int + // (optional) Comment to be associated with this page delete. + Comment *string +} + +// Deletes the wiki corresponding to the wiki name or Id provided. +func (client *ClientImpl) DeleteWiki(ctx context.Context, args DeleteWikiArgs) (*WikiV2, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + + locationId, _ := uuid.Parse("288d122c-dbd4-451d-aa5f-7dbbba070728") + 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 WikiV2 + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the DeleteWiki function +type DeleteWikiArgs struct { + // (required) Wiki name or Id. + WikiIdentifier *string + // (optional) Project ID or project name + Project *string +} + +// Gets all wikis in a project or collection. +func (client *ClientImpl) GetAllWikis(ctx context.Context, args GetAllWikisArgs) (*[]WikiV2, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + locationId, _ := uuid.Parse("288d122c-dbd4-451d-aa5f-7dbbba070728") + 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 []WikiV2 + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAllWikis function +type GetAllWikisArgs struct { + // (optional) Project ID or project name + Project *string +} + +// Gets metadata or content of the wiki page for the provided path. Content negotiation is done based on the `Accept` header sent in the request. +func (client *ClientImpl) GetPage(ctx context.Context, args GetPageArgs) (*WikiPageResponse, 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.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + + queryParams := url.Values{} + if args.Path != nil { + queryParams.Add("path", *args.Path) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + 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)) + } + locationId, _ := uuid.Parse("25d3fbc7-fe3d-46cb-b5a5-0b6f79caf27b") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseBodyValue WikiPage + err = client.Client.UnmarshalBody(resp, &responseBodyValue) + + var responseValue *WikiPageResponse + if err == nil { + responseValue = &WikiPageResponse{ + Page: &responseBodyValue, + ETag: &[]string{resp.Header.Get("ETag")}, + } + } + + return responseValue, err +} + +// Arguments for the GetPage function +type GetPageArgs struct { + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (optional) Wiki page path. + Path *string + // (optional) Recursion level for subpages retrieval. Defaults to `None` (Optional). + RecursionLevel *git.VersionControlRecursionType + // (optional) GitVersionDescriptor for the page. Defaults to the default branch (Optional). + VersionDescriptor *git.GitVersionDescriptor + // (optional) True to include the content of the page in the response for Json content type. Defaults to false (Optional) + IncludeContent *bool +} + +// [Preview API] Gets metadata or content of the wiki page for the provided page id. Content negotiation is done based on the `Accept` header sent in the request. +func (client *ClientImpl) GetPageById(ctx context.Context, args GetPageByIdArgs) (*WikiPageResponse, 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.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + queryParams := url.Values{} + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.IncludeContent != nil { + queryParams.Add("includeContent", strconv.FormatBool(*args.IncludeContent)) + } + locationId, _ := uuid.Parse("ceddcf75-1068-452d-8b13-2d4d76e1f970") + 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 WikiPage + err = client.Client.UnmarshalBody(resp, &responseBodyValue) + + var responseValue *WikiPageResponse + if err == nil { + responseValue = &WikiPageResponse{ + Page: &responseBodyValue, + ETag: &[]string{resp.Header.Get("ETag")}, + } + } + + return responseValue, err +} + +// Arguments for the GetPageById function +type GetPageByIdArgs struct { + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (required) Wiki page id. + Id *int + // (optional) Recursion level for subpages retrieval. Defaults to `None` (Optional). + RecursionLevel *git.VersionControlRecursionType + // (optional) True to include the content of the page in the response for Json content type. Defaults to false (Optional) + IncludeContent *bool +} + +// [Preview API] Gets metadata or content of the wiki page for the provided page id. Content negotiation is done based on the `Accept` header sent in the request. +func (client *ClientImpl) GetPageByIdText(ctx context.Context, args GetPageByIdTextArgs) (io.ReadCloser, 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.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + queryParams := url.Values{} + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.IncludeContent != nil { + queryParams.Add("includeContent", strconv.FormatBool(*args.IncludeContent)) + } + locationId, _ := uuid.Parse("ceddcf75-1068-452d-8b13-2d4d76e1f970") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "text/plain", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetPageByIdText function +type GetPageByIdTextArgs struct { + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (required) Wiki page id. + Id *int + // (optional) Recursion level for subpages retrieval. Defaults to `None` (Optional). + RecursionLevel *git.VersionControlRecursionType + // (optional) True to include the content of the page in the response for Json content type. Defaults to false (Optional) + IncludeContent *bool +} + +// [Preview API] Gets metadata or content of the wiki page for the provided page id. Content negotiation is done based on the `Accept` header sent in the request. +func (client *ClientImpl) GetPageByIdZip(ctx context.Context, args GetPageByIdZipArgs) (io.ReadCloser, 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.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + queryParams := url.Values{} + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + if args.IncludeContent != nil { + queryParams.Add("includeContent", strconv.FormatBool(*args.IncludeContent)) + } + locationId, _ := uuid.Parse("ceddcf75-1068-452d-8b13-2d4d76e1f970") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, queryParams, nil, "", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetPageByIdZip function +type GetPageByIdZipArgs struct { + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (required) Wiki page id. + Id *int + // (optional) Recursion level for subpages retrieval. Defaults to `None` (Optional). + RecursionLevel *git.VersionControlRecursionType + // (optional) True to include the content of the page in the response for Json content type. Defaults to false (Optional) + IncludeContent *bool +} + +// Gets metadata or content of the wiki page for the provided path. Content negotiation is done based on the `Accept` header sent in the request. +func (client *ClientImpl) GetPageText(ctx context.Context, args GetPageTextArgs) (io.ReadCloser, 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.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + + queryParams := url.Values{} + if args.Path != nil { + queryParams.Add("path", *args.Path) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + 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)) + } + locationId, _ := uuid.Parse("25d3fbc7-fe3d-46cb-b5a5-0b6f79caf27b") + 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 GetPageText function +type GetPageTextArgs struct { + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (optional) Wiki page path. + Path *string + // (optional) Recursion level for subpages retrieval. Defaults to `None` (Optional). + RecursionLevel *git.VersionControlRecursionType + // (optional) GitVersionDescriptor for the page. Defaults to the default branch (Optional). + VersionDescriptor *git.GitVersionDescriptor + // (optional) True to include the content of the page in the response for Json content type. Defaults to false (Optional) + IncludeContent *bool +} + +// Gets metadata or content of the wiki page for the provided path. Content negotiation is done based on the `Accept` header sent in the request. +func (client *ClientImpl) GetPageZip(ctx context.Context, args GetPageZipArgs) (io.ReadCloser, 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.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + + queryParams := url.Values{} + if args.Path != nil { + queryParams.Add("path", *args.Path) + } + if args.RecursionLevel != nil { + queryParams.Add("recursionLevel", string(*args.RecursionLevel)) + } + 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)) + } + locationId, _ := uuid.Parse("25d3fbc7-fe3d-46cb-b5a5-0b6f79caf27b") + 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 GetPageZip function +type GetPageZipArgs struct { + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (optional) Wiki page path. + Path *string + // (optional) Recursion level for subpages retrieval. Defaults to `None` (Optional). + RecursionLevel *git.VersionControlRecursionType + // (optional) GitVersionDescriptor for the page. Defaults to the default branch (Optional). + VersionDescriptor *git.GitVersionDescriptor + // (optional) True to include the content of the page in the response for Json content type. Defaults to false (Optional) + IncludeContent *bool +} + +// Gets the wiki corresponding to the wiki name or Id provided. +func (client *ClientImpl) GetWiki(ctx context.Context, args GetWikiArgs) (*WikiV2, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + + locationId, _ := uuid.Parse("288d122c-dbd4-451d-aa5f-7dbbba070728") + 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 WikiV2 + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWiki function +type GetWikiArgs struct { + // (required) Wiki name or id. + WikiIdentifier *string + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Edits a wiki page. +func (client *ClientImpl) UpdatePageById(ctx context.Context, args UpdatePageByIdArgs) (*WikiPageResponse, error) { + if args.Parameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Parameters"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + queryParams := url.Values{} + if args.Comment != nil { + queryParams.Add("comment", *args.Comment) + } + additionalHeaders := make(map[string]string) + if args.Version != nil { + additionalHeaders["If-Match"] = *args.Version + } + body, marshalErr := json.Marshal(*args.Parameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("ceddcf75-1068-452d-8b13-2d4d76e1f970") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", additionalHeaders) + if err != nil { + return nil, err + } + + var responseBodyValue WikiPage + err = client.Client.UnmarshalBody(resp, &responseBodyValue) + + var responseValue *WikiPageResponse + if err == nil { + responseValue = &WikiPageResponse{ + Page: &responseBodyValue, + ETag: &[]string{resp.Header.Get("ETag")}, + } + } + + return responseValue, err +} + +// Arguments for the UpdatePageById function +type UpdatePageByIdArgs struct { + // (required) Wiki update operation parameters. + Parameters *WikiPageCreateOrUpdateParameters + // (required) Project ID or project name + Project *string + // (required) Wiki Id or name. + WikiIdentifier *string + // (required) Wiki page id. + Id *int + // (required) Version of the page on which the change is to be made. Mandatory for `Edit` scenario. To be populated in the If-Match header of the request. + Version *string + // (optional) Comment to be associated with the page operation. + Comment *string +} + +// Updates the wiki corresponding to the wiki Id or name provided using the update parameters. +func (client *ClientImpl) UpdateWiki(ctx context.Context, args UpdateWikiArgs) (*WikiV2, error) { + if args.UpdateParameters == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateParameters"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.WikiIdentifier == nil || *args.WikiIdentifier == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WikiIdentifier"} + } + routeValues["wikiIdentifier"] = *args.WikiIdentifier + + body, marshalErr := json.Marshal(*args.UpdateParameters) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("288d122c-dbd4-451d-aa5f-7dbbba070728") + 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 WikiV2 + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateWiki function +type UpdateWikiArgs struct { + // (required) Update parameters. + UpdateParameters *WikiUpdateParameters + // (required) Wiki name or Id. + WikiIdentifier *string + // (optional) Project ID or project name + Project *string +} diff --git a/azuredevops/wiki/models.go b/azuredevops/wiki/models.go new file mode 100644 index 00000000..296164a9 --- /dev/null +++ b/azuredevops/wiki/models.go @@ -0,0 +1,217 @@ +// -------------------------------------------------------------------------------------------- +// 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 wiki + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/git" +) + +// Defines a wiki repository which encapsulates the git repository backing the wiki. +type Wiki struct { + // Wiki name. + Name *string `json:"name,omitempty"` + // ID of the project in which the wiki is to be created. + ProjectId *uuid.UUID `json:"projectId,omitempty"` + // The head commit associated with the git repository backing up the wiki. + HeadCommit *string `json:"headCommit,omitempty"` + // The ID of the wiki which is same as the ID of the Git repository that it is backed by. + Id *uuid.UUID `json:"id,omitempty"` + // The git repository that backs up the wiki. + Repository *git.GitRepository `json:"repository,omitempty"` +} + +// Defines properties for wiki attachment file. +type WikiAttachment struct { + // Name of the wiki attachment file. + Name *string `json:"name,omitempty"` + // Path of the wiki attachment file. + Path *string `json:"path,omitempty"` +} + +// Response contract for the Wiki Attachments API +type WikiAttachmentResponse struct { + // Defines properties for wiki attachment file. + Attachment *WikiAttachment `json:"attachment,omitempty"` + // Contains the list of ETag values from the response header of the attachments API call. The first item in the list contains the version of the wiki attachment. + ETag *[]string `json:"eTag,omitempty"` +} + +// Base wiki creation parameters. +type WikiCreateBaseParameters struct { + // Folder path inside repository which is shown as Wiki. Not required for ProjectWiki type. + MappedPath *string `json:"mappedPath,omitempty"` + // Wiki name. + Name *string `json:"name,omitempty"` + // ID of the project in which the wiki is to be created. + ProjectId *uuid.UUID `json:"projectId,omitempty"` + // ID of the git repository that backs up the wiki. Not required for ProjectWiki type. + RepositoryId *uuid.UUID `json:"repositoryId,omitempty"` + // Type of the wiki. + Type *WikiType `json:"type,omitempty"` +} + +// Wiki creations parameters. +type WikiCreateParameters struct { + // Wiki name. + Name *string `json:"name,omitempty"` + // ID of the project in which the wiki is to be created. + ProjectId *uuid.UUID `json:"projectId,omitempty"` +} + +// Wiki creation parameters. +type WikiCreateParametersV2 struct { + // Folder path inside repository which is shown as Wiki. Not required for ProjectWiki type. + MappedPath *string `json:"mappedPath,omitempty"` + // Wiki name. + Name *string `json:"name,omitempty"` + // ID of the project in which the wiki is to be created. + ProjectId *uuid.UUID `json:"projectId,omitempty"` + // ID of the git repository that backs up the wiki. Not required for ProjectWiki type. + RepositoryId *uuid.UUID `json:"repositoryId,omitempty"` + // Type of the wiki. + Type *WikiType `json:"type,omitempty"` + // Version of the wiki. Not required for ProjectWiki type. + Version *git.GitVersionDescriptor `json:"version,omitempty"` +} + +// Defines a page in a wiki. +type WikiPage struct { + // Content of the wiki page. + Content *string `json:"content,omitempty"` + // Path of the git item corresponding to the wiki page stored in the backing Git repository. + GitItemPath *string `json:"gitItemPath,omitempty"` + // When present, permanent identifier for the wiki page + Id *int `json:"id,omitempty"` + // True if a page is non-conforming, i.e. 1) if the name doesn't match page naming standards. 2) if the page does not have a valid entry in the appropriate order file. + IsNonConformant *bool `json:"isNonConformant,omitempty"` + // True if this page has subpages under its path. + IsParentPage *bool `json:"isParentPage,omitempty"` + // Order of the wiki page, relative to other pages in the same hierarchy level. + Order *int `json:"order,omitempty"` + // Path of the wiki page. + Path *string `json:"path,omitempty"` + // Remote web url to the wiki page. + RemoteUrl *string `json:"remoteUrl,omitempty"` + // List of subpages of the current page. + SubPages *[]WikiPage `json:"subPages,omitempty"` + // REST url for this wiki page. + Url *string `json:"url,omitempty"` +} + +// Contract encapsulating parameters for the page create or update operations. +type WikiPageCreateOrUpdateParameters struct { + // Content of the wiki page. + Content *string `json:"content,omitempty"` +} + +// Request contract for Wiki Page Move. +type WikiPageMove struct { + // New order of the wiki page. + NewOrder *int `json:"newOrder,omitempty"` + // New path of the wiki page. + NewPath *string `json:"newPath,omitempty"` + // Current path of the wiki page. + Path *string `json:"path,omitempty"` + // Resultant page of this page move operation. + Page *WikiPage `json:"page,omitempty"` +} + +// Contract encapsulating parameters for the page move operation. +type WikiPageMoveParameters struct { + // New order of the wiki page. + NewOrder *int `json:"newOrder,omitempty"` + // New path of the wiki page. + NewPath *string `json:"newPath,omitempty"` + // Current path of the wiki page. + Path *string `json:"path,omitempty"` +} + +// Response contract for the Wiki Page Move API. +type WikiPageMoveResponse struct { + // Contains the list of ETag values from the response header of the page move API call. The first item in the list contains the version of the wiki page subject to page move. + ETag *[]string `json:"eTag,omitempty"` + // Defines properties for wiki page move. + PageMove *WikiPageMove `json:"pageMove,omitempty"` +} + +// Response contract for the Wiki Pages PUT, PATCH and DELETE APIs. +type WikiPageResponse struct { + // Contains the list of ETag values from the response header of the pages API call. The first item in the list contains the version of the wiki page. + ETag *[]string `json:"eTag,omitempty"` + // Defines properties for wiki page. + Page *WikiPage `json:"page,omitempty"` +} + +// Defines properties for wiki page view stats. +type WikiPageViewStats struct { + // Wiki page view count. + Count *int `json:"count,omitempty"` + // Wiki page last viewed time. + LastViewedTime *azuredevops.Time `json:"lastViewedTime,omitempty"` + // Wiki page path. + Path *string `json:"path,omitempty"` +} + +// Wiki types. +type WikiType string + +type wikiTypeValuesType struct { + ProjectWiki WikiType + CodeWiki WikiType +} + +var WikiTypeValues = wikiTypeValuesType{ + // Indicates that the wiki is provisioned for the team project + ProjectWiki: "projectWiki", + // Indicates that the wiki is published from a git repository + CodeWiki: "codeWiki", +} + +type WikiUpdatedNotificationMessage struct { + // Collection host Id for which the wikis are updated. + CollectionId *uuid.UUID `json:"collectionId,omitempty"` + // Project Id for which the wikis are updated. + ProjectId *uuid.UUID `json:"projectId,omitempty"` + // Repository Id associated with the particular wiki which is added, updated or deleted. + RepositoryId *uuid.UUID `json:"repositoryId,omitempty"` +} + +// Wiki update parameters. +type WikiUpdateParameters struct { + // Name for wiki. + Name *string `json:"name,omitempty"` + // Versions of the wiki. + Versions *[]git.GitVersionDescriptor `json:"versions,omitempty"` +} + +// Defines a wiki resource. +type WikiV2 struct { + // Folder path inside repository which is shown as Wiki. Not required for ProjectWiki type. + MappedPath *string `json:"mappedPath,omitempty"` + // Wiki name. + Name *string `json:"name,omitempty"` + // ID of the project in which the wiki is to be created. + ProjectId *uuid.UUID `json:"projectId,omitempty"` + // ID of the git repository that backs up the wiki. Not required for ProjectWiki type. + RepositoryId *uuid.UUID `json:"repositoryId,omitempty"` + // Type of the wiki. + Type *WikiType `json:"type,omitempty"` + // ID of the wiki. + Id *uuid.UUID `json:"id,omitempty"` + // Properties of the wiki. + Properties *map[string]string `json:"properties,omitempty"` + // Remote web url to the wiki. + RemoteUrl *string `json:"remoteUrl,omitempty"` + // REST url for this wiki. + Url *string `json:"url,omitempty"` + // Versions of the wiki. + Versions *[]git.GitVersionDescriptor `json:"versions,omitempty"` +} diff --git a/azuredevops/work/client.go b/azuredevops/work/client.go new file mode 100644 index 00000000..5c1b3ec1 --- /dev/null +++ b/azuredevops/work/client.go @@ -0,0 +1,1981 @@ +// -------------------------------------------------------------------------------------------- +// 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 work + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("1d4f49f9-02b9-4e26-b826-2cdb6195f2a9") + +type Client interface { + // Add a new plan for the team + CreatePlan(context.Context, CreatePlanArgs) (*Plan, error) + // Delete the specified plan + DeletePlan(context.Context, DeletePlanArgs) error + // Delete a team's iteration by iterationId + DeleteTeamIteration(context.Context, DeleteTeamIterationArgs) error + // [Preview API] Get a backlog level + GetBacklog(context.Context, GetBacklogArgs) (*BacklogLevelConfiguration, error) + // Gets backlog configuration for a team + GetBacklogConfigurations(context.Context, GetBacklogConfigurationsArgs) (*BacklogConfiguration, error) + // [Preview API] Get a list of work items within a backlog level + GetBacklogLevelWorkItems(context.Context, GetBacklogLevelWorkItemsArgs) (*BacklogLevelWorkItems, error) + // [Preview API] List all backlog levels + GetBacklogs(context.Context, GetBacklogsArgs) (*[]BacklogLevelConfiguration, error) + // Get board + GetBoard(context.Context, GetBoardArgs) (*Board, error) + // Get board card Rule settings for the board id or board by name + GetBoardCardRuleSettings(context.Context, GetBoardCardRuleSettingsArgs) (*BoardCardRuleSettings, error) + // Get board card settings for the board id or board by name + GetBoardCardSettings(context.Context, GetBoardCardSettingsArgs) (*BoardCardSettings, error) + // Get a board chart + GetBoardChart(context.Context, GetBoardChartArgs) (*BoardChart, error) + // Get board charts + GetBoardCharts(context.Context, GetBoardChartsArgs) (*[]BoardChartReference, error) + // Get columns on a board + GetBoardColumns(context.Context, GetBoardColumnsArgs) (*[]BoardColumn, error) + // [Preview API] Returns the list of parent field filter model for the given list of workitem ids + GetBoardMappingParentItems(context.Context, GetBoardMappingParentItemsArgs) (*[]ParentChildWIMap, error) + // Get rows on a board + GetBoardRows(context.Context, GetBoardRowsArgs) (*[]BoardRow, error) + // Get boards + GetBoards(context.Context, GetBoardsArgs) (*[]BoardReference, error) + // [Preview API] Get board user settings for a board id + GetBoardUserSettings(context.Context, GetBoardUserSettingsArgs) (*BoardUserSettings, error) + // Get a team's capacity + GetCapacitiesWithIdentityRef(context.Context, GetCapacitiesWithIdentityRefArgs) (*[]TeamMemberCapacityIdentityRef, error) + // Get a team member's capacity + GetCapacityWithIdentityRef(context.Context, GetCapacityWithIdentityRefArgs) (*TeamMemberCapacityIdentityRef, error) + // Get available board columns in a project + GetColumnSuggestedValues(context.Context, GetColumnSuggestedValuesArgs) (*[]BoardSuggestedValue, error) + // Get Delivery View Data + GetDeliveryTimelineData(context.Context, GetDeliveryTimelineDataArgs) (*DeliveryViewData, error) + // [Preview API] Get work items for iteration + GetIterationWorkItems(context.Context, GetIterationWorkItemsArgs) (*IterationWorkItems, error) + // Get the information for the specified plan + GetPlan(context.Context, GetPlanArgs) (*Plan, error) + // Get the information for all the plans configured for the given team + GetPlans(context.Context, GetPlansArgs) (*[]Plan, error) + // [Preview API] Get process configuration + GetProcessConfiguration(context.Context, GetProcessConfigurationArgs) (*ProcessConfiguration, error) + // Get available board rows in a project + GetRowSuggestedValues(context.Context, GetRowSuggestedValuesArgs) (*[]BoardSuggestedValue, error) + // Get team's days off for an iteration + GetTeamDaysOff(context.Context, GetTeamDaysOffArgs) (*TeamSettingsDaysOff, error) + // Get a collection of team field values + GetTeamFieldValues(context.Context, GetTeamFieldValuesArgs) (*TeamFieldValues, error) + // Get team's iteration by iterationId + GetTeamIteration(context.Context, GetTeamIterationArgs) (*TeamSettingsIteration, error) + // Get a team's iterations using timeframe filter + GetTeamIterations(context.Context, GetTeamIterationsArgs) (*[]TeamSettingsIteration, error) + // Get a team's settings + GetTeamSettings(context.Context, GetTeamSettingsArgs) (*TeamSetting, error) + // Add an iteration to the team + PostTeamIteration(context.Context, PostTeamIterationArgs) (*TeamSettingsIteration, error) + // [Preview API] Reorder Product Backlog/Boards Work Items + ReorderBacklogWorkItems(context.Context, ReorderBacklogWorkItemsArgs) (*[]ReorderResult, error) + // [Preview API] Reorder Sprint Backlog/Taskboard Work Items + ReorderIterationWorkItems(context.Context, ReorderIterationWorkItemsArgs) (*[]ReorderResult, error) + // Replace a team's capacity + ReplaceCapacitiesWithIdentityRef(context.Context, ReplaceCapacitiesWithIdentityRefArgs) (*[]TeamMemberCapacityIdentityRef, error) + // Update board options + SetBoardOptions(context.Context, SetBoardOptionsArgs) (*map[string]string, error) + // Update board card Rule settings for the board id or board by name + UpdateBoardCardRuleSettings(context.Context, UpdateBoardCardRuleSettingsArgs) (*BoardCardRuleSettings, error) + // Update board card settings for the board id or board by name + UpdateBoardCardSettings(context.Context, UpdateBoardCardSettingsArgs) (*BoardCardSettings, error) + // Update a board chart + UpdateBoardChart(context.Context, UpdateBoardChartArgs) (*BoardChart, error) + // Update columns on a board + UpdateBoardColumns(context.Context, UpdateBoardColumnsArgs) (*[]BoardColumn, error) + // Update rows on a board + UpdateBoardRows(context.Context, UpdateBoardRowsArgs) (*[]BoardRow, error) + // [Preview API] Update board user settings for the board id + UpdateBoardUserSettings(context.Context, UpdateBoardUserSettingsArgs) (*BoardUserSettings, error) + // Update a team member's capacity + UpdateCapacityWithIdentityRef(context.Context, UpdateCapacityWithIdentityRefArgs) (*TeamMemberCapacityIdentityRef, error) + // Update the information for the specified plan + UpdatePlan(context.Context, UpdatePlanArgs) (*Plan, error) + // [Preview API] Update taskboard card Rule settings + UpdateTaskboardCardRuleSettings(context.Context, UpdateTaskboardCardRuleSettingsArgs) error + // [Preview API] Update taskboard card settings + UpdateTaskboardCardSettings(context.Context, UpdateTaskboardCardSettingsArgs) error + // Set a team's days off for an iteration + UpdateTeamDaysOff(context.Context, UpdateTeamDaysOffArgs) (*TeamSettingsDaysOff, error) + // Update team field values + UpdateTeamFieldValues(context.Context, UpdateTeamFieldValuesArgs) (*TeamFieldValues, error) + // Update a team's settings + UpdateTeamSettings(context.Context, UpdateTeamSettingsArgs) (*TeamSetting, 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 +} + +// Add a new plan for the team +func (client *ClientImpl) CreatePlan(ctx context.Context, args CreatePlanArgs) (*Plan, error) { + if args.PostedPlan == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PostedPlan"} + } + 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.PostedPlan) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("0b42cb47-cd73-4810-ac90-19c9ba147453") + 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 Plan + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreatePlan function +type CreatePlanArgs struct { + // (required) Plan definition + PostedPlan *CreatePlan + // (required) Project ID or project name + Project *string +} + +// Delete the specified plan +func (client *ClientImpl) DeletePlan(ctx context.Context, args DeletePlanArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Id == nil || *args.Id == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Id"} + } + routeValues["id"] = *args.Id + + locationId, _ := uuid.Parse("0b42cb47-cd73-4810-ac90-19c9ba147453") + _, 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 DeletePlan function +type DeletePlanArgs struct { + // (required) Project ID or project name + Project *string + // (required) Identifier of the plan + Id *string +} + +// Delete a team's iteration by iterationId +func (client *ClientImpl) DeleteTeamIteration(ctx context.Context, args DeleteTeamIterationArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Id == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = (*args.Id).String() + + locationId, _ := uuid.Parse("c9175577-28a1-4b06-9197-8636af9f64ad") + _, 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 DeleteTeamIteration function +type DeleteTeamIterationArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the iteration + Id *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Get a backlog level +func (client *ClientImpl) GetBacklog(ctx context.Context, args GetBacklogArgs) (*BacklogLevelConfiguration, 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.Team == nil || *args.Team == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + if args.Id == nil || *args.Id == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Id"} + } + routeValues["id"] = *args.Id + + locationId, _ := uuid.Parse("a93726f9-7867-4e38-b4f2-0bfafc2f6a94") + 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 BacklogLevelConfiguration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBacklog function +type GetBacklogArgs struct { + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string + // (required) The id of the backlog level + Id *string +} + +// Gets backlog configuration for a team +func (client *ClientImpl) GetBacklogConfigurations(ctx context.Context, args GetBacklogConfigurationsArgs) (*BacklogConfiguration, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + locationId, _ := uuid.Parse("7799f497-3cb5-4f16-ad4f-5cd06012db64") + 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 BacklogConfiguration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBacklogConfigurations function +type GetBacklogConfigurationsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Get a list of work items within a backlog level +func (client *ClientImpl) GetBacklogLevelWorkItems(ctx context.Context, args GetBacklogLevelWorkItemsArgs) (*BacklogLevelWorkItems, 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.Team == nil || *args.Team == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + if args.BacklogId == nil || *args.BacklogId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.BacklogId"} + } + routeValues["backlogId"] = *args.BacklogId + + locationId, _ := uuid.Parse("7c468d96-ab1d-4294-a360-92f07e9ccd98") + 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 BacklogLevelWorkItems + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBacklogLevelWorkItems function +type GetBacklogLevelWorkItemsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string + // (required) + BacklogId *string +} + +// [Preview API] List all backlog levels +func (client *ClientImpl) GetBacklogs(ctx context.Context, args GetBacklogsArgs) (*[]BacklogLevelConfiguration, 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.Team == nil || *args.Team == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + + locationId, _ := uuid.Parse("a93726f9-7867-4e38-b4f2-0bfafc2f6a94") + 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 []BacklogLevelConfiguration + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBacklogs function +type GetBacklogsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string +} + +// Get board +func (client *ClientImpl) GetBoard(ctx context.Context, args GetBoardArgs) (*Board, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Id == nil || *args.Id == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Id"} + } + routeValues["id"] = *args.Id + + locationId, _ := uuid.Parse("23ad19fc-3b8e-4877-8462-b3f92bc06b40") + 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 Board + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBoard function +type GetBoardArgs struct { + // (required) Project ID or project name + Project *string + // (required) identifier for board, either board's backlog level name (Eg:"Stories") or Id + Id *string + // (optional) Team ID or team name + Team *string +} + +// Get board card Rule settings for the board id or board by name +func (client *ClientImpl) GetBoardCardRuleSettings(ctx context.Context, args GetBoardCardRuleSettingsArgs) (*BoardCardRuleSettings, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + + locationId, _ := uuid.Parse("b044a3d9-02ea-49c7-91a1-b730949cc896") + 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 BoardCardRuleSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBoardCardRuleSettings function +type GetBoardCardRuleSettingsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + Board *string + // (optional) Team ID or team name + Team *string +} + +// Get board card settings for the board id or board by name +func (client *ClientImpl) GetBoardCardSettings(ctx context.Context, args GetBoardCardSettingsArgs) (*BoardCardSettings, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + + locationId, _ := uuid.Parse("07c3b467-bc60-4f05-8e34-599ce288fafc") + 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 BoardCardSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBoardCardSettings function +type GetBoardCardSettingsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + Board *string + // (optional) Team ID or team name + Team *string +} + +// Get a board chart +func (client *ClientImpl) GetBoardChart(ctx context.Context, args GetBoardChartArgs) (*BoardChart, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + locationId, _ := uuid.Parse("45fe888c-239e-49fd-958c-df1a1ab21d97") + 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 BoardChart + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBoardChart function +type GetBoardChartArgs struct { + // (required) Project ID or project name + Project *string + // (required) Identifier for board, either board's backlog level name (Eg:"Stories") or Id + Board *string + // (required) The chart name + Name *string + // (optional) Team ID or team name + Team *string +} + +// Get board charts +func (client *ClientImpl) GetBoardCharts(ctx context.Context, args GetBoardChartsArgs) (*[]BoardChartReference, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + + locationId, _ := uuid.Parse("45fe888c-239e-49fd-958c-df1a1ab21d97") + 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 []BoardChartReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBoardCharts function +type GetBoardChartsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Identifier for board, either board's backlog level name (Eg:"Stories") or Id + Board *string + // (optional) Team ID or team name + Team *string +} + +// Get columns on a board +func (client *ClientImpl) GetBoardColumns(ctx context.Context, args GetBoardColumnsArgs) (*[]BoardColumn, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + + locationId, _ := uuid.Parse("c555d7ff-84e1-47df-9923-a3fe0cd8751b") + 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 []BoardColumn + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBoardColumns function +type GetBoardColumnsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Name or ID of the specific board + Board *string + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Returns the list of parent field filter model for the given list of workitem ids +func (client *ClientImpl) GetBoardMappingParentItems(ctx context.Context, args GetBoardMappingParentItemsArgs) (*[]ParentChildWIMap, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + queryParams := url.Values{} + if args.ChildBacklogContextCategoryRefName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "childBacklogContextCategoryRefName"} + } + queryParams.Add("childBacklogContextCategoryRefName", *args.ChildBacklogContextCategoryRefName) + if args.WorkitemIds == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "workitemIds"} + } + var stringList []string + for _, item := range *args.WorkitemIds { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("workitemIds", listAsString) + locationId, _ := uuid.Parse("186abea3-5c35-432f-9e28-7a15b4312a0e") + 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 []ParentChildWIMap + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBoardMappingParentItems function +type GetBoardMappingParentItemsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + ChildBacklogContextCategoryRefName *string + // (required) + WorkitemIds *[]int + // (optional) Team ID or team name + Team *string +} + +// Get rows on a board +func (client *ClientImpl) GetBoardRows(ctx context.Context, args GetBoardRowsArgs) (*[]BoardRow, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + + locationId, _ := uuid.Parse("0863355d-aefd-4d63-8669-984c9b7b0e78") + 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 []BoardRow + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBoardRows function +type GetBoardRowsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Name or ID of the specific board + Board *string + // (optional) Team ID or team name + Team *string +} + +// Get boards +func (client *ClientImpl) GetBoards(ctx context.Context, args GetBoardsArgs) (*[]BoardReference, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + locationId, _ := uuid.Parse("23ad19fc-3b8e-4877-8462-b3f92bc06b40") + 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 []BoardReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBoards function +type GetBoardsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Get board user settings for a board id +func (client *ClientImpl) GetBoardUserSettings(ctx context.Context, args GetBoardUserSettingsArgs) (*BoardUserSettings, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + + locationId, _ := uuid.Parse("b30d9f58-1891-4b0a-b168-c46408f919b0") + 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 BoardUserSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBoardUserSettings function +type GetBoardUserSettingsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Board ID or Name + Board *string + // (optional) Team ID or team name + Team *string +} + +// Get a team's capacity +func (client *ClientImpl) GetCapacitiesWithIdentityRef(ctx context.Context, args GetCapacitiesWithIdentityRefArgs) (*[]TeamMemberCapacityIdentityRef, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = (*args.IterationId).String() + + locationId, _ := uuid.Parse("74412d15-8c1a-4352-a48d-ef1ed5587d57") + 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 []TeamMemberCapacityIdentityRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCapacitiesWithIdentityRef function +type GetCapacitiesWithIdentityRefArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the iteration + IterationId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// Get a team member's capacity +func (client *ClientImpl) GetCapacityWithIdentityRef(ctx context.Context, args GetCapacityWithIdentityRefArgs) (*TeamMemberCapacityIdentityRef, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = (*args.IterationId).String() + if args.TeamMemberId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TeamMemberId"} + } + routeValues["teamMemberId"] = (*args.TeamMemberId).String() + + locationId, _ := uuid.Parse("74412d15-8c1a-4352-a48d-ef1ed5587d57") + 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 TeamMemberCapacityIdentityRef + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCapacityWithIdentityRef function +type GetCapacityWithIdentityRefArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the iteration + IterationId *uuid.UUID + // (required) ID of the team member + TeamMemberId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// Get available board columns in a project +func (client *ClientImpl) GetColumnSuggestedValues(ctx context.Context, args GetColumnSuggestedValuesArgs) (*[]BoardSuggestedValue, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + locationId, _ := uuid.Parse("eb7ec5a3-1ba3-4fd1-b834-49a5a387e57d") + 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 []BoardSuggestedValue + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetColumnSuggestedValues function +type GetColumnSuggestedValuesArgs struct { + // (optional) Project ID or project name + Project *string +} + +// Get Delivery View Data +func (client *ClientImpl) GetDeliveryTimelineData(ctx context.Context, args GetDeliveryTimelineDataArgs) (*DeliveryViewData, 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.Id == nil || *args.Id == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Id"} + } + routeValues["id"] = *args.Id + + queryParams := url.Values{} + if args.Revision != nil { + queryParams.Add("revision", strconv.Itoa(*args.Revision)) + } + if args.StartDate != nil { + queryParams.Add("startDate", (*args.StartDate).String()) + } + if args.EndDate != nil { + queryParams.Add("endDate", (*args.EndDate).String()) + } + locationId, _ := uuid.Parse("bdd0834e-101f-49f0-a6ae-509f384a12b4") + 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 DeliveryViewData + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDeliveryTimelineData function +type GetDeliveryTimelineDataArgs struct { + // (required) Project ID or project name + Project *string + // (required) Identifier for delivery view + Id *string + // (optional) Revision of the plan for which you want data. If the current plan is a different revision you will get an ViewRevisionMismatchException exception. If you do not supply a revision you will get data for the latest revision. + Revision *int + // (optional) The start date of timeline + StartDate *azuredevops.Time + // (optional) The end date of timeline + EndDate *azuredevops.Time +} + +// [Preview API] Get work items for iteration +func (client *ClientImpl) GetIterationWorkItems(ctx context.Context, args GetIterationWorkItemsArgs) (*IterationWorkItems, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = (*args.IterationId).String() + + locationId, _ := uuid.Parse("5b3ef1a6-d3ab-44cd-bafd-c7f45db850fa") + 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 IterationWorkItems + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetIterationWorkItems function +type GetIterationWorkItemsArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the iteration + IterationId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// Get the information for the specified plan +func (client *ClientImpl) GetPlan(ctx context.Context, args GetPlanArgs) (*Plan, 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.Id == nil || *args.Id == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Id"} + } + routeValues["id"] = *args.Id + + locationId, _ := uuid.Parse("0b42cb47-cd73-4810-ac90-19c9ba147453") + 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 Plan + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPlan function +type GetPlanArgs struct { + // (required) Project ID or project name + Project *string + // (required) Identifier of the plan + Id *string +} + +// Get the information for all the plans configured for the given team +func (client *ClientImpl) GetPlans(ctx context.Context, args GetPlansArgs) (*[]Plan, 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("0b42cb47-cd73-4810-ac90-19c9ba147453") + 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 []Plan + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetPlans function +type GetPlansArgs struct { + // (required) Project ID or project name + Project *string +} + +// [Preview API] Get process configuration +func (client *ClientImpl) GetProcessConfiguration(ctx context.Context, args GetProcessConfigurationArgs) (*ProcessConfiguration, 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("f901ba42-86d2-4b0c-89c1-3f86d06daa84") + 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 ProcessConfiguration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProcessConfiguration function +type GetProcessConfigurationArgs struct { + // (required) Project ID or project name + Project *string +} + +// Get available board rows in a project +func (client *ClientImpl) GetRowSuggestedValues(ctx context.Context, args GetRowSuggestedValuesArgs) (*[]BoardSuggestedValue, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + locationId, _ := uuid.Parse("bb494cc6-a0f5-4c6c-8dca-ea6912e79eb9") + 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 []BoardSuggestedValue + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRowSuggestedValues function +type GetRowSuggestedValuesArgs struct { + // (optional) Project ID or project name + Project *string +} + +// Get team's days off for an iteration +func (client *ClientImpl) GetTeamDaysOff(ctx context.Context, args GetTeamDaysOffArgs) (*TeamSettingsDaysOff, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = (*args.IterationId).String() + + locationId, _ := uuid.Parse("2d4faa2e-9150-4cbf-a47a-932b1b4a0773") + 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 TeamSettingsDaysOff + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTeamDaysOff function +type GetTeamDaysOffArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the iteration + IterationId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// Get a collection of team field values +func (client *ClientImpl) GetTeamFieldValues(ctx context.Context, args GetTeamFieldValuesArgs) (*TeamFieldValues, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + locationId, _ := uuid.Parse("07ced576-58ed-49e6-9c1e-5cb53ab8bf2a") + 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 TeamFieldValues + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTeamFieldValues function +type GetTeamFieldValuesArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} + +// Get team's iteration by iterationId +func (client *ClientImpl) GetTeamIteration(ctx context.Context, args GetTeamIterationArgs) (*TeamSettingsIteration, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = (*args.Id).String() + + locationId, _ := uuid.Parse("c9175577-28a1-4b06-9197-8636af9f64ad") + 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 TeamSettingsIteration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTeamIteration function +type GetTeamIterationArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID of the iteration + Id *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// Get a team's iterations using timeframe filter +func (client *ClientImpl) GetTeamIterations(ctx context.Context, args GetTeamIterationsArgs) (*[]TeamSettingsIteration, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + queryParams := url.Values{} + if args.Timeframe != nil { + queryParams.Add("$timeframe", *args.Timeframe) + } + locationId, _ := uuid.Parse("c9175577-28a1-4b06-9197-8636af9f64ad") + 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 []TeamSettingsIteration + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTeamIterations function +type GetTeamIterationsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string + // (optional) A filter for which iterations are returned based on relative time. Only Current is supported currently. + Timeframe *string +} + +// Get a team's settings +func (client *ClientImpl) GetTeamSettings(ctx context.Context, args GetTeamSettingsArgs) (*TeamSetting, 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.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + locationId, _ := uuid.Parse("c3c1012b-bea7-49d7-b45e-1664e566f84c") + 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 TeamSetting + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTeamSettings function +type GetTeamSettingsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} + +// Add an iteration to the team +func (client *ClientImpl) PostTeamIteration(ctx context.Context, args PostTeamIterationArgs) (*TeamSettingsIteration, error) { + if args.Iteration == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Iteration"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + body, marshalErr := json.Marshal(*args.Iteration) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("c9175577-28a1-4b06-9197-8636af9f64ad") + 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 TeamSettingsIteration + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the PostTeamIteration function +type PostTeamIterationArgs struct { + // (required) Iteration to add + Iteration *TeamSettingsIteration + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Reorder Product Backlog/Boards Work Items +func (client *ClientImpl) ReorderBacklogWorkItems(ctx context.Context, args ReorderBacklogWorkItemsArgs) (*[]ReorderResult, error) { + if args.Operation == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Operation"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team == nil || *args.Team == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + + body, marshalErr := json.Marshal(*args.Operation) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1c22b714-e7e4-41b9-85e0-56ee13ef55ed") + 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 []ReorderResult + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReorderBacklogWorkItems function +type ReorderBacklogWorkItemsArgs struct { + // (required) + Operation *ReorderOperation + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string +} + +// [Preview API] Reorder Sprint Backlog/Taskboard Work Items +func (client *ClientImpl) ReorderIterationWorkItems(ctx context.Context, args ReorderIterationWorkItemsArgs) (*[]ReorderResult, error) { + if args.Operation == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Operation"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team == nil || *args.Team == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = (*args.IterationId).String() + + body, marshalErr := json.Marshal(*args.Operation) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("47755db2-d7eb-405a-8c25-675401525fc9") + 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 []ReorderResult + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReorderIterationWorkItems function +type ReorderIterationWorkItemsArgs struct { + // (required) + Operation *ReorderOperation + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string + // (required) The id of the iteration + IterationId *uuid.UUID +} + +// Replace a team's capacity +func (client *ClientImpl) ReplaceCapacitiesWithIdentityRef(ctx context.Context, args ReplaceCapacitiesWithIdentityRefArgs) (*[]TeamMemberCapacityIdentityRef, error) { + if args.Capacities == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Capacities"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = (*args.IterationId).String() + + body, marshalErr := json.Marshal(*args.Capacities) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("74412d15-8c1a-4352-a48d-ef1ed5587d57") + 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 []TeamMemberCapacityIdentityRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReplaceCapacitiesWithIdentityRef function +type ReplaceCapacitiesWithIdentityRefArgs struct { + // (required) Team capacity to replace + Capacities *[]TeamMemberCapacityIdentityRef + // (required) Project ID or project name + Project *string + // (required) ID of the iteration + IterationId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// Update board options +func (client *ClientImpl) SetBoardOptions(ctx context.Context, args SetBoardOptionsArgs) (*map[string]string, error) { + if args.Options == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Options"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Id == nil || *args.Id == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Id"} + } + routeValues["id"] = *args.Id + + body, marshalErr := json.Marshal(*args.Options) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("23ad19fc-3b8e-4877-8462-b3f92bc06b40") + 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 map[string]string + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the SetBoardOptions function +type SetBoardOptionsArgs struct { + // (required) options to updated + Options *map[string]string + // (required) Project ID or project name + Project *string + // (required) identifier for board, either category plural name (Eg:"Stories") or guid + Id *string + // (optional) Team ID or team name + Team *string +} + +// Update board card Rule settings for the board id or board by name +func (client *ClientImpl) UpdateBoardCardRuleSettings(ctx context.Context, args UpdateBoardCardRuleSettingsArgs) (*BoardCardRuleSettings, error) { + if args.BoardCardRuleSettings == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BoardCardRuleSettings"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + + body, marshalErr := json.Marshal(*args.BoardCardRuleSettings) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b044a3d9-02ea-49c7-91a1-b730949cc896") + 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 BoardCardRuleSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateBoardCardRuleSettings function +type UpdateBoardCardRuleSettingsArgs struct { + // (required) + BoardCardRuleSettings *BoardCardRuleSettings + // (required) Project ID or project name + Project *string + // (required) + Board *string + // (optional) Team ID or team name + Team *string +} + +// Update board card settings for the board id or board by name +func (client *ClientImpl) UpdateBoardCardSettings(ctx context.Context, args UpdateBoardCardSettingsArgs) (*BoardCardSettings, error) { + if args.BoardCardSettingsToSave == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BoardCardSettingsToSave"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + + body, marshalErr := json.Marshal(*args.BoardCardSettingsToSave) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("07c3b467-bc60-4f05-8e34-599ce288fafc") + 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 BoardCardSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateBoardCardSettings function +type UpdateBoardCardSettingsArgs struct { + // (required) + BoardCardSettingsToSave *BoardCardSettings + // (required) Project ID or project name + Project *string + // (required) + Board *string + // (optional) Team ID or team name + Team *string +} + +// Update a board chart +func (client *ClientImpl) UpdateBoardChart(ctx context.Context, args UpdateBoardChartArgs) (*BoardChart, error) { + if args.Chart == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Chart"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + body, marshalErr := json.Marshal(*args.Chart) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("45fe888c-239e-49fd-958c-df1a1ab21d97") + 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 BoardChart + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateBoardChart function +type UpdateBoardChartArgs struct { + // (required) + Chart *BoardChart + // (required) Project ID or project name + Project *string + // (required) Identifier for board, either board's backlog level name (Eg:"Stories") or Id + Board *string + // (required) The chart name + Name *string + // (optional) Team ID or team name + Team *string +} + +// Update columns on a board +func (client *ClientImpl) UpdateBoardColumns(ctx context.Context, args UpdateBoardColumnsArgs) (*[]BoardColumn, error) { + if args.BoardColumns == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BoardColumns"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + + body, marshalErr := json.Marshal(*args.BoardColumns) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("c555d7ff-84e1-47df-9923-a3fe0cd8751b") + 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 []BoardColumn + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateBoardColumns function +type UpdateBoardColumnsArgs struct { + // (required) List of board columns to update + BoardColumns *[]BoardColumn + // (required) Project ID or project name + Project *string + // (required) Name or ID of the specific board + Board *string + // (optional) Team ID or team name + Team *string +} + +// Update rows on a board +func (client *ClientImpl) UpdateBoardRows(ctx context.Context, args UpdateBoardRowsArgs) (*[]BoardRow, error) { + if args.BoardRows == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BoardRows"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + + body, marshalErr := json.Marshal(*args.BoardRows) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("0863355d-aefd-4d63-8669-984c9b7b0e78") + 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 []BoardRow + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateBoardRows function +type UpdateBoardRowsArgs struct { + // (required) List of board rows to update + BoardRows *[]BoardRow + // (required) Project ID or project name + Project *string + // (required) Name or ID of the specific board + Board *string + // (optional) Team ID or team name + Team *string +} + +// [Preview API] Update board user settings for the board id +func (client *ClientImpl) UpdateBoardUserSettings(ctx context.Context, args UpdateBoardUserSettingsArgs) (*BoardUserSettings, error) { + if args.BoardUserSettings == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BoardUserSettings"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Board == nil || *args.Board == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Board"} + } + routeValues["board"] = *args.Board + + body, marshalErr := json.Marshal(*args.BoardUserSettings) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b30d9f58-1891-4b0a-b168-c46408f919b0") + 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 BoardUserSettings + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateBoardUserSettings function +type UpdateBoardUserSettingsArgs struct { + // (required) + BoardUserSettings *map[string]string + // (required) Project ID or project name + Project *string + // (required) + Board *string + // (optional) Team ID or team name + Team *string +} + +// Update a team member's capacity +func (client *ClientImpl) UpdateCapacityWithIdentityRef(ctx context.Context, args UpdateCapacityWithIdentityRefArgs) (*TeamMemberCapacityIdentityRef, error) { + if args.Patch == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Patch"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = (*args.IterationId).String() + if args.TeamMemberId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TeamMemberId"} + } + routeValues["teamMemberId"] = (*args.TeamMemberId).String() + + body, marshalErr := json.Marshal(*args.Patch) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("74412d15-8c1a-4352-a48d-ef1ed5587d57") + 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 TeamMemberCapacityIdentityRef + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateCapacityWithIdentityRef function +type UpdateCapacityWithIdentityRefArgs struct { + // (required) Updated capacity + Patch *CapacityPatch + // (required) Project ID or project name + Project *string + // (required) ID of the iteration + IterationId *uuid.UUID + // (required) ID of the team member + TeamMemberId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// Update the information for the specified plan +func (client *ClientImpl) UpdatePlan(ctx context.Context, args UpdatePlanArgs) (*Plan, error) { + if args.UpdatedPlan == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdatedPlan"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Id == nil || *args.Id == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Id"} + } + routeValues["id"] = *args.Id + + body, marshalErr := json.Marshal(*args.UpdatedPlan) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("0b42cb47-cd73-4810-ac90-19c9ba147453") + 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 Plan + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdatePlan function +type UpdatePlanArgs struct { + // (required) Plan definition to be updated + UpdatedPlan *UpdatePlan + // (required) Project ID or project name + Project *string + // (required) Identifier of the plan + Id *string +} + +// [Preview API] Update taskboard card Rule settings +func (client *ClientImpl) UpdateTaskboardCardRuleSettings(ctx context.Context, args UpdateTaskboardCardRuleSettingsArgs) error { + if args.BoardCardRuleSettings == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.BoardCardRuleSettings"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team == nil || *args.Team == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + + body, marshalErr := json.Marshal(*args.BoardCardRuleSettings) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("3f84a8d1-1aab-423e-a94b-6dcbdcca511f") + _, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the UpdateTaskboardCardRuleSettings function +type UpdateTaskboardCardRuleSettingsArgs struct { + // (required) + BoardCardRuleSettings *BoardCardRuleSettings + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string +} + +// [Preview API] Update taskboard card settings +func (client *ClientImpl) UpdateTaskboardCardSettings(ctx context.Context, args UpdateTaskboardCardSettingsArgs) error { + if args.BoardCardSettingsToSave == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.BoardCardSettingsToSave"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team == nil || *args.Team == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + + body, marshalErr := json.Marshal(*args.BoardCardSettingsToSave) + if marshalErr != nil { + return marshalErr + } + locationId, _ := uuid.Parse("0d63745f-31f3-4cf3-9056-2a064e567637") + _, 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 err + } + + return nil +} + +// Arguments for the UpdateTaskboardCardSettings function +type UpdateTaskboardCardSettingsArgs struct { + // (required) + BoardCardSettingsToSave *BoardCardSettings + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string +} + +// Set a team's days off for an iteration +func (client *ClientImpl) UpdateTeamDaysOff(ctx context.Context, args UpdateTeamDaysOffArgs) (*TeamSettingsDaysOff, error) { + if args.DaysOffPatch == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DaysOffPatch"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.IterationId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.IterationId"} + } + routeValues["iterationId"] = (*args.IterationId).String() + + body, marshalErr := json.Marshal(*args.DaysOffPatch) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2d4faa2e-9150-4cbf-a47a-932b1b4a0773") + 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 TeamSettingsDaysOff + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTeamDaysOff function +type UpdateTeamDaysOffArgs struct { + // (required) Team's days off patch containing a list of start and end dates + DaysOffPatch *TeamSettingsDaysOffPatch + // (required) Project ID or project name + Project *string + // (required) ID of the iteration + IterationId *uuid.UUID + // (optional) Team ID or team name + Team *string +} + +// Update team field values +func (client *ClientImpl) UpdateTeamFieldValues(ctx context.Context, args UpdateTeamFieldValuesArgs) (*TeamFieldValues, error) { + if args.Patch == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Patch"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + body, marshalErr := json.Marshal(*args.Patch) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("07ced576-58ed-49e6-9c1e-5cb53ab8bf2a") + 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 TeamFieldValues + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTeamFieldValues function +type UpdateTeamFieldValuesArgs struct { + // (required) + Patch *TeamFieldValuesPatch + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} + +// Update a team's settings +func (client *ClientImpl) UpdateTeamSettings(ctx context.Context, args UpdateTeamSettingsArgs) (*TeamSetting, error) { + if args.TeamSettingsPatch == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TeamSettingsPatch"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + body, marshalErr := json.Marshal(*args.TeamSettingsPatch) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("c3c1012b-bea7-49d7-b45e-1664e566f84c") + 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 TeamSetting + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateTeamSettings function +type UpdateTeamSettingsArgs struct { + // (required) TeamSettings changes + TeamSettingsPatch *TeamSettingsPatch + // (required) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string +} diff --git a/azuredevops/work/models.go b/azuredevops/work/models.go new file mode 100644 index 00000000..1a5d600e --- /dev/null +++ b/azuredevops/work/models.go @@ -0,0 +1,911 @@ +// -------------------------------------------------------------------------------------------- +// 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 work + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" + "github.com/microsoft/azure-devops-go-api/azuredevops/workitemtracking" +) + +type Activity struct { + CapacityPerDay *float32 `json:"capacityPerDay,omitempty"` + Name *string `json:"name,omitempty"` +} + +type attribute struct { +} + +type BacklogColumn struct { + ColumnFieldReference *workitemtracking.WorkItemFieldReference `json:"columnFieldReference,omitempty"` + Width *int `json:"width,omitempty"` +} + +type BacklogConfiguration struct { + // Behavior/type field mapping + BacklogFields *BacklogFields `json:"backlogFields,omitempty"` + // Bugs behavior + BugsBehavior *BugsBehavior `json:"bugsBehavior,omitempty"` + // Hidden Backlog + HiddenBacklogs *[]string `json:"hiddenBacklogs,omitempty"` + // Is BugsBehavior Configured in the process + IsBugsBehaviorConfigured *bool `json:"isBugsBehaviorConfigured,omitempty"` + // Portfolio backlog descriptors + PortfolioBacklogs *[]BacklogLevelConfiguration `json:"portfolioBacklogs,omitempty"` + // Requirement backlog + RequirementBacklog *BacklogLevelConfiguration `json:"requirementBacklog,omitempty"` + // Task backlog + TaskBacklog *BacklogLevelConfiguration `json:"taskBacklog,omitempty"` + Url *string `json:"url,omitempty"` + // Mapped states for work item types + WorkItemTypeMappedStates *[]WorkItemTypeStateInfo `json:"workItemTypeMappedStates,omitempty"` +} + +type BacklogFields struct { + // Field Type (e.g. Order, Activity) to Field Reference Name map + TypeFields *map[string]string `json:"typeFields,omitempty"` +} + +// Contract representing a backlog level +type BacklogLevel struct { + // Reference name of the corresponding WIT category + CategoryReferenceName *string `json:"categoryReferenceName,omitempty"` + // Plural name for the backlog level + PluralName *string `json:"pluralName,omitempty"` + // Collection of work item states that are included in the plan. The server will filter to only these work item types. + WorkItemStates *[]string `json:"workItemStates,omitempty"` + // Collection of valid workitem type names for the given backlog level + WorkItemTypes *[]string `json:"workItemTypes,omitempty"` +} + +type BacklogLevelConfiguration struct { + // List of fields to include in Add Panel + AddPanelFields *[]workitemtracking.WorkItemFieldReference `json:"addPanelFields,omitempty"` + // Color for the backlog level + Color *string `json:"color,omitempty"` + // Default list of columns for the backlog + ColumnFields *[]BacklogColumn `json:"columnFields,omitempty"` + // Default Work Item Type for the backlog + DefaultWorkItemType *workitemtracking.WorkItemTypeReference `json:"defaultWorkItemType,omitempty"` + // Backlog Id (for Legacy Backlog Level from process config it can be categoryref name) + Id *string `json:"id,omitempty"` + // Indicates whether the backlog level is hidden + IsHidden *bool `json:"isHidden,omitempty"` + // Backlog Name + Name *string `json:"name,omitempty"` + // Backlog Rank (Taskbacklog is 0) + Rank *int `json:"rank,omitempty"` + // The type of this backlog level + Type *BacklogType `json:"type,omitempty"` + // Max number of work items to show in the given backlog + WorkItemCountLimit *int `json:"workItemCountLimit,omitempty"` + // Work Item types participating in this backlog as known by the project/Process, can be overridden by team settings for bugs + WorkItemTypes *[]workitemtracking.WorkItemTypeReference `json:"workItemTypes,omitempty"` +} + +// Represents work items in a backlog level +type BacklogLevelWorkItems struct { + // A list of work items within a backlog level + WorkItems *[]workitemtracking.WorkItemLink `json:"workItems,omitempty"` +} + +// Definition of the type of backlog level +type BacklogType string + +type backlogTypeValuesType struct { + Portfolio BacklogType + Requirement BacklogType + Task BacklogType +} + +var BacklogTypeValues = backlogTypeValuesType{ + // Portfolio backlog level + Portfolio: "portfolio", + // Requirement backlog level + Requirement: "requirement", + // Task backlog level + Task: "task", +} + +type Board struct { + // Id of the resource + Id *uuid.UUID `json:"id,omitempty"` + // Name of the resource + Name *string `json:"name,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` + Links interface{} `json:"_links,omitempty"` + AllowedMappings *map[string]map[string][]string `json:"allowedMappings,omitempty"` + CanEdit *bool `json:"canEdit,omitempty"` + Columns *[]BoardColumn `json:"columns,omitempty"` + Fields *BoardFields `json:"fields,omitempty"` + IsValid *bool `json:"isValid,omitempty"` + Revision *int `json:"revision,omitempty"` + Rows *[]BoardRow `json:"rows,omitempty"` +} + +// Represents a board badge. +type BoardBadge struct { + // The ID of the board represented by this badge. + BoardId *uuid.UUID `json:"boardId,omitempty"` + // A link to the SVG resource. + ImageUrl *string `json:"imageUrl,omitempty"` +} + +// Determines what columns to include on the board badge +type BoardBadgeColumnOptions string + +type boardBadgeColumnOptionsValuesType struct { + InProgressColumns BoardBadgeColumnOptions + AllColumns BoardBadgeColumnOptions + CustomColumns BoardBadgeColumnOptions +} + +var BoardBadgeColumnOptionsValues = boardBadgeColumnOptionsValuesType{ + // Only include In Progress columns + InProgressColumns: "inProgressColumns", + // Include all columns + AllColumns: "allColumns", + // Include a custom set of columns + CustomColumns: "customColumns", +} + +type BoardCardRuleSettings struct { + Links interface{} `json:"_links,omitempty"` + Rules *map[string][]Rule `json:"rules,omitempty"` + Url *string `json:"url,omitempty"` +} + +type BoardCardSettings struct { + Cards *map[string][]FieldSetting `json:"cards,omitempty"` +} + +type BoardChart struct { + // Name of the resource + Name *string `json:"name,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` + // The links for the resource + Links interface{} `json:"_links,omitempty"` + // The settings for the resource + Settings *map[string]interface{} `json:"settings,omitempty"` +} + +type BoardChartReference struct { + // Name of the resource + Name *string `json:"name,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` +} + +type BoardColumn struct { + ColumnType *BoardColumnType `json:"columnType,omitempty"` + Description *string `json:"description,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + IsSplit *bool `json:"isSplit,omitempty"` + ItemLimit *int `json:"itemLimit,omitempty"` + Name *string `json:"name,omitempty"` + StateMappings *map[string]string `json:"stateMappings,omitempty"` +} + +type BoardColumnType string + +type boardColumnTypeValuesType struct { + Incoming BoardColumnType + InProgress BoardColumnType + Outgoing BoardColumnType +} + +var BoardColumnTypeValues = boardColumnTypeValuesType{ + Incoming: "incoming", + InProgress: "inProgress", + Outgoing: "outgoing", +} + +type BoardFields struct { + ColumnField *FieldReference `json:"columnField,omitempty"` + DoneField *FieldReference `json:"doneField,omitempty"` + RowField *FieldReference `json:"rowField,omitempty"` +} + +type BoardReference struct { + // Id of the resource + Id *uuid.UUID `json:"id,omitempty"` + // Name of the resource + Name *string `json:"name,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` +} + +type BoardRow struct { + Id *uuid.UUID `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type BoardSuggestedValue struct { + Name *string `json:"name,omitempty"` +} + +type BoardUserSettings struct { + AutoRefreshState *bool `json:"autoRefreshState,omitempty"` +} + +// The behavior of the work item types that are in the work item category specified in the BugWorkItems section in the Process Configuration +type BugsBehavior string + +type bugsBehaviorValuesType struct { + Off BugsBehavior + AsRequirements BugsBehavior + AsTasks BugsBehavior +} + +var BugsBehaviorValues = bugsBehaviorValuesType{ + Off: "off", + AsRequirements: "asRequirements", + AsTasks: "asTasks", +} + +type CapacityContractBase struct { + // Collection of links relevant to resource + Links interface{} `json:"_links,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` + // Collection of capacities associated with the team member + Activities *[]Activity `json:"activities,omitempty"` + // The days off associated with the team member + DaysOff *[]DateRange `json:"daysOff,omitempty"` +} + +// Expected data from PATCH +type CapacityPatch struct { + Activities *[]Activity `json:"activities,omitempty"` + DaysOff *[]DateRange `json:"daysOff,omitempty"` +} + +// Card settings, such as fields and rules +type CardFieldSettings struct { + // A collection of field information of additional fields on cards. The index in the collection signifies the order of the field among the additional fields. Currently unused. Should be used with User Story 691539: Card setting: additional fields + AdditionalFields *[]FieldInfo `json:"additionalFields,omitempty"` + // Display format for the assigned to field + AssignedToDisplayFormat *IdentityDisplayFormat `json:"assignedToDisplayFormat,omitempty"` + // A collection of field information of rendered core fields on cards. + CoreFields *[]FieldInfo `json:"coreFields,omitempty"` + // Flag indicating whether to show assigned to field on cards. When true, AssignedToDisplayFormat will determine how the field will be displayed + ShowAssignedTo *bool `json:"showAssignedTo,omitempty"` + // Flag indicating whether to show empty fields on cards + ShowEmptyFields *bool `json:"showEmptyFields,omitempty"` + // Flag indicating whether to show ID on cards + ShowId *bool `json:"showId,omitempty"` + // Flag indicating whether to show state field on cards + ShowState *bool `json:"showState,omitempty"` + // Flag indicating whether to show tags on cards + ShowTags *bool `json:"showTags,omitempty"` +} + +// Card settings, such as fields and rules +type CardSettings struct { + // A collection of settings related to rendering of fields on cards + Fields *CardFieldSettings `json:"fields,omitempty"` +} + +// Details about a given backlog category +type CategoryConfiguration struct { + // Name + Name *string `json:"name,omitempty"` + // Category Reference Name + ReferenceName *string `json:"referenceName,omitempty"` + // Work item types for the backlog category + WorkItemTypes *[]workitemtracking.WorkItemTypeReference `json:"workItemTypes,omitempty"` +} + +type CreatePlan struct { + // Description of the plan + Description *string `json:"description,omitempty"` + // Name of the plan to create. + Name *string `json:"name,omitempty"` + // Plan properties. + Properties interface{} `json:"properties,omitempty"` + // Type of plan to create. + Type *PlanType `json:"type,omitempty"` +} + +type DateRange struct { + // End of the date range. + End *azuredevops.Time `json:"end,omitempty"` + // Start of the date range. + Start *azuredevops.Time `json:"start,omitempty"` +} + +// Data contract for Data of Delivery View +type DeliveryViewData struct { + Id *uuid.UUID `json:"id,omitempty"` + Revision *int `json:"revision,omitempty"` + // Work item child id to parent id map + ChildIdToParentIdMap *map[int]int `json:"childIdToParentIdMap,omitempty"` + // Filter criteria status of the timeline + CriteriaStatus *TimelineCriteriaStatus `json:"criteriaStatus,omitempty"` + // The end date of the delivery view data + EndDate *azuredevops.Time `json:"endDate,omitempty"` + // Max number of teams can be configured for a delivery plan. + MaxExpandedTeams *int `json:"maxExpandedTeams,omitempty"` + // The start date for the delivery view data + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // All the team data + Teams *[]TimelineTeamData `json:"teams,omitempty"` +} + +// Collection of properties, specific to the DeliveryTimelineView +type DeliveryViewPropertyCollection struct { + // Card settings + CardSettings *CardSettings `json:"cardSettings,omitempty"` + // Field criteria + Criteria *[]FilterClause `json:"criteria,omitempty"` + // Markers. Will be missing/null if there are no markers. + Markers *[]Marker `json:"markers,omitempty"` + // Team backlog mappings + TeamBacklogMappings *[]TeamBacklogMapping `json:"teamBacklogMappings,omitempty"` +} + +// Object bag storing the set of permissions relevant to this plan +type FieldInfo struct { + // The additional field display name + DisplayName *string `json:"displayName,omitempty"` + // The additional field type + FieldType *FieldType `json:"fieldType,omitempty"` + // Indicates if the field definition is for an identity field. + IsIdentity *bool `json:"isIdentity,omitempty"` + // The additional field reference name + ReferenceName *string `json:"referenceName,omitempty"` +} + +// An abstracted reference to a field +type FieldReference struct { + // fieldRefName for the field + ReferenceName *string `json:"referenceName,omitempty"` + // Full http link to more information about the field + Url *string `json:"url,omitempty"` +} + +type FieldSetting struct { +} + +type FieldType string + +type fieldTypeValuesType struct { + String FieldType + PlainText FieldType + Integer FieldType + DateTime FieldType + TreePath FieldType + Boolean FieldType + Double FieldType +} + +var FieldTypeValues = fieldTypeValuesType{ + String: "string", + PlainText: "plainText", + Integer: "integer", + DateTime: "dateTime", + TreePath: "treePath", + Boolean: "boolean", + Double: "double", +} + +type FilterClause struct { + FieldName *string `json:"fieldName,omitempty"` + Index *int `json:"index,omitempty"` + LogicalOperator *string `json:"logicalOperator,omitempty"` + Operator *string `json:"operator,omitempty"` + Value *string `json:"value,omitempty"` +} + +type FilterGroup struct { + End *int `json:"end,omitempty"` + Level *int `json:"level,omitempty"` + Start *int `json:"start,omitempty"` +} + +// Enum for the various modes of identity picker +type IdentityDisplayFormat string + +type identityDisplayFormatValuesType struct { + AvatarOnly IdentityDisplayFormat + FullName IdentityDisplayFormat + AvatarAndFullName IdentityDisplayFormat +} + +var IdentityDisplayFormatValues = identityDisplayFormatValuesType{ + // Display avatar only + AvatarOnly: "avatarOnly", + // Display Full name only + FullName: "fullName", + // Display Avatar and Full name + AvatarAndFullName: "avatarAndFullName", +} + +// Represents work items in an iteration backlog +type IterationWorkItems struct { + // Collection of links relevant to resource + Links interface{} `json:"_links,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` + // Work item relations + WorkItemRelations *[]workitemtracking.WorkItemLink `json:"workItemRelations,omitempty"` +} + +// Client serialization contract for Delivery Timeline Markers. +type Marker struct { + // Color associated with the marker. + Color *string `json:"color,omitempty"` + // Where the marker should be displayed on the timeline. + Date *azuredevops.Time `json:"date,omitempty"` + // Label/title for the marker. + Label *string `json:"label,omitempty"` +} + +type Member struct { + DisplayName *string `json:"displayName,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + ImageUrl *string `json:"imageUrl,omitempty"` + UniqueName *string `json:"uniqueName,omitempty"` + Url *string `json:"url,omitempty"` +} + +type ParentChildWIMap struct { + ChildWorkItemIds *[]int `json:"childWorkItemIds,omitempty"` + Id *int `json:"id,omitempty"` + Title *string `json:"title,omitempty"` +} + +// Data contract for the plan definition +type Plan struct { + // Identity that created this plan. Defaults to null for records before upgrading to ScaledAgileViewComponent4. + CreatedByIdentity *webapi.IdentityRef `json:"createdByIdentity,omitempty"` + // Date when the plan was created + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Description of the plan + Description *string `json:"description,omitempty"` + // Id of the plan + Id *uuid.UUID `json:"id,omitempty"` + // Identity that last modified this plan. Defaults to null for records before upgrading to ScaledAgileViewComponent4. + ModifiedByIdentity *webapi.IdentityRef `json:"modifiedByIdentity,omitempty"` + // Date when the plan was last modified. Default to CreatedDate when the plan is first created. + ModifiedDate *azuredevops.Time `json:"modifiedDate,omitempty"` + // Name of the plan + Name *string `json:"name,omitempty"` + // The PlanPropertyCollection instance associated with the plan. These are dependent on the type of the plan. For example, DeliveryTimelineView, it would be of type DeliveryViewPropertyCollection. + Properties interface{} `json:"properties,omitempty"` + // Revision of the plan. Used to safeguard users from overwriting each other's changes. + Revision *int `json:"revision,omitempty"` + // Type of the plan + Type *PlanType `json:"type,omitempty"` + // The resource url to locate the plan via rest api + Url *string `json:"url,omitempty"` + // Bit flag indicating set of permissions a user has to the plan. + UserPermissions *PlanUserPermissions `json:"userPermissions,omitempty"` +} + +// Metadata about a plan definition that is stored in favorites service +type PlanMetadata struct { + // Identity of the creator of the plan + CreatedByIdentity *webapi.IdentityRef `json:"createdByIdentity,omitempty"` + // Description of plan + Description *string `json:"description,omitempty"` + // Last modified date of the plan + ModifiedDate *azuredevops.Time `json:"modifiedDate,omitempty"` + // Bit flag indicating set of permissions a user has to the plan. + UserPermissions *PlanUserPermissions `json:"userPermissions,omitempty"` +} + +// Enum for the various types of plans +type PlanType string + +type planTypeValuesType struct { + DeliveryTimelineView PlanType +} + +var PlanTypeValues = planTypeValuesType{ + DeliveryTimelineView: "deliveryTimelineView", +} + +// [Flags] Flag for permissions a user can have for this plan. +type PlanUserPermissions string + +type planUserPermissionsValuesType struct { + None PlanUserPermissions + View PlanUserPermissions + Edit PlanUserPermissions + Delete PlanUserPermissions + Manage PlanUserPermissions + AllPermissions PlanUserPermissions +} + +var PlanUserPermissionsValues = planUserPermissionsValuesType{ + // None + None: "none", + // Permission to view this plan. + View: "view", + // Permission to update this plan. + Edit: "edit", + // Permission to delete this plan. + Delete: "delete", + // Permission to manage this plan. + Manage: "manage", + // Full control permission for this plan. + AllPermissions: "allPermissions", +} + +// Base class for plan view data contracts. Anything common goes here. +type PlanViewData struct { + Id *uuid.UUID `json:"id,omitempty"` + Revision *int `json:"revision,omitempty"` +} + +// Represents a single pre-defined query. +type PredefinedQuery struct { + // Whether or not the query returned the complete set of data or if the data was truncated. + HasMore *bool `json:"hasMore,omitempty"` + // Id of the query + Id *string `json:"id,omitempty"` + // Localized name of the query + Name *string `json:"name,omitempty"` + // The results of the query. This will be a set of WorkItem objects with only the 'id' set. The client is responsible for paging in the data as needed. + Results *[]workitemtracking.WorkItem `json:"results,omitempty"` + // REST API Url to use to retrieve results for this query + Url *string `json:"url,omitempty"` + // Url to use to display a page in the browser with the results of this query + WebUrl *string `json:"webUrl,omitempty"` +} + +// Process Configurations for the project +type ProcessConfiguration struct { + // Details about bug work items + BugWorkItems *CategoryConfiguration `json:"bugWorkItems,omitempty"` + // Details about portfolio backlogs + PortfolioBacklogs *[]CategoryConfiguration `json:"portfolioBacklogs,omitempty"` + // Details of requirement backlog + RequirementBacklog *CategoryConfiguration `json:"requirementBacklog,omitempty"` + // Details of task backlog + TaskBacklog *CategoryConfiguration `json:"taskBacklog,omitempty"` + // Type fields for the process configuration + TypeFields *map[string]workitemtracking.WorkItemFieldReference `json:"typeFields,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Represents a reorder request for one or more work items. +type ReorderOperation struct { + // IDs of the work items to be reordered. Must be valid WorkItem Ids. + Ids *[]int `json:"ids,omitempty"` + // IterationPath for reorder operation. This is only used when we reorder from the Iteration Backlog + IterationPath *string `json:"iterationPath,omitempty"` + // ID of the work item that should be after the reordered items. Can use 0 to specify the end of the list. + NextId *int `json:"nextId,omitempty"` + // Parent ID for all of the work items involved in this operation. Can use 0 to indicate the items don't have a parent. + ParentId *int `json:"parentId,omitempty"` + // ID of the work item that should be before the reordered items. Can use 0 to specify the beginning of the list. + PreviousId *int `json:"previousId,omitempty"` +} + +// Represents a reorder result for a work item. +type ReorderResult struct { + // The ID of the work item that was reordered. + Id *int `json:"id,omitempty"` + // The updated order value of the work item that was reordered. + Order *float64 `json:"order,omitempty"` +} + +type Rule struct { + Clauses *[]FilterClause `json:"clauses,omitempty"` + Filter *string `json:"filter,omitempty"` + IsEnabled *string `json:"isEnabled,omitempty"` + Name *string `json:"name,omitempty"` + Settings *attribute `json:"settings,omitempty"` +} + +// Mapping of teams to the corresponding work item category +type TeamBacklogMapping struct { + CategoryReferenceName *string `json:"categoryReferenceName,omitempty"` + TeamId *uuid.UUID `json:"teamId,omitempty"` +} + +// Represents a single TeamFieldValue +type TeamFieldValue struct { + IncludeChildren *bool `json:"includeChildren,omitempty"` + Value *string `json:"value,omitempty"` +} + +// Essentially a collection of team field values +type TeamFieldValues struct { + // Collection of links relevant to resource + Links interface{} `json:"_links,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` + // The default team field value + DefaultValue *string `json:"defaultValue,omitempty"` + // Shallow ref to the field being used as a team field + Field *FieldReference `json:"field,omitempty"` + // Collection of all valid team field values + Values *[]TeamFieldValue `json:"values,omitempty"` +} + +// Expected data from PATCH +type TeamFieldValuesPatch struct { + DefaultValue *string `json:"defaultValue,omitempty"` + Values *[]TeamFieldValue `json:"values,omitempty"` +} + +type TeamIterationAttributes struct { + // Finish date of the iteration. Date-only, correct unadjusted at midnight in UTC. + FinishDate *azuredevops.Time `json:"finishDate,omitempty"` + // Start date of the iteration. Date-only, correct unadjusted at midnight in UTC. + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // Time frame of the iteration, such as past, current or future. + TimeFrame *TimeFrame `json:"timeFrame,omitempty"` +} + +// Represents capacity for a specific team member +type TeamMemberCapacity struct { + // Collection of links relevant to resource + Links interface{} `json:"_links,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` + // Collection of capacities associated with the team member + Activities *[]Activity `json:"activities,omitempty"` + // The days off associated with the team member + DaysOff *[]DateRange `json:"daysOff,omitempty"` + // Shallow Ref to the associated team member + TeamMember *Member `json:"teamMember,omitempty"` +} + +// Represents capacity for a specific team member +type TeamMemberCapacityIdentityRef struct { + // Collection of links relevant to resource + Links interface{} `json:"_links,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` + // Collection of capacities associated with the team member + Activities *[]Activity `json:"activities,omitempty"` + // The days off associated with the team member + DaysOff *[]DateRange `json:"daysOff,omitempty"` + // Identity ref of the associated team member + TeamMember *webapi.IdentityRef `json:"teamMember,omitempty"` +} + +// Data contract for TeamSettings +type TeamSetting struct { + // Collection of links relevant to resource + Links interface{} `json:"_links,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` + // Backlog Iteration + BacklogIteration *TeamSettingsIteration `json:"backlogIteration,omitempty"` + // Information about categories that are visible on the backlog. + BacklogVisibilities *map[string]bool `json:"backlogVisibilities,omitempty"` + // BugsBehavior (Off, AsTasks, AsRequirements, ...) + BugsBehavior *BugsBehavior `json:"bugsBehavior,omitempty"` + // Default Iteration, the iteration used when creating a new work item on the queries page. + DefaultIteration *TeamSettingsIteration `json:"defaultIteration,omitempty"` + // Default Iteration macro (if any) + DefaultIterationMacro *string `json:"defaultIterationMacro,omitempty"` + // Days that the team is working + WorkingDays *[]string `json:"workingDays,omitempty"` +} + +// Base class for TeamSettings data contracts. Anything common goes here. +type TeamSettingsDataContractBase struct { + // Collection of links relevant to resource + Links interface{} `json:"_links,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` +} + +type TeamSettingsDaysOff struct { + // Collection of links relevant to resource + Links interface{} `json:"_links,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` + DaysOff *[]DateRange `json:"daysOff,omitempty"` +} + +type TeamSettingsDaysOffPatch struct { + DaysOff *[]DateRange `json:"daysOff,omitempty"` +} + +// Represents a shallow ref for a single iteration. +type TeamSettingsIteration struct { + // Collection of links relevant to resource + Links interface{} `json:"_links,omitempty"` + // Full http link to the resource + Url *string `json:"url,omitempty"` + // Attributes of the iteration such as start and end date. + Attributes *TeamIterationAttributes `json:"attributes,omitempty"` + // Id of the iteration. + Id *uuid.UUID `json:"id,omitempty"` + // Name of the iteration. + Name *string `json:"name,omitempty"` + // Relative path of the iteration. + Path *string `json:"path,omitempty"` +} + +// Data contract for what we expect to receive when PATCH +type TeamSettingsPatch struct { + BacklogIteration *uuid.UUID `json:"backlogIteration,omitempty"` + BacklogVisibilities *map[string]bool `json:"backlogVisibilities,omitempty"` + BugsBehavior *BugsBehavior `json:"bugsBehavior,omitempty"` + DefaultIteration *uuid.UUID `json:"defaultIteration,omitempty"` + DefaultIterationMacro *string `json:"defaultIterationMacro,omitempty"` + WorkingDays *[]string `json:"workingDays,omitempty"` +} + +type TimeFrame string + +type timeFrameValuesType struct { + Past TimeFrame + Current TimeFrame + Future TimeFrame +} + +var TimeFrameValues = timeFrameValuesType{ + Past: "past", + Current: "current", + Future: "future", +} + +type TimelineCriteriaStatus struct { + Message *string `json:"message,omitempty"` + Type *TimelineCriteriaStatusCode `json:"type,omitempty"` +} + +type TimelineCriteriaStatusCode string + +type timelineCriteriaStatusCodeValuesType struct { + Ok TimelineCriteriaStatusCode + InvalidFilterClause TimelineCriteriaStatusCode + Unknown TimelineCriteriaStatusCode +} + +var TimelineCriteriaStatusCodeValues = timelineCriteriaStatusCodeValuesType{ + // No error - filter is good. + Ok: "ok", + // One of the filter clause is invalid. + InvalidFilterClause: "invalidFilterClause", + // Unknown error. + Unknown: "unknown", +} + +type TimelineIterationStatus struct { + Message *string `json:"message,omitempty"` + Type *TimelineIterationStatusCode `json:"type,omitempty"` +} + +type TimelineIterationStatusCode string + +type timelineIterationStatusCodeValuesType struct { + Ok TimelineIterationStatusCode + IsOverlapping TimelineIterationStatusCode +} + +var TimelineIterationStatusCodeValues = timelineIterationStatusCodeValuesType{ + // No error - iteration data is good. + Ok: "ok", + // This iteration overlaps with another iteration, no data is returned for this iteration. + IsOverlapping: "isOverlapping", +} + +type TimelineTeamData struct { + // Backlog matching the mapped backlog associated with this team. + Backlog *BacklogLevel `json:"backlog,omitempty"` + // The field reference names of the work item data + FieldReferenceNames *[]string `json:"fieldReferenceNames,omitempty"` + // The id of the team + Id *uuid.UUID `json:"id,omitempty"` + // Was iteration and work item data retrieved for this team. Teams with IsExpanded false have not had their iteration, work item, and field related data queried and will never contain this data. If true then these items are queried and, if there are items in the queried range, there will be data. + IsExpanded *bool `json:"isExpanded,omitempty"` + // The iteration data, including the work items, in the queried date range. + Iterations *[]TimelineTeamIteration `json:"iterations,omitempty"` + // The name of the team + Name *string `json:"name,omitempty"` + // The order by field name of this team + OrderByField *string `json:"orderByField,omitempty"` + // The field reference names of the partially paged work items, such as ID, WorkItemType + PartiallyPagedFieldReferenceNames *[]string `json:"partiallyPagedFieldReferenceNames,omitempty"` + // The project id the team belongs team + ProjectId *uuid.UUID `json:"projectId,omitempty"` + // Status for this team. + Status *TimelineTeamStatus `json:"status,omitempty"` + // The team field default value + TeamFieldDefaultValue *string `json:"teamFieldDefaultValue,omitempty"` + // The team field name of this team + TeamFieldName *string `json:"teamFieldName,omitempty"` + // The team field values + TeamFieldValues *[]TeamFieldValue `json:"teamFieldValues,omitempty"` + // Colors for the work item types. + WorkItemTypeColors *[]WorkItemColor `json:"workItemTypeColors,omitempty"` +} + +type TimelineTeamIteration struct { + // The iteration CSS Node Id + CssNodeId *string `json:"cssNodeId,omitempty"` + // The end date of the iteration + FinishDate *azuredevops.Time `json:"finishDate,omitempty"` + // The iteration name + Name *string `json:"name,omitempty"` + // All the partially paged workitems in this iteration. + PartiallyPagedWorkItems *[][]interface{} `json:"partiallyPagedWorkItems,omitempty"` + // The iteration path + Path *string `json:"path,omitempty"` + // The start date of the iteration + StartDate *azuredevops.Time `json:"startDate,omitempty"` + // The status of this iteration + Status *TimelineIterationStatus `json:"status,omitempty"` + // The work items that have been paged in this iteration + WorkItems *[][]interface{} `json:"workItems,omitempty"` +} + +type TimelineTeamStatus struct { + Message *string `json:"message,omitempty"` + Type *TimelineTeamStatusCode `json:"type,omitempty"` +} + +type TimelineTeamStatusCode string + +type timelineTeamStatusCodeValuesType struct { + Ok TimelineTeamStatusCode + DoesntExistOrAccessDenied TimelineTeamStatusCode + MaxTeamsExceeded TimelineTeamStatusCode + MaxTeamFieldsExceeded TimelineTeamStatusCode + BacklogInError TimelineTeamStatusCode + MissingTeamFieldValue TimelineTeamStatusCode + NoIterationsExist TimelineTeamStatusCode +} + +var TimelineTeamStatusCodeValues = timelineTeamStatusCodeValuesType{ + // No error - all data for team is good. + Ok: "ok", + // Team does not exist or access is denied. + DoesntExistOrAccessDenied: "doesntExistOrAccessDenied", + // Maximum number of teams was exceeded. No team data will be returned for this team. + MaxTeamsExceeded: "maxTeamsExceeded", + // Maximum number of team fields (ie Area paths) have been exceeded. No team data will be returned for this team. + MaxTeamFieldsExceeded: "maxTeamFieldsExceeded", + // Backlog does not exist or is missing crucial information. + BacklogInError: "backlogInError", + // Team field value is not set for this team. No team data will be returned for this team + MissingTeamFieldValue: "missingTeamFieldValue", + // Team does not have a single iteration with date range. + NoIterationsExist: "noIterationsExist", +} + +type UpdatePlan struct { + // Description of the plan + Description *string `json:"description,omitempty"` + // Name of the plan to create. + Name *string `json:"name,omitempty"` + // Plan properties. + Properties interface{} `json:"properties,omitempty"` + // Revision of the plan that was updated - the value used here should match the one the server gave the client in the Plan. + Revision *int `json:"revision,omitempty"` + // Type of the plan + Type *PlanType `json:"type,omitempty"` +} + +// Work item color and icon. +type WorkItemColor struct { + Icon *string `json:"icon,omitempty"` + PrimaryColor *string `json:"primaryColor,omitempty"` + WorkItemTypeName *string `json:"workItemTypeName,omitempty"` +} + +type WorkItemTypeStateInfo struct { + // State name to state category map + States *map[string]string `json:"states,omitempty"` + // Work Item type name + WorkItemTypeName *string `json:"workItemTypeName,omitempty"` +} diff --git a/azuredevops/workitemtracking/client.go b/azuredevops/workitemtracking/client.go new file mode 100644 index 00000000..f15b0e03 --- /dev/null +++ b/azuredevops/workitemtracking/client.go @@ -0,0 +1,3215 @@ +// -------------------------------------------------------------------------------------------- +// 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 workitemtracking + +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/webapi" + "io" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("5264459e-e5e0-4bd8-b118-0985e68a4ec5") + +type Client interface { + // [Preview API] Add a comment on a work item. + AddComment(context.Context, AddCommentArgs) (*Comment, error) + // Uploads an attachment. + CreateAttachment(context.Context, CreateAttachmentArgs) (*AttachmentReference, error) + // [Preview API] Adds a new reaction to a comment. + CreateCommentReaction(context.Context, CreateCommentReactionArgs) (*CommentReaction, error) + // Create a new field. + CreateField(context.Context, CreateFieldArgs) (*WorkItemField, error) + // Create new or update an existing classification node. + CreateOrUpdateClassificationNode(context.Context, CreateOrUpdateClassificationNodeArgs) (*WorkItemClassificationNode, error) + // Creates a query, or moves a query. + CreateQuery(context.Context, CreateQueryArgs) (*QueryHierarchyItem, error) + // [Preview API] Creates a template + CreateTemplate(context.Context, CreateTemplateArgs) (*WorkItemTemplate, error) + // Creates a single work item. + CreateWorkItem(context.Context, CreateWorkItemArgs) (*WorkItem, error) + // Delete an existing classification node. + DeleteClassificationNode(context.Context, DeleteClassificationNodeArgs) error + // [Preview API] Delete a comment on a work item. + DeleteComment(context.Context, DeleteCommentArgs) error + // [Preview API] Deletes an existing reaction on a comment. + DeleteCommentReaction(context.Context, DeleteCommentReactionArgs) (*CommentReaction, error) + // Deletes the field. + DeleteField(context.Context, DeleteFieldArgs) error + // Delete a query or a folder. This deletes any permission change on the deleted query or folder and any of its descendants if it is a folder. It is important to note that the deleted permission changes cannot be recovered upon undeleting the query or folder. + DeleteQuery(context.Context, DeleteQueryArgs) error + // [Preview API] Deletes the template with given id + DeleteTemplate(context.Context, DeleteTemplateArgs) error + // Deletes the specified work item and sends it to the Recycle Bin, so that it can be restored back, if required. Optionally, if the destroy parameter has been set to true, it destroys the work item permanently. WARNING: If the destroy parameter is set to true, work items deleted by this command will NOT go to recycle-bin and there is no way to restore/recover them after deletion. It is recommended NOT to use this parameter. If you do, please use this parameter with extreme caution. + DeleteWorkItem(context.Context, DeleteWorkItemArgs) (*WorkItemDelete, error) + // Destroys the specified work item permanently from the Recycle Bin. This action can not be undone. + DestroyWorkItem(context.Context, DestroyWorkItemArgs) error + // Downloads an attachment. + GetAttachmentContent(context.Context, GetAttachmentContentArgs) (io.ReadCloser, error) + // Downloads an attachment. + GetAttachmentZip(context.Context, GetAttachmentZipArgs) (io.ReadCloser, error) + // Gets the classification node for a given node path. + GetClassificationNode(context.Context, GetClassificationNodeArgs) (*WorkItemClassificationNode, error) + // Gets root classification nodes or list of classification nodes for a given list of nodes ids, for a given project. In case ids parameter is supplied you will get list of classification nodes for those ids. Otherwise you will get root classification nodes for this project. + GetClassificationNodes(context.Context, GetClassificationNodesArgs) (*[]WorkItemClassificationNode, error) + // [Preview API] Returns a work item comment. + GetComment(context.Context, GetCommentArgs) (*Comment, error) + // [Preview API] Gets reactions of a comment. + GetCommentReactions(context.Context, GetCommentReactionsArgs) (*[]CommentReaction, error) + // [Preview API] Returns a list of work item comments, pageable. + GetComments(context.Context, GetCommentsArgs) (*CommentList, error) + // [Preview API] Returns a list of work item comments by ids. + GetCommentsBatch(context.Context, GetCommentsBatchArgs) (*CommentList, error) + // [Preview API] + GetCommentVersion(context.Context, GetCommentVersionArgs) (*CommentVersion, error) + // [Preview API] + GetCommentVersions(context.Context, GetCommentVersionsArgs) (*[]CommentVersion, error) + // Gets a deleted work item from Recycle Bin. + GetDeletedWorkItem(context.Context, GetDeletedWorkItemArgs) (*WorkItemDelete, error) + // Gets the work items from the recycle bin, whose IDs have been specified in the parameters + GetDeletedWorkItems(context.Context, GetDeletedWorkItemsArgs) (*[]WorkItemDeleteReference, error) + // Gets a list of the IDs and the URLs of the deleted the work items in the Recycle Bin. + GetDeletedWorkItemShallowReferences(context.Context, GetDeletedWorkItemShallowReferencesArgs) (*[]WorkItemDeleteShallowReference, error) + // [Preview API] Get users who reacted on the comment. + GetEngagedUsers(context.Context, GetEngagedUsersArgs) (*[]webapi.IdentityRef, error) + // Gets information on a specific field. + GetField(context.Context, GetFieldArgs) (*WorkItemField, error) + // Returns information for all fields. + GetFields(context.Context, GetFieldsArgs) (*[]WorkItemField, error) + // Gets the root queries and their children + GetQueries(context.Context, GetQueriesArgs) (*[]QueryHierarchyItem, error) + // Gets a list of queries by ids (Maximum 1000) + GetQueriesBatch(context.Context, GetQueriesBatchArgs) (*[]QueryHierarchyItem, error) + // Retrieves an individual query and its children + GetQuery(context.Context, GetQueryArgs) (*QueryHierarchyItem, error) + // Gets the results of the query given the query ID. + GetQueryResultCount(context.Context, GetQueryResultCountArgs) (*int, error) + // [Preview API] Gets recent work item activities + GetRecentActivityData(context.Context, GetRecentActivityDataArgs) (*[]AccountRecentActivityWorkItemModel2, error) + // Gets the work item relation type definition. + GetRelationType(context.Context, GetRelationTypeArgs) (*WorkItemRelationType, error) + // Gets the work item relation types. + GetRelationTypes(context.Context, GetRelationTypesArgs) (*[]WorkItemRelationType, error) + // Get a batch of work item links + GetReportingLinksByLinkType(context.Context, GetReportingLinksByLinkTypeArgs) (*ReportingWorkItemLinksBatch, error) + // Returns a fully hydrated work item for the requested revision + GetRevision(context.Context, GetRevisionArgs) (*WorkItem, error) + // Returns the list of fully hydrated work item revisions, paged. + GetRevisions(context.Context, GetRevisionsArgs) (*[]WorkItem, error) + // Gets root classification nodes under the project. + GetRootNodes(context.Context, GetRootNodesArgs) (*[]WorkItemClassificationNode, error) + // [Preview API] Gets the template with specified id + GetTemplate(context.Context, GetTemplateArgs) (*WorkItemTemplate, error) + // [Preview API] Gets template + GetTemplates(context.Context, GetTemplatesArgs) (*[]WorkItemTemplateReference, error) + // Returns a single update for a work item + GetUpdate(context.Context, GetUpdateArgs) (*WorkItemUpdate, error) + // Returns a the deltas between work item revisions + GetUpdates(context.Context, GetUpdatesArgs) (*[]WorkItemUpdate, error) + // [Preview API] Get the list of work item tracking outbound artifact link types. + GetWorkArtifactLinkTypes(context.Context, GetWorkArtifactLinkTypesArgs) (*[]WorkArtifactLink, error) + // Returns a single work item. + GetWorkItem(context.Context, GetWorkItemArgs) (*WorkItem, error) + // Get a work item icon given the friendly name and icon color. + GetWorkItemIconJson(context.Context, GetWorkItemIconJsonArgs) (*WorkItemIcon, error) + // Get a list of all work item icons. + GetWorkItemIcons(context.Context, GetWorkItemIconsArgs) (*[]WorkItemIcon, error) + // Get a work item icon given the friendly name and icon color. + GetWorkItemIconSvg(context.Context, GetWorkItemIconSvgArgs) (io.ReadCloser, error) + // Get a work item icon given the friendly name and icon color. + GetWorkItemIconXaml(context.Context, GetWorkItemIconXamlArgs) (io.ReadCloser, error) + // [Preview API] Returns the next state on the given work item IDs. + GetWorkItemNextStatesOnCheckinAction(context.Context, GetWorkItemNextStatesOnCheckinActionArgs) (*[]WorkItemNextStateOnTransition, error) + // Returns a list of work items (Maximum 200) + GetWorkItems(context.Context, GetWorkItemsArgs) (*[]WorkItem, error) + // Gets work items for a list of work item ids (Maximum 200) + GetWorkItemsBatch(context.Context, GetWorkItemsBatchArgs) (*[]WorkItem, error) + // Returns a single work item from a template. + GetWorkItemTemplate(context.Context, GetWorkItemTemplateArgs) (*WorkItem, error) + // Returns a work item type definition. + GetWorkItemType(context.Context, GetWorkItemTypeArgs) (*WorkItemType, error) + // Get all work item type categories. + GetWorkItemTypeCategories(context.Context, GetWorkItemTypeCategoriesArgs) (*[]WorkItemTypeCategory, error) + // Get specific work item type category by name. + GetWorkItemTypeCategory(context.Context, GetWorkItemTypeCategoryArgs) (*WorkItemTypeCategory, error) + // Get a list of fields for a work item type with detailed references. + GetWorkItemTypeFieldsWithReferences(context.Context, GetWorkItemTypeFieldsWithReferencesArgs) (*[]WorkItemTypeFieldWithReferences, error) + // Get a field for a work item type with detailed references. + GetWorkItemTypeFieldWithReferences(context.Context, GetWorkItemTypeFieldWithReferencesArgs) (*WorkItemTypeFieldWithReferences, error) + // Returns the list of work item types + GetWorkItemTypes(context.Context, GetWorkItemTypesArgs) (*[]WorkItemType, error) + // [Preview API] Returns the state names and colors for a work item type. + GetWorkItemTypeStates(context.Context, GetWorkItemTypeStatesArgs) (*[]WorkItemStateColor, error) + // Gets the results of the query given the query ID. + QueryById(context.Context, QueryByIdArgs) (*WorkItemQueryResult, error) + // Gets the results of the query given its WIQL. + QueryByWiql(context.Context, QueryByWiqlArgs) (*WorkItemQueryResult, error) + // [Preview API] Queries work items linked to a given list of artifact URI. + QueryWorkItemsForArtifactUris(context.Context, QueryWorkItemsForArtifactUrisArgs) (*ArtifactUriQueryResult, error) + // [Preview API] + ReadReportingDiscussions(context.Context, ReadReportingDiscussionsArgs) (*ReportingWorkItemRevisionsBatch, error) + // Get a batch of work item revisions with the option of including deleted items + ReadReportingRevisionsGet(context.Context, ReadReportingRevisionsGetArgs) (*ReportingWorkItemRevisionsBatch, error) + // Get a batch of work item revisions. This request may be used if your list of fields is large enough that it may run the URL over the length limit. + ReadReportingRevisionsPost(context.Context, ReadReportingRevisionsPostArgs) (*ReportingWorkItemRevisionsBatch, error) + // [Preview API] Replace template contents + ReplaceTemplate(context.Context, ReplaceTemplateArgs) (*WorkItemTemplate, error) + // Restores the deleted work item from Recycle Bin. + RestoreWorkItem(context.Context, RestoreWorkItemArgs) (*WorkItemDelete, error) + // Searches all queries the user has access to in the current project + SearchQueries(context.Context, SearchQueriesArgs) (*QueryHierarchyItemsResult, error) + // Update an existing classification node. + UpdateClassificationNode(context.Context, UpdateClassificationNodeArgs) (*WorkItemClassificationNode, error) + // [Preview API] Update a comment on a work item. + UpdateComment(context.Context, UpdateCommentArgs) (*Comment, error) + // Update a query or a folder. This allows you to update, rename and move queries and folders. + UpdateQuery(context.Context, UpdateQueryArgs) (*QueryHierarchyItem, error) + // Updates a single work item. + UpdateWorkItem(context.Context, UpdateWorkItemArgs) (*WorkItem, 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] Add a comment on a work item. +func (client *ClientImpl) AddComment(ctx context.Context, args AddCommentArgs) (*Comment, error) { + if args.Request == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Request"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + + body, marshalErr := json.Marshal(*args.Request) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("608aac0a-32e1-4493-a863-b9cf4566d257") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.3", 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 AddComment function +type AddCommentArgs struct { + // (required) Comment create request. + Request *CommentCreate + // (required) Project ID or project name + Project *string + // (required) Id of a work item. + WorkItemId *int +} + +// Uploads an attachment. +func (client *ClientImpl) CreateAttachment(ctx context.Context, args CreateAttachmentArgs) (*AttachmentReference, 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 + } + + queryParams := url.Values{} + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + if args.UploadType != nil { + queryParams.Add("uploadType", *args.UploadType) + } + if args.AreaPath != nil { + queryParams.Add("areaPath", *args.AreaPath) + } + locationId, _ := uuid.Parse("e07b5fa4-1499-494d-a496-64b860fd64ff") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, queryParams, args.UploadStream, "application/octet-stream", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue AttachmentReference + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateAttachment function +type CreateAttachmentArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (optional) Project ID or project name + Project *string + // (optional) The name of the file + FileName *string + // (optional) Attachment upload type: Simple or Chunked + UploadType *string + // (optional) Target project Area Path + AreaPath *string +} + +// [Preview API] Adds a new reaction to a comment. +func (client *ClientImpl) CreateCommentReaction(ctx context.Context, args CreateCommentReactionArgs) (*CommentReaction, 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.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + if args.CommentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + if args.ReactionType == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReactionType"} + } + routeValues["reactionType"] = string(*args.ReactionType) + + locationId, _ := uuid.Parse("f6cb3f27-1028-4851-af96-887e570dc21f") + 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 CommentReaction + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateCommentReaction function +type CreateCommentReactionArgs struct { + // (required) Project ID or project name + Project *string + // (required) WorkItem ID + WorkItemId *int + // (required) Comment ID + CommentId *int + // (required) Type of the reaction + ReactionType *CommentReactionType +} + +// Create a new field. +func (client *ClientImpl) CreateField(ctx context.Context, args CreateFieldArgs) (*WorkItemField, error) { + if args.WorkItemField == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemField"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.WorkItemField) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94") + 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 WorkItemField + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateField function +type CreateFieldArgs struct { + // (required) New field definition + WorkItemField *WorkItemField + // (optional) Project ID or project name + Project *string +} + +// Create new or update an existing classification node. +func (client *ClientImpl) CreateOrUpdateClassificationNode(ctx context.Context, args CreateOrUpdateClassificationNodeArgs) (*WorkItemClassificationNode, error) { + if args.PostedNode == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PostedNode"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.StructureGroup == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.StructureGroup"} + } + routeValues["structureGroup"] = string(*args.StructureGroup) + if args.Path != nil && *args.Path != "" { + routeValues["path"] = *args.Path + } + + body, marshalErr := json.Marshal(*args.PostedNode) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("5a172953-1b41-49d3-840a-33f79c3ce89f") + 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 WorkItemClassificationNode + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateOrUpdateClassificationNode function +type CreateOrUpdateClassificationNodeArgs struct { + // (required) Node to create or update. + PostedNode *WorkItemClassificationNode + // (required) Project ID or project name + Project *string + // (required) Structure group of the classification node, area or iteration. + StructureGroup *TreeStructureGroup + // (optional) Path of the classification node. + Path *string +} + +// Creates a query, or moves a query. +func (client *ClientImpl) CreateQuery(ctx context.Context, args CreateQueryArgs) (*QueryHierarchyItem, error) { + if args.PostedQuery == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PostedQuery"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Query == nil || *args.Query == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Query"} + } + routeValues["query"] = *args.Query + + queryParams := url.Values{} + if args.ValidateWiqlOnly != nil { + queryParams.Add("validateWiqlOnly", strconv.FormatBool(*args.ValidateWiqlOnly)) + } + body, marshalErr := json.Marshal(*args.PostedQuery) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a67d190c-c41f-424b-814d-0e906f659301") + 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 QueryHierarchyItem + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateQuery function +type CreateQueryArgs struct { + // (required) The query to create. + PostedQuery *QueryHierarchyItem + // (required) Project ID or project name + Project *string + // (required) The parent id or path under which the query is to be created. + Query *string + // (optional) If you only want to validate your WIQL query without actually creating one, set it to true. Default is false. + ValidateWiqlOnly *bool +} + +// [Preview API] Creates a template +func (client *ClientImpl) CreateTemplate(ctx context.Context, args CreateTemplateArgs) (*WorkItemTemplate, error) { + if args.Template == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Template"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team == nil || *args.Team == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + + body, marshalErr := json.Marshal(*args.Template) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("6a90345f-a676-4969-afce-8e163e1d5642") + 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 WorkItemTemplate + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateTemplate function +type CreateTemplateArgs struct { + // (required) Template contents + Template *WorkItemTemplate + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string +} + +// Creates a single work item. +func (client *ClientImpl) CreateWorkItem(ctx context.Context, args CreateWorkItemArgs) (*WorkItem, error) { + if args.Document == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Document"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + + queryParams := url.Values{} + if args.ValidateOnly != nil { + queryParams.Add("validateOnly", strconv.FormatBool(*args.ValidateOnly)) + } + if args.BypassRules != nil { + queryParams.Add("bypassRules", strconv.FormatBool(*args.BypassRules)) + } + if args.SuppressNotifications != nil { + queryParams.Add("suppressNotifications", strconv.FormatBool(*args.SuppressNotifications)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + body, marshalErr := json.Marshal(*args.Document) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("62d3d110-0047-428c-ad3c-4fe872c91c74") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, queryParams, bytes.NewReader(body), "application/json-patch+json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue WorkItem + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateWorkItem function +type CreateWorkItemArgs struct { + // (required) The JSON Patch document representing the work item + Document *[]webapi.JsonPatchOperation + // (required) Project ID or project name + Project *string + // (required) The work item type of the work item to create + Type *string + // (optional) Indicate if you only want to validate the changes without saving the work item + ValidateOnly *bool + // (optional) Do not enforce the work item type rules on this update + BypassRules *bool + // (optional) Do not fire any notifications for this change + SuppressNotifications *bool + // (optional) The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }. + Expand *WorkItemExpand +} + +// Delete an existing classification node. +func (client *ClientImpl) DeleteClassificationNode(ctx context.Context, args DeleteClassificationNodeArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.StructureGroup == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.StructureGroup"} + } + routeValues["structureGroup"] = string(*args.StructureGroup) + if args.Path != nil && *args.Path != "" { + routeValues["path"] = *args.Path + } + + queryParams := url.Values{} + if args.ReclassifyId != nil { + queryParams.Add("$reclassifyId", strconv.Itoa(*args.ReclassifyId)) + } + locationId, _ := uuid.Parse("5a172953-1b41-49d3-840a-33f79c3ce89f") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteClassificationNode function +type DeleteClassificationNodeArgs struct { + // (required) Project ID or project name + Project *string + // (required) Structure group of the classification node, area or iteration. + StructureGroup *TreeStructureGroup + // (optional) Path of the classification node. + Path *string + // (optional) Id of the target classification node for reclassification. + ReclassifyId *int +} + +// [Preview API] Delete a comment on a work item. +func (client *ClientImpl) DeleteComment(ctx context.Context, args DeleteCommentArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.WorkItemId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + if args.CommentId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + + locationId, _ := uuid.Parse("608aac0a-32e1-4493-a863-b9cf4566d257") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.3", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteComment function +type DeleteCommentArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of a work item. + WorkItemId *int + // (required) + CommentId *int +} + +// [Preview API] Deletes an existing reaction on a comment. +func (client *ClientImpl) DeleteCommentReaction(ctx context.Context, args DeleteCommentReactionArgs) (*CommentReaction, 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.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + if args.CommentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + if args.ReactionType == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReactionType"} + } + routeValues["reactionType"] = string(*args.ReactionType) + + locationId, _ := uuid.Parse("f6cb3f27-1028-4851-af96-887e570dc21f") + 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 CommentReaction + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the DeleteCommentReaction function +type DeleteCommentReactionArgs struct { + // (required) Project ID or project name + Project *string + // (required) WorkItem ID + WorkItemId *int + // (required) Comment ID + CommentId *int + // (required) Type of the reaction + ReactionType *CommentReactionType +} + +// Deletes the field. +func (client *ClientImpl) DeleteField(ctx context.Context, args DeleteFieldArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FieldNameOrRefName == nil || *args.FieldNameOrRefName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FieldNameOrRefName"} + } + routeValues["fieldNameOrRefName"] = *args.FieldNameOrRefName + + locationId, _ := uuid.Parse("b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94") + _, 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 DeleteField function +type DeleteFieldArgs struct { + // (required) Field simple name or reference name + FieldNameOrRefName *string + // (optional) Project ID or project name + Project *string +} + +// Delete a query or a folder. This deletes any permission change on the deleted query or folder and any of its descendants if it is a folder. It is important to note that the deleted permission changes cannot be recovered upon undeleting the query or folder. +func (client *ClientImpl) DeleteQuery(ctx context.Context, args DeleteQueryArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Query == nil || *args.Query == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Query"} + } + routeValues["query"] = *args.Query + + locationId, _ := uuid.Parse("a67d190c-c41f-424b-814d-0e906f659301") + _, 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 DeleteQuery function +type DeleteQueryArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID or path of the query or folder to delete. + Query *string +} + +// [Preview API] Deletes the template with given id +func (client *ClientImpl) DeleteTemplate(ctx context.Context, args DeleteTemplateArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team == nil || *args.Team == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + if args.TemplateId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.TemplateId"} + } + routeValues["templateId"] = (*args.TemplateId).String() + + locationId, _ := uuid.Parse("fb10264a-8836-48a0-8033-1b0ccd2748d5") + _, 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 DeleteTemplate function +type DeleteTemplateArgs struct { + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string + // (required) Template id + TemplateId *uuid.UUID +} + +// Deletes the specified work item and sends it to the Recycle Bin, so that it can be restored back, if required. Optionally, if the destroy parameter has been set to true, it destroys the work item permanently. WARNING: If the destroy parameter is set to true, work items deleted by this command will NOT go to recycle-bin and there is no way to restore/recover them after deletion. It is recommended NOT to use this parameter. If you do, please use this parameter with extreme caution. +func (client *ClientImpl) DeleteWorkItem(ctx context.Context, args DeleteWorkItemArgs) (*WorkItemDelete, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + queryParams := url.Values{} + if args.Destroy != nil { + queryParams.Add("destroy", strconv.FormatBool(*args.Destroy)) + } + locationId, _ := uuid.Parse("72c7ddf8-2cdc-4f60-90cd-ab71c14a399b") + resp, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue WorkItemDelete + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the DeleteWorkItem function +type DeleteWorkItemArgs struct { + // (required) ID of the work item to be deleted + Id *int + // (optional) Project ID or project name + Project *string + // (optional) Optional parameter, if set to true, the work item is deleted permanently. Please note: the destroy action is PERMANENT and cannot be undone. + Destroy *bool +} + +// Destroys the specified work item permanently from the Recycle Bin. This action can not be undone. +func (client *ClientImpl) DestroyWorkItem(ctx context.Context, args DestroyWorkItemArgs) error { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Id == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + locationId, _ := uuid.Parse("b70d8d39-926c-465e-b927-b1bf0e5ca0e0") + _, 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 DestroyWorkItem function +type DestroyWorkItemArgs struct { + // (required) ID of the work item to be destroyed permanently + Id *int + // (optional) Project ID or project name + Project *string +} + +// Downloads an 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.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = (*args.Id).String() + + queryParams := url.Values{} + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + locationId, _ := uuid.Parse("e07b5fa4-1499-494d-a496-64b860fd64ff") + 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 GetAttachmentContent function +type GetAttachmentContentArgs struct { + // (required) Attachment ID + Id *uuid.UUID + // (optional) Project ID or project name + Project *string + // (optional) Name of the file + FileName *string + // (optional) If set to true always download attachment + Download *bool +} + +// Downloads an 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.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = (*args.Id).String() + + queryParams := url.Values{} + if args.FileName != nil { + queryParams.Add("fileName", *args.FileName) + } + if args.Download != nil { + queryParams.Add("download", strconv.FormatBool(*args.Download)) + } + locationId, _ := uuid.Parse("e07b5fa4-1499-494d-a496-64b860fd64ff") + 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 GetAttachmentZip function +type GetAttachmentZipArgs struct { + // (required) Attachment ID + Id *uuid.UUID + // (optional) Project ID or project name + Project *string + // (optional) Name of the file + FileName *string + // (optional) If set to true always download attachment + Download *bool +} + +// Gets the classification node for a given node path. +func (client *ClientImpl) GetClassificationNode(ctx context.Context, args GetClassificationNodeArgs) (*WorkItemClassificationNode, 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.StructureGroup == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.StructureGroup"} + } + routeValues["structureGroup"] = string(*args.StructureGroup) + if args.Path != nil && *args.Path != "" { + routeValues["path"] = *args.Path + } + + queryParams := url.Values{} + if args.Depth != nil { + queryParams.Add("$depth", strconv.Itoa(*args.Depth)) + } + locationId, _ := uuid.Parse("5a172953-1b41-49d3-840a-33f79c3ce89f") + 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 WorkItemClassificationNode + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetClassificationNode function +type GetClassificationNodeArgs struct { + // (required) Project ID or project name + Project *string + // (required) Structure group of the classification node, area or iteration. + StructureGroup *TreeStructureGroup + // (optional) Path of the classification node. + Path *string + // (optional) Depth of children to fetch. + Depth *int +} + +// Gets root classification nodes or list of classification nodes for a given list of nodes ids, for a given project. In case ids parameter is supplied you will get list of classification nodes for those ids. Otherwise you will get root classification nodes for this project. +func (client *ClientImpl) GetClassificationNodes(ctx context.Context, args GetClassificationNodesArgs) (*[]WorkItemClassificationNode, 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.Ids == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "ids"} + } + var stringList []string + for _, item := range *args.Ids { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("ids", listAsString) + if args.Depth != nil { + queryParams.Add("$depth", strconv.Itoa(*args.Depth)) + } + if args.ErrorPolicy != nil { + queryParams.Add("errorPolicy", string(*args.ErrorPolicy)) + } + locationId, _ := uuid.Parse("a70579d1-f53a-48ee-a5be-7be8659023b9") + 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 []WorkItemClassificationNode + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetClassificationNodes function +type GetClassificationNodesArgs struct { + // (required) Project ID or project name + Project *string + // (required) Comma separated integer classification nodes ids. It's not required, if you want root nodes. + Ids *[]int + // (optional) Depth of children to fetch. + Depth *int + // (optional) Flag to handle errors in getting some nodes. Possible options are Fail and Omit. + ErrorPolicy *ClassificationNodesErrorPolicy +} + +// [Preview API] Returns a work item comment. +func (client *ClientImpl) GetComment(ctx context.Context, args GetCommentArgs) (*Comment, 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.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + if args.CommentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + + queryParams := url.Values{} + if args.IncludeDeleted != nil { + queryParams.Add("includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("608aac0a-32e1-4493-a863-b9cf4566d257") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.3", routeValues, queryParams, 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) Project ID or project name + Project *string + // (required) Id of a work item to get the comment. + WorkItemId *int + // (required) Id of the comment to return. + CommentId *int + // (optional) Specify if the deleted comment should be retrieved. + IncludeDeleted *bool + // (optional) Specifies the additional data retrieval options for work item comments. + Expand *CommentExpandOptions +} + +// [Preview API] Gets reactions of a comment. +func (client *ClientImpl) GetCommentReactions(ctx context.Context, args GetCommentReactionsArgs) (*[]CommentReaction, 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.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + if args.CommentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + + locationId, _ := uuid.Parse("f6cb3f27-1028-4851-af96-887e570dc21f") + 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 []CommentReaction + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCommentReactions function +type GetCommentReactionsArgs struct { + // (required) Project ID or project name + Project *string + // (required) WorkItem ID + WorkItemId *int + // (required) Comment ID + CommentId *int +} + +// [Preview API] Returns a list of work item comments, pageable. +func (client *ClientImpl) GetComments(ctx context.Context, args GetCommentsArgs) (*CommentList, 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.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + + queryParams := url.Values{} + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.IncludeDeleted != nil { + queryParams.Add("includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.Order != nil { + queryParams.Add("order", string(*args.Order)) + } + locationId, _ := uuid.Parse("608aac0a-32e1-4493-a863-b9cf4566d257") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.3", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue CommentList + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetComments function +type GetCommentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of a work item to get comments for. + WorkItemId *int + // (optional) Max number of comments to return. + Top *int + // (optional) Used to query for the next page of comments. + ContinuationToken *string + // (optional) Specify if the deleted comments should be retrieved. + IncludeDeleted *bool + // (optional) Specifies the additional data retrieval options for work item comments. + Expand *CommentExpandOptions + // (optional) Order in which the comments should be returned. + Order *CommentSortOrder +} + +// [Preview API] Returns a list of work item comments by ids. +func (client *ClientImpl) GetCommentsBatch(ctx context.Context, args GetCommentsBatchArgs) (*CommentList, 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.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + + queryParams := url.Values{} + if args.Ids == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "ids"} + } + var stringList []string + for _, item := range *args.Ids { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("ids", listAsString) + if args.IncludeDeleted != nil { + queryParams.Add("includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("608aac0a-32e1-4493-a863-b9cf4566d257") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.3", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue CommentList + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCommentsBatch function +type GetCommentsBatchArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of a work item to get comments for. + WorkItemId *int + // (required) Comma-separated list of comment ids to return. + Ids *[]int + // (optional) Specify if the deleted comments should be retrieved. + IncludeDeleted *bool + // (optional) Specifies the additional data retrieval options for work item comments. + Expand *CommentExpandOptions +} + +// [Preview API] +func (client *ClientImpl) GetCommentVersion(ctx context.Context, args GetCommentVersionArgs) (*CommentVersion, 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.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + if args.CommentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + if args.Version == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Version"} + } + routeValues["version"] = strconv.Itoa(*args.Version) + + locationId, _ := uuid.Parse("49e03b34-3be0-42e3-8a5d-e8dfb88ac954") + 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 CommentVersion + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCommentVersion function +type GetCommentVersionArgs struct { + // (required) Project ID or project name + Project *string + // (required) + WorkItemId *int + // (required) + CommentId *int + // (required) + Version *int +} + +// [Preview API] +func (client *ClientImpl) GetCommentVersions(ctx context.Context, args GetCommentVersionsArgs) (*[]CommentVersion, 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.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + if args.CommentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + + locationId, _ := uuid.Parse("49e03b34-3be0-42e3-8a5d-e8dfb88ac954") + 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 []CommentVersion + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetCommentVersions function +type GetCommentVersionsArgs struct { + // (required) Project ID or project name + Project *string + // (required) + WorkItemId *int + // (required) + CommentId *int +} + +// Gets a deleted work item from Recycle Bin. +func (client *ClientImpl) GetDeletedWorkItem(ctx context.Context, args GetDeletedWorkItemArgs) (*WorkItemDelete, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + locationId, _ := uuid.Parse("b70d8d39-926c-465e-b927-b1bf0e5ca0e0") + 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 WorkItemDelete + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDeletedWorkItem function +type GetDeletedWorkItemArgs struct { + // (required) ID of the work item to be returned + Id *int + // (optional) Project ID or project name + Project *string +} + +// Gets the work items from the recycle bin, whose IDs have been specified in the parameters +func (client *ClientImpl) GetDeletedWorkItems(ctx context.Context, args GetDeletedWorkItemsArgs) (*[]WorkItemDeleteReference, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.Ids == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "ids"} + } + var stringList []string + for _, item := range *args.Ids { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("ids", listAsString) + locationId, _ := uuid.Parse("b70d8d39-926c-465e-b927-b1bf0e5ca0e0") + 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 []WorkItemDeleteReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDeletedWorkItems function +type GetDeletedWorkItemsArgs struct { + // (required) Comma separated list of IDs of the deleted work items to be returned + Ids *[]int + // (optional) Project ID or project name + Project *string +} + +// Gets a list of the IDs and the URLs of the deleted the work items in the Recycle Bin. +func (client *ClientImpl) GetDeletedWorkItemShallowReferences(ctx context.Context, args GetDeletedWorkItemShallowReferencesArgs) (*[]WorkItemDeleteShallowReference, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + locationId, _ := uuid.Parse("b70d8d39-926c-465e-b927-b1bf0e5ca0e0") + 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 []WorkItemDeleteShallowReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetDeletedWorkItemShallowReferences function +type GetDeletedWorkItemShallowReferencesArgs struct { + // (optional) Project ID or project name + Project *string +} + +// [Preview API] Get users who reacted on the comment. +func (client *ClientImpl) GetEngagedUsers(ctx context.Context, args GetEngagedUsersArgs) (*[]webapi.IdentityRef, 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.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + if args.CommentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + if args.ReactionType == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReactionType"} + } + routeValues["reactionType"] = string(*args.ReactionType) + + 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("e33ca5e0-2349-4285-af3d-d72d86781c35") + 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 []webapi.IdentityRef + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetEngagedUsers function +type GetEngagedUsersArgs struct { + // (required) Project ID or project name + Project *string + // (required) WorkItem ID. + WorkItemId *int + // (required) Comment ID. + CommentId *int + // (required) Type of the reaction. + ReactionType *CommentReactionType + // (optional) + Top *int + // (optional) + Skip *int +} + +// Gets information on a specific field. +func (client *ClientImpl) GetField(ctx context.Context, args GetFieldArgs) (*WorkItemField, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.FieldNameOrRefName == nil || *args.FieldNameOrRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FieldNameOrRefName"} + } + routeValues["fieldNameOrRefName"] = *args.FieldNameOrRefName + + locationId, _ := uuid.Parse("b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94") + 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 WorkItemField + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetField function +type GetFieldArgs struct { + // (required) Field simple name or reference name + FieldNameOrRefName *string + // (optional) Project ID or project name + Project *string +} + +// Returns information for all fields. +func (client *ClientImpl) GetFields(ctx context.Context, args GetFieldsArgs) (*[]WorkItemField, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94") + 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 []WorkItemField + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFields function +type GetFieldsArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) Use ExtensionFields to include extension fields, otherwise exclude them. Unless the feature flag for this parameter is enabled, extension fields are always included. + Expand *GetFieldsExpand +} + +// Gets the root queries and their children +func (client *ClientImpl) GetQueries(ctx context.Context, args GetQueriesArgs) (*[]QueryHierarchyItem, 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.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.Depth != nil { + queryParams.Add("$depth", strconv.Itoa(*args.Depth)) + } + if args.IncludeDeleted != nil { + queryParams.Add("$includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + locationId, _ := uuid.Parse("a67d190c-c41f-424b-814d-0e906f659301") + 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 []QueryHierarchyItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetQueries function +type GetQueriesArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Include the query string (wiql), clauses, query result columns, and sort options in the results. + Expand *QueryExpand + // (optional) In the folder of queries, return child queries and folders to this depth. + Depth *int + // (optional) Include deleted queries and folders + IncludeDeleted *bool +} + +// Gets a list of queries by ids (Maximum 1000) +func (client *ClientImpl) GetQueriesBatch(ctx context.Context, args GetQueriesBatchArgs) (*[]QueryHierarchyItem, error) { + if args.QueryGetRequest == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.QueryGetRequest"} + } + 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.QueryGetRequest) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("549816f9-09b0-4e75-9e81-01fbfcd07426") + 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 []QueryHierarchyItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetQueriesBatch function +type GetQueriesBatchArgs struct { + // (required) + QueryGetRequest *QueryBatchGetRequest + // (required) Project ID or project name + Project *string +} + +// Retrieves an individual query and its children +func (client *ClientImpl) GetQuery(ctx context.Context, args GetQueryArgs) (*QueryHierarchyItem, 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.Query == nil || *args.Query == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Query"} + } + routeValues["query"] = *args.Query + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.Depth != nil { + queryParams.Add("$depth", strconv.Itoa(*args.Depth)) + } + if args.IncludeDeleted != nil { + queryParams.Add("$includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + locationId, _ := uuid.Parse("a67d190c-c41f-424b-814d-0e906f659301") + 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 QueryHierarchyItem + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetQuery function +type GetQueryArgs struct { + // (required) Project ID or project name + Project *string + // (required) ID or path of the query. + Query *string + // (optional) Include the query string (wiql), clauses, query result columns, and sort options in the results. + Expand *QueryExpand + // (optional) In the folder of queries, return child queries and folders to this depth. + Depth *int + // (optional) Include deleted queries and folders + IncludeDeleted *bool +} + +// Gets the results of the query given the query ID. +func (client *ClientImpl) GetQueryResultCount(ctx context.Context, args GetQueryResultCountArgs) (*int, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = (*args.Id).String() + + queryParams := url.Values{} + if args.TimePrecision != nil { + queryParams.Add("timePrecision", strconv.FormatBool(*args.TimePrecision)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + locationId, _ := uuid.Parse("a02355f5-5f8a-4671-8e32-369d23aac83d") + resp, err := client.Client.Send(ctx, http.MethodHead, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue int + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetQueryResultCount function +type GetQueryResultCountArgs struct { + // (required) The query ID. + Id *uuid.UUID + // (optional) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string + // (optional) Whether or not to use time precision. + TimePrecision *bool + // (optional) The max number of results to return. + Top *int +} + +// [Preview API] Gets recent work item activities +func (client *ClientImpl) GetRecentActivityData(ctx context.Context, args GetRecentActivityDataArgs) (*[]AccountRecentActivityWorkItemModel2, error) { + locationId, _ := uuid.Parse("1bc988f4-c15f-4072-ad35-497c87e3a909") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", nil, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []AccountRecentActivityWorkItemModel2 + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRecentActivityData function +type GetRecentActivityDataArgs struct { +} + +// Gets the work item relation type definition. +func (client *ClientImpl) GetRelationType(ctx context.Context, args GetRelationTypeArgs) (*WorkItemRelationType, error) { + routeValues := make(map[string]string) + if args.Relation == nil || *args.Relation == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Relation"} + } + routeValues["relation"] = *args.Relation + + locationId, _ := uuid.Parse("f5d33bc9-5b49-4a3c-a9bd-f3cd46dd2165") + 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 WorkItemRelationType + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRelationType function +type GetRelationTypeArgs struct { + // (required) The relation name + Relation *string +} + +// Gets the work item relation types. +func (client *ClientImpl) GetRelationTypes(ctx context.Context, args GetRelationTypesArgs) (*[]WorkItemRelationType, error) { + locationId, _ := uuid.Parse("f5d33bc9-5b49-4a3c-a9bd-f3cd46dd2165") + 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 []WorkItemRelationType + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRelationTypes function +type GetRelationTypesArgs struct { +} + +// Get a batch of work item links +func (client *ClientImpl) GetReportingLinksByLinkType(ctx context.Context, args GetReportingLinksByLinkTypeArgs) (*ReportingWorkItemLinksBatch, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.LinkTypes != nil { + listAsString := strings.Join((*args.LinkTypes)[:], ",") + queryParams.Add("linkTypes", listAsString) + } + if args.Types != nil { + listAsString := strings.Join((*args.Types)[:], ",") + queryParams.Add("types", listAsString) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.StartDateTime != nil { + queryParams.Add("startDateTime", (*args.StartDateTime).String()) + } + locationId, _ := uuid.Parse("b5b5b6d0-0308-40a1-b3f4-b9bb3c66878f") + 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 ReportingWorkItemLinksBatch + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetReportingLinksByLinkType function +type GetReportingLinksByLinkTypeArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) A list of types to filter the results to specific link types. Omit this parameter to get work item links of all link types. + LinkTypes *[]string + // (optional) A list of types to filter the results to specific work item types. Omit this parameter to get work item links of all work item types. + Types *[]string + // (optional) Specifies the continuationToken to start the batch from. Omit this parameter to get the first batch of links. + ContinuationToken *string + // (optional) Date/time to use as a starting point for link changes. Only link changes that occurred after that date/time will be returned. Cannot be used in conjunction with 'watermark' parameter. + StartDateTime *azuredevops.Time +} + +// Returns a fully hydrated work item for the requested revision +func (client *ClientImpl) GetRevision(ctx context.Context, args GetRevisionArgs) (*WorkItem, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + if args.RevisionNumber == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RevisionNumber"} + } + routeValues["revisionNumber"] = strconv.Itoa(*args.RevisionNumber) + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("a00c85a5-80fa-4565-99c3-bcd2181434bb") + 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 WorkItem + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRevision function +type GetRevisionArgs struct { + // (required) + Id *int + // (required) + RevisionNumber *int + // (optional) Project ID or project name + Project *string + // (optional) + Expand *WorkItemExpand +} + +// Returns the list of fully hydrated work item revisions, paged. +func (client *ClientImpl) GetRevisions(ctx context.Context, args GetRevisionsArgs) (*[]WorkItem, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + 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.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("a00c85a5-80fa-4565-99c3-bcd2181434bb") + 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 []WorkItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRevisions function +type GetRevisionsArgs struct { + // (required) + Id *int + // (optional) Project ID or project name + Project *string + // (optional) + Top *int + // (optional) + Skip *int + // (optional) + Expand *WorkItemExpand +} + +// Gets root classification nodes under the project. +func (client *ClientImpl) GetRootNodes(ctx context.Context, args GetRootNodesArgs) (*[]WorkItemClassificationNode, 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.Depth != nil { + queryParams.Add("$depth", strconv.Itoa(*args.Depth)) + } + locationId, _ := uuid.Parse("a70579d1-f53a-48ee-a5be-7be8659023b9") + 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 []WorkItemClassificationNode + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRootNodes function +type GetRootNodesArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Depth of children to fetch. + Depth *int +} + +// [Preview API] Gets the template with specified id +func (client *ClientImpl) GetTemplate(ctx context.Context, args GetTemplateArgs) (*WorkItemTemplate, 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.Team == nil || *args.Team == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + if args.TemplateId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TemplateId"} + } + routeValues["templateId"] = (*args.TemplateId).String() + + locationId, _ := uuid.Parse("fb10264a-8836-48a0-8033-1b0ccd2748d5") + 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 WorkItemTemplate + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTemplate function +type GetTemplateArgs struct { + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string + // (required) Template Id + TemplateId *uuid.UUID +} + +// [Preview API] Gets template +func (client *ClientImpl) GetTemplates(ctx context.Context, args GetTemplatesArgs) (*[]WorkItemTemplateReference, 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.Team == nil || *args.Team == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + + queryParams := url.Values{} + if args.Workitemtypename != nil { + queryParams.Add("workitemtypename", *args.Workitemtypename) + } + locationId, _ := uuid.Parse("6a90345f-a676-4969-afce-8e163e1d5642") + 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 []WorkItemTemplateReference + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetTemplates function +type GetTemplatesArgs struct { + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string + // (optional) Optional, When specified returns templates for given Work item type. + Workitemtypename *string +} + +// Returns a single update for a work item +func (client *ClientImpl) GetUpdate(ctx context.Context, args GetUpdateArgs) (*WorkItemUpdate, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + if args.UpdateNumber == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateNumber"} + } + routeValues["updateNumber"] = strconv.Itoa(*args.UpdateNumber) + + locationId, _ := uuid.Parse("6570bf97-d02c-4a91-8d93-3abe9895b1a9") + 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 WorkItemUpdate + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetUpdate function +type GetUpdateArgs struct { + // (required) + Id *int + // (required) + UpdateNumber *int + // (optional) Project ID or project name + Project *string +} + +// Returns a the deltas between work item revisions +func (client *ClientImpl) GetUpdates(ctx context.Context, args GetUpdatesArgs) (*[]WorkItemUpdate, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + 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("6570bf97-d02c-4a91-8d93-3abe9895b1a9") + 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 []WorkItemUpdate + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetUpdates function +type GetUpdatesArgs struct { + // (required) + Id *int + // (optional) Project ID or project name + Project *string + // (optional) + Top *int + // (optional) + Skip *int +} + +// [Preview API] Get the list of work item tracking outbound artifact link types. +func (client *ClientImpl) GetWorkArtifactLinkTypes(ctx context.Context, args GetWorkArtifactLinkTypesArgs) (*[]WorkArtifactLink, error) { + locationId, _ := uuid.Parse("1a31de40-e318-41cd-a6c6-881077df52e3") + 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 []WorkArtifactLink + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkArtifactLinkTypes function +type GetWorkArtifactLinkTypesArgs struct { +} + +// Returns a single work item. +func (client *ClientImpl) GetWorkItem(ctx context.Context, args GetWorkItemArgs) (*WorkItem, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + queryParams := url.Values{} + if args.Fields != nil { + listAsString := strings.Join((*args.Fields)[:], ",") + queryParams.Add("fields", listAsString) + } + if args.AsOf != nil { + queryParams.Add("asOf", (*args.AsOf).String()) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("72c7ddf8-2cdc-4f60-90cd-ab71c14a399b") + 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 WorkItem + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItem function +type GetWorkItemArgs struct { + // (required) The work item id + Id *int + // (optional) Project ID or project name + Project *string + // (optional) Comma-separated list of requested fields + Fields *[]string + // (optional) AsOf UTC date time string + AsOf *azuredevops.Time + // (optional) The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }. + Expand *WorkItemExpand +} + +// Get a work item icon given the friendly name and icon color. +func (client *ClientImpl) GetWorkItemIconJson(ctx context.Context, args GetWorkItemIconJsonArgs) (*WorkItemIcon, error) { + routeValues := make(map[string]string) + if args.Icon == nil || *args.Icon == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Icon"} + } + routeValues["icon"] = *args.Icon + + queryParams := url.Values{} + if args.Color != nil { + queryParams.Add("color", *args.Color) + } + if args.V != nil { + queryParams.Add("v", strconv.Itoa(*args.V)) + } + locationId, _ := uuid.Parse("4e1eb4a5-1970-4228-a682-ec48eb2dca30") + 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 WorkItemIcon + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemIconJson function +type GetWorkItemIconJsonArgs struct { + // (required) The name of the icon + Icon *string + // (optional) The 6-digit hex color for the icon + Color *string + // (optional) The version of the icon (used only for cache invalidation) + V *int +} + +// Get a list of all work item icons. +func (client *ClientImpl) GetWorkItemIcons(ctx context.Context, args GetWorkItemIconsArgs) (*[]WorkItemIcon, error) { + locationId, _ := uuid.Parse("4e1eb4a5-1970-4228-a682-ec48eb2dca30") + 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 []WorkItemIcon + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemIcons function +type GetWorkItemIconsArgs struct { +} + +// Get a work item icon given the friendly name and icon color. +func (client *ClientImpl) GetWorkItemIconSvg(ctx context.Context, args GetWorkItemIconSvgArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Icon == nil || *args.Icon == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Icon"} + } + routeValues["icon"] = *args.Icon + + queryParams := url.Values{} + if args.Color != nil { + queryParams.Add("color", *args.Color) + } + if args.V != nil { + queryParams.Add("v", strconv.Itoa(*args.V)) + } + locationId, _ := uuid.Parse("4e1eb4a5-1970-4228-a682-ec48eb2dca30") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "image/svg+xml", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetWorkItemIconSvg function +type GetWorkItemIconSvgArgs struct { + // (required) The name of the icon + Icon *string + // (optional) The 6-digit hex color for the icon + Color *string + // (optional) The version of the icon (used only for cache invalidation) + V *int +} + +// Get a work item icon given the friendly name and icon color. +func (client *ClientImpl) GetWorkItemIconXaml(ctx context.Context, args GetWorkItemIconXamlArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Icon == nil || *args.Icon == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Icon"} + } + routeValues["icon"] = *args.Icon + + queryParams := url.Values{} + if args.Color != nil { + queryParams.Add("color", *args.Color) + } + if args.V != nil { + queryParams.Add("v", strconv.Itoa(*args.V)) + } + locationId, _ := uuid.Parse("4e1eb4a5-1970-4228-a682-ec48eb2dca30") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "image/xaml+xml", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetWorkItemIconXaml function +type GetWorkItemIconXamlArgs struct { + // (required) The name of the icon + Icon *string + // (optional) The 6-digit hex color for the icon + Color *string + // (optional) The version of the icon (used only for cache invalidation) + V *int +} + +// [Preview API] Returns the next state on the given work item IDs. +func (client *ClientImpl) GetWorkItemNextStatesOnCheckinAction(ctx context.Context, args GetWorkItemNextStatesOnCheckinActionArgs) (*[]WorkItemNextStateOnTransition, error) { + queryParams := url.Values{} + if args.Ids == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "ids"} + } + var stringList []string + for _, item := range *args.Ids { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("ids", listAsString) + if args.Action != nil { + queryParams.Add("action", *args.Action) + } + locationId, _ := uuid.Parse("afae844b-e2f6-44c2-8053-17b3bb936a40") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []WorkItemNextStateOnTransition + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemNextStatesOnCheckinAction function +type GetWorkItemNextStatesOnCheckinActionArgs struct { + // (required) list of work item ids + Ids *[]int + // (optional) possible actions. Currently only supports checkin + Action *string +} + +// Returns a list of work items (Maximum 200) +func (client *ClientImpl) GetWorkItems(ctx context.Context, args GetWorkItemsArgs) (*[]WorkItem, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.Ids == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "ids"} + } + var stringList []string + for _, item := range *args.Ids { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("ids", listAsString) + if args.Fields != nil { + listAsString := strings.Join((*args.Fields)[:], ",") + queryParams.Add("fields", listAsString) + } + if args.AsOf != nil { + queryParams.Add("asOf", (*args.AsOf).String()) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.ErrorPolicy != nil { + queryParams.Add("errorPolicy", string(*args.ErrorPolicy)) + } + locationId, _ := uuid.Parse("72c7ddf8-2cdc-4f60-90cd-ab71c14a399b") + 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 []WorkItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItems function +type GetWorkItemsArgs struct { + // (required) The comma-separated list of requested work item ids. (Maximum 200 ids allowed). + Ids *[]int + // (optional) Project ID or project name + Project *string + // (optional) Comma-separated list of requested fields + Fields *[]string + // (optional) AsOf UTC date time string + AsOf *azuredevops.Time + // (optional) The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }. + Expand *WorkItemExpand + // (optional) The flag to control error policy in a bulk get work items request. Possible options are {Fail, Omit}. + ErrorPolicy *WorkItemErrorPolicy +} + +// Gets work items for a list of work item ids (Maximum 200) +func (client *ClientImpl) GetWorkItemsBatch(ctx context.Context, args GetWorkItemsBatchArgs) (*[]WorkItem, error) { + if args.WorkItemGetRequest == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemGetRequest"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.WorkItemGetRequest) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("908509b6-4248-4475-a1cd-829139ba419f") + 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 []WorkItem + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemsBatch function +type GetWorkItemsBatchArgs struct { + // (required) + WorkItemGetRequest *WorkItemBatchGetRequest + // (optional) Project ID or project name + Project *string +} + +// Returns a single work item from a template. +func (client *ClientImpl) GetWorkItemTemplate(ctx context.Context, args GetWorkItemTemplateArgs) (*WorkItem, 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.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + + queryParams := url.Values{} + if args.Fields != nil { + queryParams.Add("fields", *args.Fields) + } + if args.AsOf != nil { + queryParams.Add("asOf", (*args.AsOf).String()) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("62d3d110-0047-428c-ad3c-4fe872c91c74") + 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 WorkItem + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemTemplate function +type GetWorkItemTemplateArgs struct { + // (required) Project ID or project name + Project *string + // (required) The work item type name + Type *string + // (optional) Comma-separated list of requested fields + Fields *string + // (optional) AsOf UTC date time string + AsOf *azuredevops.Time + // (optional) The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }. + Expand *WorkItemExpand +} + +// Returns a work item type definition. +func (client *ClientImpl) GetWorkItemType(ctx context.Context, args GetWorkItemTypeArgs) (*WorkItemType, 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.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + + locationId, _ := uuid.Parse("7c8d7a76-4a09-43e8-b5df-bd792f4ac6aa") + 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 WorkItemType + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemType function +type GetWorkItemTypeArgs struct { + // (required) Project ID or project name + Project *string + // (required) Work item type name + Type *string +} + +// Get all work item type categories. +func (client *ClientImpl) GetWorkItemTypeCategories(ctx context.Context, args GetWorkItemTypeCategoriesArgs) (*[]WorkItemTypeCategory, 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("9b9f5734-36c8-415e-ba67-f83b45c31408") + 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 []WorkItemTypeCategory + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemTypeCategories function +type GetWorkItemTypeCategoriesArgs struct { + // (required) Project ID or project name + Project *string +} + +// Get specific work item type category by name. +func (client *ClientImpl) GetWorkItemTypeCategory(ctx context.Context, args GetWorkItemTypeCategoryArgs) (*WorkItemTypeCategory, 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.Category == nil || *args.Category == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Category"} + } + routeValues["category"] = *args.Category + + locationId, _ := uuid.Parse("9b9f5734-36c8-415e-ba67-f83b45c31408") + 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 WorkItemTypeCategory + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemTypeCategory function +type GetWorkItemTypeCategoryArgs struct { + // (required) Project ID or project name + Project *string + // (required) The category name + Category *string +} + +// Get a list of fields for a work item type with detailed references. +func (client *ClientImpl) GetWorkItemTypeFieldsWithReferences(ctx context.Context, args GetWorkItemTypeFieldsWithReferencesArgs) (*[]WorkItemTypeFieldWithReferences, 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.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("bd293ce5-3d25-4192-8e67-e8092e879efb") + 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 []WorkItemTypeFieldWithReferences + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemTypeFieldsWithReferences function +type GetWorkItemTypeFieldsWithReferencesArgs struct { + // (required) Project ID or project name + Project *string + // (required) Work item type. + Type *string + // (optional) Expand level for the API response. Properties: to include allowedvalues, default value, isRequired etc. as a part of response; None: to skip these properties. + Expand *WorkItemTypeFieldsExpandLevel +} + +// Get a field for a work item type with detailed references. +func (client *ClientImpl) GetWorkItemTypeFieldWithReferences(ctx context.Context, args GetWorkItemTypeFieldWithReferencesArgs) (*WorkItemTypeFieldWithReferences, 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.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + if args.Field == nil || *args.Field == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Field"} + } + routeValues["field"] = *args.Field + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("bd293ce5-3d25-4192-8e67-e8092e879efb") + 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 WorkItemTypeFieldWithReferences + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemTypeFieldWithReferences function +type GetWorkItemTypeFieldWithReferencesArgs struct { + // (required) Project ID or project name + Project *string + // (required) Work item type. + Type *string + // (required) + Field *string + // (optional) Expand level for the API response. Properties: to include allowedvalues, default value, isRequired etc. as a part of response; None: to skip these properties. + Expand *WorkItemTypeFieldsExpandLevel +} + +// Returns the list of work item types +func (client *ClientImpl) GetWorkItemTypes(ctx context.Context, args GetWorkItemTypesArgs) (*[]WorkItemType, 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("7c8d7a76-4a09-43e8-b5df-bd792f4ac6aa") + 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 []WorkItemType + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemTypes function +type GetWorkItemTypesArgs struct { + // (required) Project ID or project name + Project *string +} + +// [Preview API] Returns the state names and colors for a work item type. +func (client *ClientImpl) GetWorkItemTypeStates(ctx context.Context, args GetWorkItemTypeStatesArgs) (*[]WorkItemStateColor, 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.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + + locationId, _ := uuid.Parse("7c9d7a76-4a09-43e8-b5df-bd792f4ac6aa") + 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 []WorkItemStateColor + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemTypeStates function +type GetWorkItemTypeStatesArgs struct { + // (required) Project ID or project name + Project *string + // (required) The state name + Type *string +} + +// Gets the results of the query given the query ID. +func (client *ClientImpl) QueryById(ctx context.Context, args QueryByIdArgs) (*WorkItemQueryResult, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = (*args.Id).String() + + queryParams := url.Values{} + if args.TimePrecision != nil { + queryParams.Add("timePrecision", strconv.FormatBool(*args.TimePrecision)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + locationId, _ := uuid.Parse("a02355f5-5f8a-4671-8e32-369d23aac83d") + 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 WorkItemQueryResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryById function +type QueryByIdArgs struct { + // (required) The query ID. + Id *uuid.UUID + // (optional) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string + // (optional) Whether or not to use time precision. + TimePrecision *bool + // (optional) The max number of results to return. + Top *int +} + +// Gets the results of the query given its WIQL. +func (client *ClientImpl) QueryByWiql(ctx context.Context, args QueryByWiqlArgs) (*WorkItemQueryResult, error) { + if args.Wiql == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Wiql"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Team != nil && *args.Team != "" { + routeValues["team"] = *args.Team + } + + queryParams := url.Values{} + if args.TimePrecision != nil { + queryParams.Add("timePrecision", strconv.FormatBool(*args.TimePrecision)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + body, marshalErr := json.Marshal(*args.Wiql) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1a9c53f7-f243-4447-b110-35ef023636e4") + 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 WorkItemQueryResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryByWiql function +type QueryByWiqlArgs struct { + // (required) The query containing the WIQL. + Wiql *Wiql + // (optional) Project ID or project name + Project *string + // (optional) Team ID or team name + Team *string + // (optional) Whether or not to use time precision. + TimePrecision *bool + // (optional) The max number of results to return. + Top *int +} + +// [Preview API] Queries work items linked to a given list of artifact URI. +func (client *ClientImpl) QueryWorkItemsForArtifactUris(ctx context.Context, args QueryWorkItemsForArtifactUrisArgs) (*ArtifactUriQueryResult, error) { + if args.ArtifactUriQuery == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ArtifactUriQuery"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + body, marshalErr := json.Marshal(*args.ArtifactUriQuery) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a9a9aa7a-8c09-44d3-ad1b-46e855c1e3d3") + 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 ArtifactUriQueryResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the QueryWorkItemsForArtifactUris function +type QueryWorkItemsForArtifactUrisArgs struct { + // (required) Defines a list of artifact URI for querying work items. + ArtifactUriQuery *ArtifactUriQuery + // (optional) Project ID or project name + Project *string +} + +// [Preview API] +func (client *ClientImpl) ReadReportingDiscussions(ctx context.Context, args ReadReportingDiscussionsArgs) (*ReportingWorkItemRevisionsBatch, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.MaxPageSize != nil { + queryParams.Add("$maxPageSize", strconv.Itoa(*args.MaxPageSize)) + } + locationId, _ := uuid.Parse("4a644469-90c5-4fcc-9a9f-be0827d369ec") + 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 ReportingWorkItemRevisionsBatch + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReadReportingDiscussions function +type ReadReportingDiscussionsArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) + ContinuationToken *string + // (optional) + MaxPageSize *int +} + +// Get a batch of work item revisions with the option of including deleted items +func (client *ClientImpl) ReadReportingRevisionsGet(ctx context.Context, args ReadReportingRevisionsGetArgs) (*ReportingWorkItemRevisionsBatch, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.Fields != nil { + listAsString := strings.Join((*args.Fields)[:], ",") + queryParams.Add("fields", listAsString) + } + if args.Types != nil { + listAsString := strings.Join((*args.Types)[:], ",") + queryParams.Add("types", listAsString) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.StartDateTime != nil { + queryParams.Add("startDateTime", (*args.StartDateTime).String()) + } + if args.IncludeIdentityRef != nil { + queryParams.Add("includeIdentityRef", strconv.FormatBool(*args.IncludeIdentityRef)) + } + if args.IncludeDeleted != nil { + queryParams.Add("includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + if args.IncludeTagRef != nil { + queryParams.Add("includeTagRef", strconv.FormatBool(*args.IncludeTagRef)) + } + if args.IncludeLatestOnly != nil { + queryParams.Add("includeLatestOnly", strconv.FormatBool(*args.IncludeLatestOnly)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.IncludeDiscussionChangesOnly != nil { + queryParams.Add("includeDiscussionChangesOnly", strconv.FormatBool(*args.IncludeDiscussionChangesOnly)) + } + if args.MaxPageSize != nil { + queryParams.Add("$maxPageSize", strconv.Itoa(*args.MaxPageSize)) + } + locationId, _ := uuid.Parse("f828fe59-dd87-495d-a17c-7a8d6211ca6c") + 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 ReportingWorkItemRevisionsBatch + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReadReportingRevisionsGet function +type ReadReportingRevisionsGetArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) A list of fields to return in work item revisions. Omit this parameter to get all reportable fields. + Fields *[]string + // (optional) A list of types to filter the results to specific work item types. Omit this parameter to get work item revisions of all work item types. + Types *[]string + // (optional) Specifies the watermark to start the batch from. Omit this parameter to get the first batch of revisions. + ContinuationToken *string + // (optional) Date/time to use as a starting point for revisions, all revisions will occur after this date/time. Cannot be used in conjunction with 'watermark' parameter. + StartDateTime *azuredevops.Time + // (optional) Return an identity reference instead of a string value for identity fields. + IncludeIdentityRef *bool + // (optional) Specify if the deleted item should be returned. + IncludeDeleted *bool + // (optional) Specify if the tag objects should be returned for System.Tags field. + IncludeTagRef *bool + // (optional) Return only the latest revisions of work items, skipping all historical revisions + IncludeLatestOnly *bool + // (optional) Return all the fields in work item revisions, including long text fields which are not returned by default + Expand *ReportingRevisionsExpand + // (optional) Return only the those revisions of work items, where only history field was changed + IncludeDiscussionChangesOnly *bool + // (optional) The maximum number of results to return in this batch + MaxPageSize *int +} + +// Get a batch of work item revisions. This request may be used if your list of fields is large enough that it may run the URL over the length limit. +func (client *ClientImpl) ReadReportingRevisionsPost(ctx context.Context, args ReadReportingRevisionsPostArgs) (*ReportingWorkItemRevisionsBatch, error) { + if args.Filter == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Filter"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.StartDateTime != nil { + queryParams.Add("startDateTime", (*args.StartDateTime).String()) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + body, marshalErr := json.Marshal(*args.Filter) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("f828fe59-dd87-495d-a17c-7a8d6211ca6c") + 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 ReportingWorkItemRevisionsBatch + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReadReportingRevisionsPost function +type ReadReportingRevisionsPostArgs struct { + // (required) An object that contains request settings: field filter, type filter, identity format + Filter *ReportingWorkItemRevisionsFilter + // (optional) Project ID or project name + Project *string + // (optional) Specifies the watermark to start the batch from. Omit this parameter to get the first batch of revisions. + ContinuationToken *string + // (optional) Date/time to use as a starting point for revisions, all revisions will occur after this date/time. Cannot be used in conjunction with 'watermark' parameter. + StartDateTime *azuredevops.Time + // (optional) + Expand *ReportingRevisionsExpand +} + +// [Preview API] Replace template contents +func (client *ClientImpl) ReplaceTemplate(ctx context.Context, args ReplaceTemplateArgs) (*WorkItemTemplate, error) { + if args.TemplateContent == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TemplateContent"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Team == nil || *args.Team == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Team"} + } + routeValues["team"] = *args.Team + if args.TemplateId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TemplateId"} + } + routeValues["templateId"] = (*args.TemplateId).String() + + body, marshalErr := json.Marshal(*args.TemplateContent) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("fb10264a-8836-48a0-8033-1b0ccd2748d5") + resp, 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 nil, err + } + + var responseValue WorkItemTemplate + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ReplaceTemplate function +type ReplaceTemplateArgs struct { + // (required) Template contents to replace with + TemplateContent *WorkItemTemplate + // (required) Project ID or project name + Project *string + // (required) Team ID or team name + Team *string + // (required) Template id + TemplateId *uuid.UUID +} + +// Restores the deleted work item from Recycle Bin. +func (client *ClientImpl) RestoreWorkItem(ctx context.Context, args RestoreWorkItemArgs) (*WorkItemDelete, error) { + if args.Payload == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Payload"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + body, marshalErr := json.Marshal(*args.Payload) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("b70d8d39-926c-465e-b927-b1bf0e5ca0e0") + 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 WorkItemDelete + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the RestoreWorkItem function +type RestoreWorkItemArgs struct { + // (required) Paylod with instructions to update the IsDeleted flag to false + Payload *WorkItemDeleteUpdate + // (required) ID of the work item to be restored + Id *int + // (optional) Project ID or project name + Project *string +} + +// Searches all queries the user has access to in the current project +func (client *ClientImpl) SearchQueries(ctx context.Context, args SearchQueriesArgs) (*QueryHierarchyItemsResult, 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.Filter == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "filter"} + } + queryParams.Add("$filter", *args.Filter) + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.IncludeDeleted != nil { + queryParams.Add("$includeDeleted", strconv.FormatBool(*args.IncludeDeleted)) + } + locationId, _ := uuid.Parse("a67d190c-c41f-424b-814d-0e906f659301") + 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 QueryHierarchyItemsResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the SearchQueries function +type SearchQueriesArgs struct { + // (required) Project ID or project name + Project *string + // (required) The text to filter the queries with. + Filter *string + // (optional) The number of queries to return (Default is 50 and maximum is 200). + Top *int + // (optional) + Expand *QueryExpand + // (optional) Include deleted queries and folders + IncludeDeleted *bool +} + +// Update an existing classification node. +func (client *ClientImpl) UpdateClassificationNode(ctx context.Context, args UpdateClassificationNodeArgs) (*WorkItemClassificationNode, error) { + if args.PostedNode == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PostedNode"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.StructureGroup == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.StructureGroup"} + } + routeValues["structureGroup"] = string(*args.StructureGroup) + if args.Path != nil && *args.Path != "" { + routeValues["path"] = *args.Path + } + + body, marshalErr := json.Marshal(*args.PostedNode) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("5a172953-1b41-49d3-840a-33f79c3ce89f") + 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 WorkItemClassificationNode + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateClassificationNode function +type UpdateClassificationNodeArgs struct { + // (required) Node to create or update. + PostedNode *WorkItemClassificationNode + // (required) Project ID or project name + Project *string + // (required) Structure group of the classification node, area or iteration. + StructureGroup *TreeStructureGroup + // (optional) Path of the classification node. + Path *string +} + +// [Preview API] Update a comment on a work item. +func (client *ClientImpl) UpdateComment(ctx context.Context, args UpdateCommentArgs) (*Comment, error) { + if args.Request == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Request"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.WorkItemId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemId"} + } + routeValues["workItemId"] = strconv.Itoa(*args.WorkItemId) + if args.CommentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CommentId"} + } + routeValues["commentId"] = strconv.Itoa(*args.CommentId) + + body, marshalErr := json.Marshal(*args.Request) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("608aac0a-32e1-4493-a863-b9cf4566d257") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.3", 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) Comment update request. + Request *CommentUpdate + // (required) Project ID or project name + Project *string + // (required) Id of a work item. + WorkItemId *int + // (required) + CommentId *int +} + +// Update a query or a folder. This allows you to update, rename and move queries and folders. +func (client *ClientImpl) UpdateQuery(ctx context.Context, args UpdateQueryArgs) (*QueryHierarchyItem, error) { + if args.QueryUpdate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.QueryUpdate"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Query == nil || *args.Query == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Query"} + } + routeValues["query"] = *args.Query + + queryParams := url.Values{} + if args.UndeleteDescendants != nil { + queryParams.Add("$undeleteDescendants", strconv.FormatBool(*args.UndeleteDescendants)) + } + body, marshalErr := json.Marshal(*args.QueryUpdate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a67d190c-c41f-424b-814d-0e906f659301") + 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 QueryHierarchyItem + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateQuery function +type UpdateQueryArgs struct { + // (required) The query to update. + QueryUpdate *QueryHierarchyItem + // (required) Project ID or project name + Project *string + // (required) The ID or path for the query to update. + Query *string + // (optional) Undelete the children of this folder. It is important to note that this will not bring back the permission changes that were previously applied to the descendants. + UndeleteDescendants *bool +} + +// Updates a single work item. +func (client *ClientImpl) UpdateWorkItem(ctx context.Context, args UpdateWorkItemArgs) (*WorkItem, error) { + if args.Document == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Document"} + } + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = strconv.Itoa(*args.Id) + + queryParams := url.Values{} + if args.ValidateOnly != nil { + queryParams.Add("validateOnly", strconv.FormatBool(*args.ValidateOnly)) + } + if args.BypassRules != nil { + queryParams.Add("bypassRules", strconv.FormatBool(*args.BypassRules)) + } + if args.SuppressNotifications != nil { + queryParams.Add("suppressNotifications", strconv.FormatBool(*args.SuppressNotifications)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + body, marshalErr := json.Marshal(*args.Document) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("72c7ddf8-2cdc-4f60-90cd-ab71c14a399b") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, queryParams, bytes.NewReader(body), "application/json-patch+json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue WorkItem + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateWorkItem function +type UpdateWorkItemArgs struct { + // (required) The JSON Patch document representing the update + Document *[]webapi.JsonPatchOperation + // (required) The id of the work item to update + Id *int + // (optional) Project ID or project name + Project *string + // (optional) Indicate if you only want to validate the changes without saving the work item + ValidateOnly *bool + // (optional) Do not enforce the work item type rules on this update + BypassRules *bool + // (optional) Do not fire any notifications for this change + SuppressNotifications *bool + // (optional) The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All }. + Expand *WorkItemExpand +} diff --git a/azuredevops/workitemtracking/models.go b/azuredevops/workitemtracking/models.go new file mode 100644 index 00000000..19a9ee58 --- /dev/null +++ b/azuredevops/workitemtracking/models.go @@ -0,0 +1,1496 @@ +// -------------------------------------------------------------------------------------------- +// 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 workitemtracking + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type AccountMyWorkResult struct { + // True, when length of WorkItemDetails is same as the limit + QuerySizeLimitExceeded *bool `json:"querySizeLimitExceeded,omitempty"` + // WorkItem Details + WorkItemDetails *[]AccountWorkWorkItemModel `json:"workItemDetails,omitempty"` +} + +// Represents Work Item Recent Activity +type AccountRecentActivityWorkItemModel struct { + // Date of the last Activity by the user + ActivityDate *azuredevops.Time `json:"activityDate,omitempty"` + // Type of the activity + ActivityType *WorkItemRecentActivityType `json:"activityType,omitempty"` + // Last changed date of the work item + ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` + // Work Item Id + Id *int `json:"id,omitempty"` + // TeamFoundationId of the user this activity belongs to + IdentityId *uuid.UUID `json:"identityId,omitempty"` + // State of the work item + State *string `json:"state,omitempty"` + // Team project the work item belongs to + TeamProject *string `json:"teamProject,omitempty"` + // Title of the work item + Title *string `json:"title,omitempty"` + // Type of Work Item + WorkItemType *string `json:"workItemType,omitempty"` + // Assigned To + AssignedTo *string `json:"assignedTo,omitempty"` +} + +// Represents Work Item Recent Activity +type AccountRecentActivityWorkItemModel2 struct { + // Date of the last Activity by the user + ActivityDate *azuredevops.Time `json:"activityDate,omitempty"` + // Type of the activity + ActivityType *WorkItemRecentActivityType `json:"activityType,omitempty"` + // Last changed date of the work item + ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` + // Work Item Id + Id *int `json:"id,omitempty"` + // TeamFoundationId of the user this activity belongs to + IdentityId *uuid.UUID `json:"identityId,omitempty"` + // State of the work item + State *string `json:"state,omitempty"` + // Team project the work item belongs to + TeamProject *string `json:"teamProject,omitempty"` + // Title of the work item + Title *string `json:"title,omitempty"` + // Type of Work Item + WorkItemType *string `json:"workItemType,omitempty"` + // Assigned To + AssignedTo *webapi.IdentityRef `json:"assignedTo,omitempty"` +} + +// Represents Work Item Recent Activity +type AccountRecentActivityWorkItemModelBase struct { + // Date of the last Activity by the user + ActivityDate *azuredevops.Time `json:"activityDate,omitempty"` + // Type of the activity + ActivityType *WorkItemRecentActivityType `json:"activityType,omitempty"` + // Last changed date of the work item + ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` + // Work Item Id + Id *int `json:"id,omitempty"` + // TeamFoundationId of the user this activity belongs to + IdentityId *uuid.UUID `json:"identityId,omitempty"` + // State of the work item + State *string `json:"state,omitempty"` + // Team project the work item belongs to + TeamProject *string `json:"teamProject,omitempty"` + // Title of the work item + Title *string `json:"title,omitempty"` + // Type of Work Item + WorkItemType *string `json:"workItemType,omitempty"` +} + +// Represents Recent Mention Work Item +type AccountRecentMentionWorkItemModel struct { + // Assigned To + AssignedTo *string `json:"assignedTo,omitempty"` + // Work Item Id + Id *int `json:"id,omitempty"` + // Latest date that the user were mentioned + MentionedDateField *azuredevops.Time `json:"mentionedDateField,omitempty"` + // State of the work item + State *string `json:"state,omitempty"` + // Team project the work item belongs to + TeamProject *string `json:"teamProject,omitempty"` + // Title of the work item + Title *string `json:"title,omitempty"` + // Type of Work Item + WorkItemType *string `json:"workItemType,omitempty"` +} + +type AccountWorkWorkItemModel struct { + AssignedTo *string `json:"assignedTo,omitempty"` + ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` + Id *int `json:"id,omitempty"` + State *string `json:"state,omitempty"` + TeamProject *string `json:"teamProject,omitempty"` + Title *string `json:"title,omitempty"` + WorkItemType *string `json:"workItemType,omitempty"` +} + +// Contains criteria for querying work items based on artifact URI. +type ArtifactUriQuery struct { + // List of artifact URIs to use for querying work items. + ArtifactUris *[]string `json:"artifactUris,omitempty"` +} + +// Defines result of artifact URI query on work items. Contains mapping of work item IDs to artifact URI. +type ArtifactUriQueryResult struct { + // A Dictionary that maps a list of work item references to the given list of artifact URI. + ArtifactUrisQueryResult *map[string][]WorkItemReference `json:"artifactUrisQueryResult,omitempty"` +} + +type AttachmentReference struct { + Id *uuid.UUID `json:"id,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Flag to control error policy in a batch classification nodes get request. +type ClassificationNodesErrorPolicy string + +type classificationNodesErrorPolicyValuesType struct { + Fail ClassificationNodesErrorPolicy + Omit ClassificationNodesErrorPolicy +} + +var ClassificationNodesErrorPolicyValues = classificationNodesErrorPolicyValuesType{ + Fail: "fail", + Omit: "omit", +} + +// Comment on a Work Item. +type Comment struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // IdentityRef of the creator of the comment. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // The creation date of the comment. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Effective Date/time value for adding the comment. Can be optionally different from CreatedDate. + CreatedOnBehalfDate *azuredevops.Time `json:"createdOnBehalfDate,omitempty"` + // Identity on whose behalf this comment has been added. Can be optionally different from CreatedBy. + CreatedOnBehalfOf *webapi.IdentityRef `json:"createdOnBehalfOf,omitempty"` + // The id assigned to the comment. + Id *int `json:"id,omitempty"` + // Indicates if the comment has been deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + // The mentions of the comment. + Mentions *[]CommentMention `json:"mentions,omitempty"` + // IdentityRef of the user who last modified the comment. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // The last modification date of the comment. + ModifiedDate *azuredevops.Time `json:"modifiedDate,omitempty"` + // The reactions of the comment. + Reactions *[]CommentReaction `json:"reactions,omitempty"` + // The text of the comment. + Text *string `json:"text,omitempty"` + // The current version of the comment. + Version *int `json:"version,omitempty"` + // The id of the work item this comment belongs to. + WorkItemId *int `json:"workItemId,omitempty"` +} + +// Represents a request to create a work item comment. +type CommentCreate struct { + // The text of the comment. + Text *string `json:"text,omitempty"` +} + +// [Flags] Specifies the additional data retrieval options for work item comments. +type CommentExpandOptions string + +type commentExpandOptionsValuesType struct { + None CommentExpandOptions + Reactions CommentExpandOptions + Mentions CommentExpandOptions + RenderedText CommentExpandOptions + RenderedTextOnly CommentExpandOptions + All CommentExpandOptions +} + +var CommentExpandOptionsValues = commentExpandOptionsValuesType{ + None: "none", + // Include comment reactions. + Reactions: "reactions", + // Include comment mentions. + Mentions: "mentions", + // Include the rendered text (html) in addition to MD text. + RenderedText: "renderedText", + // If specified, then ONLY rendered text (html) will be returned, w/o markdown. Supposed to be used internally from data provides for optimization purposes. + RenderedTextOnly: "renderedTextOnly", + All: "all", +} + +// Represents a list of work item comments. +type CommentList struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // List of comments in the current batch. + Comments *[]Comment `json:"comments,omitempty"` + // A string token that can be used to retrieving next page of comments if available. Otherwise null. + ContinuationToken *string `json:"continuationToken,omitempty"` + // The count of comments in the current batch. + Count *int `json:"count,omitempty"` + // Uri to the next page of comments if it is available. Otherwise null. + NextPage *string `json:"nextPage,omitempty"` + // Total count of comments on a work item. + TotalCount *int `json:"totalCount,omitempty"` +} + +type CommentMention struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // The artifact portion of the parsed text. (i.e. the work item's id) + ArtifactId *string `json:"artifactId,omitempty"` + // The type the parser assigned to the mention. (i.e. person, work item, etc) + ArtifactType *string `json:"artifactType,omitempty"` + // The comment id of the mention. + CommentId *int `json:"commentId,omitempty"` + // The resolved target of the mention. An example of this could be a user's tfid + TargetId *string `json:"targetId,omitempty"` +} + +// Contains information about work item comment reaction for a particular reaction type. +type CommentReaction struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // The id of the comment this reaction belongs to. + CommentId *int `json:"commentId,omitempty"` + // Total number of reactions for the CommentReactionType. + Count *int `json:"count,omitempty"` + // Flag to indicate if the current user has engaged on this particular EngagementType (e.g. if they liked the associated comment). + IsCurrentUserEngaged *bool `json:"isCurrentUserEngaged,omitempty"` + // Type of the reaction. + Type *CommentReactionType `json:"type,omitempty"` +} + +// Represents different reaction types for a work item comment. +type CommentReactionType string + +type commentReactionTypeValuesType struct { + Like CommentReactionType + Dislike CommentReactionType + Heart CommentReactionType + Hooray CommentReactionType + Smile CommentReactionType + Confused CommentReactionType +} + +var CommentReactionTypeValues = commentReactionTypeValuesType{ + Like: "like", + Dislike: "dislike", + Heart: "heart", + Hooray: "hooray", + Smile: "smile", + Confused: "confused", +} + +type CommentSortOrder string + +type commentSortOrderValuesType struct { + Asc CommentSortOrder + Desc CommentSortOrder +} + +var CommentSortOrderValues = commentSortOrderValuesType{ + // The results will be sorted in Ascending order. + Asc: "asc", + // The results will be sorted in Descending order. + Desc: "desc", +} + +// Represents a request to update a work item comment. +type CommentUpdate struct { + // The updated text of the comment. + Text *string `json:"text,omitempty"` +} + +// Represents a specific version of a comment on a work item. +type CommentVersion struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // IdentityRef of the creator of the comment. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // The creation date of the comment. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // Effective Date/time value for adding the comment. Can be optionally different from CreatedDate. + CreatedOnBehalfDate *azuredevops.Time `json:"createdOnBehalfDate,omitempty"` + // Identity on whose behalf this comment has been added. Can be optionally different from CreatedBy. + CreatedOnBehalfOf *webapi.IdentityRef `json:"createdOnBehalfOf,omitempty"` + // The id assigned to the comment. + Id *int `json:"id,omitempty"` + // Indicates if the comment has been deleted at this version. + IsDeleted *bool `json:"isDeleted,omitempty"` + // IdentityRef of the user who modified the comment at this version. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // The modification date of the comment for this version. + ModifiedDate *azuredevops.Time `json:"modifiedDate,omitempty"` + // The rendered content of the comment at this version. + RenderedText *string `json:"renderedText,omitempty"` + // The text of the comment at this version. + Text *string `json:"text,omitempty"` + // The version number. + Version *int `json:"version,omitempty"` +} + +// Describes a list of dependent fields for a rule. +type FieldDependentRule struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // The dependent fields. + DependentFields *[]WorkItemFieldReference `json:"dependentFields,omitempty"` +} + +// Describes a set fields for rule evaluation. +type FieldsToEvaluate struct { + // List of fields to evaluate. + Fields *[]string `json:"fields,omitempty"` + // Updated field values to evaluate. + FieldUpdates *map[string]interface{} `json:"fieldUpdates,omitempty"` + // Initial field values. + FieldValues *map[string]interface{} `json:"fieldValues,omitempty"` + // URL of the work item type for which the rules need to be executed. + RulesFrom *[]string `json:"rulesFrom,omitempty"` +} + +// Enum for field types. +type FieldType string + +type fieldTypeValuesType struct { + String FieldType + Integer FieldType + DateTime FieldType + PlainText FieldType + Html FieldType + TreePath FieldType + History FieldType + Double FieldType + Guid FieldType + Boolean FieldType + Identity FieldType + PicklistString FieldType + PicklistInteger FieldType + PicklistDouble FieldType +} + +var FieldTypeValues = fieldTypeValuesType{ + // String field type. + String: "string", + // Integer field type. + Integer: "integer", + // Datetime field type. + DateTime: "dateTime", + // Plain text field type. + PlainText: "plainText", + // HTML (Multiline) field type. + Html: "html", + // Treepath field type. + TreePath: "treePath", + // History field type. + History: "history", + // Double field type. + Double: "double", + // Guid field type. + Guid: "guid", + // Boolean field type. + Boolean: "boolean", + // Identity field type. + Identity: "identity", + // String picklist field type. When creating a string picklist field from REST API, use "String" FieldType. + PicklistString: "picklistString", + // Integer picklist field type. When creating a integer picklist field from REST API, use "Integer" FieldType. + PicklistInteger: "picklistInteger", + // Double picklist field type. When creating a double picklist field from REST API, use "Double" FieldType. + PicklistDouble: "picklistDouble", +} + +// Enum for field usages. +type FieldUsage string + +type fieldUsageValuesType struct { + None FieldUsage + WorkItem FieldUsage + WorkItemLink FieldUsage + Tree FieldUsage + WorkItemTypeExtension FieldUsage +} + +var FieldUsageValues = fieldUsageValuesType{ + // Empty usage. + None: "none", + // Work item field usage. + WorkItem: "workItem", + // Work item link field usage. + WorkItemLink: "workItemLink", + // Treenode field usage. + Tree: "tree", + // Work Item Type Extension usage. + WorkItemTypeExtension: "workItemTypeExtension", +} + +// Flag to expand types of fields. +type GetFieldsExpand string + +type getFieldsExpandValuesType struct { + None GetFieldsExpand + ExtensionFields GetFieldsExpand +} + +var GetFieldsExpandValues = getFieldsExpandValuesType{ + // Default behavior. + None: "none", + // Adds extension fields to the response. + ExtensionFields: "extensionFields", +} + +// Describes a reference to an identity. +type IdentityReference 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"` + // 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"` + Id *uuid.UUID `json:"id,omitempty"` + // Legacy back-compat property. This has been the WIT specific value from Constants. Will be hidden (but exists) on the client unless they are targeting the newest version + Name *string `json:"name,omitempty"` +} + +// Link description. +type Link struct { + // Collection of link attributes. + Attributes *map[string]interface{} `json:"attributes,omitempty"` + // Relation type. + Rel *string `json:"rel,omitempty"` + // Link url. + Url *string `json:"url,omitempty"` +} + +// The link query mode which determines the behavior of the query. +type LinkQueryMode string + +type linkQueryModeValuesType struct { + WorkItems LinkQueryMode + LinksOneHopMustContain LinkQueryMode + LinksOneHopMayContain LinkQueryMode + LinksOneHopDoesNotContain LinkQueryMode + LinksRecursiveMustContain LinkQueryMode + LinksRecursiveMayContain LinkQueryMode + LinksRecursiveDoesNotContain LinkQueryMode +} + +var LinkQueryModeValues = linkQueryModeValuesType{ + // Returns flat list of work items. + WorkItems: "workItems", + // Returns work items where the source, target, and link criteria are all satisfied. + LinksOneHopMustContain: "linksOneHopMustContain", + // Returns work items that satisfy the source and link criteria, even if no linked work item satisfies the target criteria. + LinksOneHopMayContain: "linksOneHopMayContain", + // Returns work items that satisfy the source, only if no linked work item satisfies the link and target criteria. + LinksOneHopDoesNotContain: "linksOneHopDoesNotContain", + LinksRecursiveMustContain: "linksRecursiveMustContain", + // Returns work items a hierarchy of work items that by default satisfy the source + LinksRecursiveMayContain: "linksRecursiveMayContain", + LinksRecursiveDoesNotContain: "linksRecursiveDoesNotContain", +} + +type LogicalOperation string + +type logicalOperationValuesType struct { + None LogicalOperation + And LogicalOperation + Or LogicalOperation +} + +var LogicalOperationValues = logicalOperationValuesType{ + None: "none", + And: "and", + Or: "or", +} + +// Project work item type state colors +type ProjectWorkItemStateColors struct { + // Project name + ProjectName *string `json:"projectName,omitempty"` + // State colors for all work item type in a project + WorkItemTypeStateColors *[]WorkItemTypeStateColors `json:"workItemTypeStateColors,omitempty"` +} + +// Enumerates the possible provisioning actions that can be triggered on process template update. +type ProvisioningActionType string + +type provisioningActionTypeValuesType struct { + Import ProvisioningActionType + Validate ProvisioningActionType +} + +var ProvisioningActionTypeValues = provisioningActionTypeValuesType{ + Import: "import", + Validate: "validate", +} + +// Result of an update work item type XML update operation. +type ProvisioningResult struct { + // Details about of the provisioning import events. + ProvisioningImportEvents *[]string `json:"provisioningImportEvents,omitempty"` +} + +// Describes a request to get a list of queries +type QueryBatchGetRequest struct { + // The expand parameters for queries. Possible options are { None, Wiql, Clauses, All, Minimal } + Expand *QueryExpand `json:"$expand,omitempty"` + // The flag to control error policy in a query batch request. Possible options are { Fail, Omit }. + ErrorPolicy *QueryErrorPolicy `json:"errorPolicy,omitempty"` + // The requested query ids + Ids *[]uuid.UUID `json:"ids,omitempty"` +} + +// Enum to control error policy in a query batch request. +type QueryErrorPolicy string + +type queryErrorPolicyValuesType struct { + Fail QueryErrorPolicy + Omit QueryErrorPolicy +} + +var QueryErrorPolicyValues = queryErrorPolicyValuesType{ + Fail: "fail", + Omit: "omit", +} + +// Determines which set of additional query properties to display +type QueryExpand string + +type queryExpandValuesType struct { + None QueryExpand + Wiql QueryExpand + Clauses QueryExpand + All QueryExpand + Minimal QueryExpand +} + +var QueryExpandValues = queryExpandValuesType{ + // Expands Columns, Links and ChangeInfo + None: "none", + // Expands Columns, Links, ChangeInfo and WIQL text + Wiql: "wiql", + // Expands Columns, Links, ChangeInfo, WIQL text and clauses + Clauses: "clauses", + // Expands all properties + All: "all", + // Displays minimal properties and the WIQL text + Minimal: "minimal", +} + +// Represents an item in the work item query hierarchy. This can be either a query or a folder. +type QueryHierarchyItem struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // The child query items inside a query folder. + Children *[]QueryHierarchyItem `json:"children,omitempty"` + // The clauses for a flat query. + Clauses *WorkItemQueryClause `json:"clauses,omitempty"` + // The columns of the query. + Columns *[]WorkItemFieldReference `json:"columns,omitempty"` + // The identity who created the query item. + CreatedBy *IdentityReference `json:"createdBy,omitempty"` + // When the query item was created. + CreatedDate *azuredevops.Time `json:"createdDate,omitempty"` + // The link query mode. + FilterOptions *LinkQueryMode `json:"filterOptions,omitempty"` + // If this is a query folder, indicates if it contains any children. + HasChildren *bool `json:"hasChildren,omitempty"` + // The id of the query item. + Id *uuid.UUID `json:"id,omitempty"` + // Indicates if this query item is deleted. Setting this to false on a deleted query item will undelete it. Undeleting a query or folder will not bring back the permission changes that were previously applied to it. + IsDeleted *bool `json:"isDeleted,omitempty"` + // Indicates if this is a query folder or a query. + IsFolder *bool `json:"isFolder,omitempty"` + // Indicates if the WIQL of this query is invalid. This could be due to invalid syntax or a no longer valid area/iteration path. + IsInvalidSyntax *bool `json:"isInvalidSyntax,omitempty"` + // Indicates if this query item is public or private. + IsPublic *bool `json:"isPublic,omitempty"` + // The identity who last ran the query. + LastExecutedBy *IdentityReference `json:"lastExecutedBy,omitempty"` + // When the query was last run. + LastExecutedDate *azuredevops.Time `json:"lastExecutedDate,omitempty"` + // The identity who last modified the query item. + LastModifiedBy *IdentityReference `json:"lastModifiedBy,omitempty"` + // When the query item was last modified. + LastModifiedDate *azuredevops.Time `json:"lastModifiedDate,omitempty"` + // The link query clause. + LinkClauses *WorkItemQueryClause `json:"linkClauses,omitempty"` + // The name of the query item. + Name *string `json:"name,omitempty"` + // The path of the query item. + Path *string `json:"path,omitempty"` + // The recursion option for use in a tree query. + QueryRecursionOption *QueryRecursionOption `json:"queryRecursionOption,omitempty"` + // The type of query. + QueryType *QueryType `json:"queryType,omitempty"` + // The sort columns of the query. + SortColumns *[]WorkItemQuerySortColumn `json:"sortColumns,omitempty"` + // The source clauses in a tree or one-hop link query. + SourceClauses *WorkItemQueryClause `json:"sourceClauses,omitempty"` + // The target clauses in a tree or one-hop link query. + TargetClauses *WorkItemQueryClause `json:"targetClauses,omitempty"` + // The WIQL text of the query + Wiql *string `json:"wiql,omitempty"` +} + +type QueryHierarchyItemsResult struct { + // The count of items. + Count *int `json:"count,omitempty"` + // Indicates if the max return limit was hit but there are still more items + HasMore *bool `json:"hasMore,omitempty"` + // The list of items + Value *[]QueryHierarchyItem `json:"value,omitempty"` +} + +type QueryOption string + +type queryOptionValuesType struct { + Doing QueryOption + Done QueryOption + Followed QueryOption +} + +var QueryOptionValues = queryOptionValuesType{ + Doing: "doing", + Done: "done", + Followed: "followed", +} + +// Determines whether a tree query matches parents or children first. +type QueryRecursionOption string + +type queryRecursionOptionValuesType struct { + ParentFirst QueryRecursionOption + ChildFirst QueryRecursionOption +} + +var QueryRecursionOptionValues = queryRecursionOptionValuesType{ + // Returns work items that satisfy the source, even if no linked work item satisfies the target and link criteria. + ParentFirst: "parentFirst", + // Returns work items that satisfy the target criteria, even if no work item satisfies the source and link criteria. + ChildFirst: "childFirst", +} + +// The query result type +type QueryResultType string + +type queryResultTypeValuesType struct { + WorkItem QueryResultType + WorkItemLink QueryResultType +} + +var QueryResultTypeValues = queryResultTypeValuesType{ + // A list of work items (for flat queries). + WorkItem: "workItem", + // A list of work item links (for OneHop and Tree queries). + WorkItemLink: "workItemLink", +} + +// The type of query. +type QueryType string + +type queryTypeValuesType struct { + Flat QueryType + Tree QueryType + OneHop QueryType +} + +var QueryTypeValues = queryTypeValuesType{ + // Gets a flat list of work items. + Flat: "flat", + // Gets a tree of work items showing their link hierarchy. + Tree: "tree", + // Gets a list of work items and their direct links. + OneHop: "oneHop", +} + +// The reporting revision expand level. +type ReportingRevisionsExpand string + +type reportingRevisionsExpandValuesType struct { + None ReportingRevisionsExpand + Fields ReportingRevisionsExpand +} + +var ReportingRevisionsExpandValues = reportingRevisionsExpandValuesType{ + // Default behavior. + None: "none", + // Add fields to the response. + Fields: "fields", +} + +type ReportingWorkItemLinksBatch struct { +} + +type ReportingWorkItemRevisionsBatch struct { +} + +// The class represents the reporting work item revision filer. +type ReportingWorkItemRevisionsFilter struct { + // A list of fields to return in work item revisions. Omit this parameter to get all reportable fields. + Fields *[]string `json:"fields,omitempty"` + // Include deleted work item in the result. + IncludeDeleted *bool `json:"includeDeleted,omitempty"` + // Return an identity reference instead of a string value for identity fields. + IncludeIdentityRef *bool `json:"includeIdentityRef,omitempty"` + // Include only the latest version of a work item, skipping over all previous revisions of the work item. + IncludeLatestOnly *bool `json:"includeLatestOnly,omitempty"` + // Include tag reference instead of string value for System.Tags field + IncludeTagRef *bool `json:"includeTagRef,omitempty"` + // A list of types to filter the results to specific work item types. Omit this parameter to get work item revisions of all work item types. + Types *[]string `json:"types,omitempty"` +} + +// The class describes reporting work item revision batch. +type StreamedBatch struct { + // ContinuationToken acts as a waterMark. Used while querying large results. + ContinuationToken *string `json:"continuationToken,omitempty"` + // Returns 'true' if it's last batch, 'false' otherwise. + IsLastBatch *bool `json:"isLastBatch,omitempty"` + // The next link for the work item. + NextLink *string `json:"nextLink,omitempty"` + // Values such as rel, sourceId, TargetId, ChangedDate, isActive. + Values *[]interface{} `json:"values,omitempty"` +} + +// Enumerates types of supported xml templates used for customization. +type TemplateType string + +type templateTypeValuesType struct { + WorkItemType TemplateType + GlobalWorkflow TemplateType +} + +var TemplateTypeValues = templateTypeValuesType{ + WorkItemType: "workItemType", + GlobalWorkflow: "globalWorkflow", +} + +// Types of tree node structures. +type TreeNodeStructureType string + +type treeNodeStructureTypeValuesType struct { + Area TreeNodeStructureType + Iteration TreeNodeStructureType +} + +var TreeNodeStructureTypeValues = treeNodeStructureTypeValuesType{ + // Area type. + Area: "area", + // Iteration type. + Iteration: "iteration", +} + +// Types of tree structures groups. +type TreeStructureGroup string + +type treeStructureGroupValuesType struct { + Areas TreeStructureGroup + Iterations TreeStructureGroup +} + +var TreeStructureGroupValues = treeStructureGroupValuesType{ + Areas: "areas", + Iterations: "iterations", +} + +// A WIQL query +type Wiql struct { + // The text of the WIQL query + Query *string `json:"query,omitempty"` +} + +// A work artifact link describes an outbound artifact link type. +type WorkArtifactLink struct { + // Target artifact type. + ArtifactType *string `json:"artifactType,omitempty"` + // Outbound link type. + LinkType *string `json:"linkType,omitempty"` + // Target tool type. + ToolType *string `json:"toolType,omitempty"` +} + +// Describes a work item. +type WorkItem struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // Reference to a specific version of the comment added/edited/deleted in this revision. + CommentVersionRef *WorkItemCommentVersionRef `json:"commentVersionRef,omitempty"` + // Map of field and values for the work item. + Fields *map[string]interface{} `json:"fields,omitempty"` + // The work item ID. + Id *int `json:"id,omitempty"` + // Relations of the work item. + Relations *[]WorkItemRelation `json:"relations,omitempty"` + // Revision number of the work item. + Rev *int `json:"rev,omitempty"` +} + +// Describes a request to get a set of work items +type WorkItemBatchGetRequest struct { + // The expand parameters for work item attributes. Possible options are { None, Relations, Fields, Links, All } + Expand *WorkItemExpand `json:"$expand,omitempty"` + // AsOf UTC date time string + AsOf *azuredevops.Time `json:"asOf,omitempty"` + // The flag to control error policy in a bulk get work items request. Possible options are {Fail, Omit}. + ErrorPolicy *WorkItemErrorPolicy `json:"errorPolicy,omitempty"` + // The requested fields + Fields *[]string `json:"fields,omitempty"` + // The requested work item ids + Ids *[]int `json:"ids,omitempty"` +} + +// Defines a classification node for work item tracking. +type WorkItemClassificationNode struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // Dictionary that has node attributes like start/finish date for iteration nodes. + Attributes *map[string]interface{} `json:"attributes,omitempty"` + // List of child nodes fetched. + Children *[]WorkItemClassificationNode `json:"children,omitempty"` + // Flag that indicates if the classification node has any child nodes. + HasChildren *bool `json:"hasChildren,omitempty"` + // Integer ID of the classification node. + Id *int `json:"id,omitempty"` + // GUID ID of the classification node. + Identifier *uuid.UUID `json:"identifier,omitempty"` + // Name of the classification node. + Name *string `json:"name,omitempty"` + // Path of the classification node. + Path *string `json:"path,omitempty"` + // Node structure type. + StructureType *TreeNodeStructureType `json:"structureType,omitempty"` +} + +// Comment on Work Item +type WorkItemComment struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // Identity of user who added the comment. + RevisedBy *IdentityReference `json:"revisedBy,omitempty"` + // The date of comment. + RevisedDate *azuredevops.Time `json:"revisedDate,omitempty"` + // The work item revision number. + Revision *int `json:"revision,omitempty"` + // The text of the comment. + Text *string `json:"text,omitempty"` +} + +// Collection of comments. +type WorkItemComments struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // Comments collection. + Comments *[]WorkItemComment `json:"comments,omitempty"` + // The count of comments. + Count *int `json:"count,omitempty"` + // Count of comments from the revision. + FromRevisionCount *int `json:"fromRevisionCount,omitempty"` + // Total count of comments. + TotalCount *int `json:"totalCount,omitempty"` +} + +// Represents the reference to a specific version of a comment on a Work Item. +type WorkItemCommentVersionRef struct { + Url *string `json:"url,omitempty"` + // The id assigned to the comment. + CommentId *int `json:"commentId,omitempty"` + // [Internal] The work item revision where this comment was originally added. + CreatedInRevision *int `json:"createdInRevision,omitempty"` + // [Internal] Specifies whether comment was deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + // [Internal] The text of the comment. + Text *string `json:"text,omitempty"` + // The version number. + Version *int `json:"version,omitempty"` +} + +// Full deleted work item object. Includes the work item itself. +type WorkItemDelete struct { + // The HTTP status code for work item operation in a batch request. + Code *int `json:"code,omitempty"` + // The user who deleted the work item type. + DeletedBy *string `json:"deletedBy,omitempty"` + // The work item deletion date. + DeletedDate *string `json:"deletedDate,omitempty"` + // Work item ID. + Id *int `json:"id,omitempty"` + // The exception message for work item operation in a batch request. + Message *string `json:"message,omitempty"` + // Name or title of the work item. + Name *string `json:"name,omitempty"` + // Parent project of the deleted work item. + Project *string `json:"project,omitempty"` + // Type of work item. + Type *string `json:"type,omitempty"` + // REST API URL of the resource + Url *string `json:"url,omitempty"` + // The work item object that was deleted. + Resource *WorkItem `json:"resource,omitempty"` +} + +// Reference to a deleted work item. +type WorkItemDeleteReference struct { + // The HTTP status code for work item operation in a batch request. + Code *int `json:"code,omitempty"` + // The user who deleted the work item type. + DeletedBy *string `json:"deletedBy,omitempty"` + // The work item deletion date. + DeletedDate *string `json:"deletedDate,omitempty"` + // Work item ID. + Id *int `json:"id,omitempty"` + // The exception message for work item operation in a batch request. + Message *string `json:"message,omitempty"` + // Name or title of the work item. + Name *string `json:"name,omitempty"` + // Parent project of the deleted work item. + Project *string `json:"project,omitempty"` + // Type of work item. + Type *string `json:"type,omitempty"` + // REST API URL of the resource + Url *string `json:"url,omitempty"` +} + +// Shallow Reference to a deleted work item. +type WorkItemDeleteShallowReference struct { + // Work item ID. + Id *int `json:"id,omitempty"` + // REST API URL of the resource + Url *string `json:"url,omitempty"` +} + +// Describes an update request for a deleted work item. +type WorkItemDeleteUpdate struct { + // Sets a value indicating whether this work item is deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` +} + +// Enum to control error policy in a bulk get work items request. +type WorkItemErrorPolicy string + +type workItemErrorPolicyValuesType struct { + Fail WorkItemErrorPolicy + Omit WorkItemErrorPolicy +} + +var WorkItemErrorPolicyValues = workItemErrorPolicyValuesType{ + // Fail work error policy. + Fail: "fail", + // Omit work error policy. + Omit: "omit", +} + +// Flag to control payload properties from get work item command. +type WorkItemExpand string + +type workItemExpandValuesType struct { + None WorkItemExpand + Relations WorkItemExpand + Fields WorkItemExpand + Links WorkItemExpand + All WorkItemExpand +} + +var WorkItemExpandValues = workItemExpandValuesType{ + // Default behavior. + None: "none", + // Relations work item expand. + Relations: "relations", + // Fields work item expand. + Fields: "fields", + // Links work item expand. + Links: "links", + // Expands all. + All: "all", +} + +// Describes a field on a work item and it's properties specific to that work item type. +type WorkItemField struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // Indicates whether the field is sortable in server queries. + CanSortBy *bool `json:"canSortBy,omitempty"` + // The description of the field. + Description *string `json:"description,omitempty"` + // Indicates whether this field is an identity field. + IsIdentity *bool `json:"isIdentity,omitempty"` + // Indicates whether this instance is picklist. + IsPicklist *bool `json:"isPicklist,omitempty"` + // Indicates whether this instance is a suggested picklist . + IsPicklistSuggested *bool `json:"isPicklistSuggested,omitempty"` + // Indicates whether the field can be queried in the server. + IsQueryable *bool `json:"isQueryable,omitempty"` + // The name of the field. + Name *string `json:"name,omitempty"` + // If this field is picklist, the identifier of the picklist associated, otherwise null + PicklistId *uuid.UUID `json:"picklistId,omitempty"` + // Indicates whether the field is [read only]. + ReadOnly *bool `json:"readOnly,omitempty"` + // The reference name of the field. + ReferenceName *string `json:"referenceName,omitempty"` + // The supported operations on this field. + SupportedOperations *[]WorkItemFieldOperation `json:"supportedOperations,omitempty"` + // The type of the field. + Type *FieldType `json:"type,omitempty"` + // The usage of the field. + Usage *FieldUsage `json:"usage,omitempty"` +} + +// Describes a work item field operation. +type WorkItemFieldOperation struct { + // Friendly name of the operation. + Name *string `json:"name,omitempty"` + // Reference name of the operation. + ReferenceName *string `json:"referenceName,omitempty"` +} + +// Reference to a field in a work item +type WorkItemFieldReference struct { + // The friendly name of the field. + Name *string `json:"name,omitempty"` + // The reference name of the field. + ReferenceName *string `json:"referenceName,omitempty"` + // The REST URL of the resource. + Url *string `json:"url,omitempty"` +} + +// Describes an update to a work item field. +type WorkItemFieldUpdate struct { + // The new value of the field. + NewValue interface{} `json:"newValue,omitempty"` + // The old value of the field. + OldValue interface{} `json:"oldValue,omitempty"` +} + +type WorkItemHistory struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + Rev *int `json:"rev,omitempty"` + RevisedBy *IdentityReference `json:"revisedBy,omitempty"` + RevisedDate *azuredevops.Time `json:"revisedDate,omitempty"` + Value *string `json:"value,omitempty"` +} + +// Reference to a work item icon. +type WorkItemIcon struct { + // The identifier of the icon. + Id *string `json:"id,omitempty"` + // The REST URL of the resource. + Url *string `json:"url,omitempty"` +} + +// A link between two work items. +type WorkItemLink struct { + // The type of link. + Rel *string `json:"rel,omitempty"` + // The source work item. + Source *WorkItemReference `json:"source,omitempty"` + // The target work item. + Target *WorkItemReference `json:"target,omitempty"` +} + +// Describes the next state for a work item. +type WorkItemNextStateOnTransition struct { + // Error code if there is no next state transition possible. + ErrorCode *string `json:"errorCode,omitempty"` + // Work item ID. + Id *int `json:"id,omitempty"` + // Error message if there is no next state transition possible. + Message *string `json:"message,omitempty"` + // Name of the next state on transition. + StateOnTransition *string `json:"stateOnTransition,omitempty"` +} + +// Represents a clause in a work item query. This shows the structure of a work item query. +type WorkItemQueryClause struct { + // Child clauses if the current clause is a logical operator + Clauses *[]WorkItemQueryClause `json:"clauses,omitempty"` + // Field associated with condition + Field *WorkItemFieldReference `json:"field,omitempty"` + // Right side of the condition when a field to field comparison + FieldValue *WorkItemFieldReference `json:"fieldValue,omitempty"` + // Determines if this is a field to field comparison + IsFieldValue *bool `json:"isFieldValue,omitempty"` + // Logical operator separating the condition clause + LogicalOperator *LogicalOperation `json:"logicalOperator,omitempty"` + // The field operator + Operator *WorkItemFieldOperation `json:"operator,omitempty"` + // Right side of the condition when a field to value comparison + Value *string `json:"value,omitempty"` +} + +// The result of a work item query. +type WorkItemQueryResult struct { + // The date the query was run in the context of. + AsOf *azuredevops.Time `json:"asOf,omitempty"` + // The columns of the query. + Columns *[]WorkItemFieldReference `json:"columns,omitempty"` + // The result type + QueryResultType *QueryResultType `json:"queryResultType,omitempty"` + // The type of the query + QueryType *QueryType `json:"queryType,omitempty"` + // The sort columns of the query. + SortColumns *[]WorkItemQuerySortColumn `json:"sortColumns,omitempty"` + // The work item links returned by the query. + WorkItemRelations *[]WorkItemLink `json:"workItemRelations,omitempty"` + // The work items returned by the query. + WorkItems *[]WorkItemReference `json:"workItems,omitempty"` +} + +// A sort column. +type WorkItemQuerySortColumn struct { + // The direction to sort by. + Descending *bool `json:"descending,omitempty"` + // A work item field. + Field *WorkItemFieldReference `json:"field,omitempty"` +} + +// Type of the activity +type WorkItemRecentActivityType string + +type workItemRecentActivityTypeValuesType struct { + Visited WorkItemRecentActivityType + Edited WorkItemRecentActivityType + Deleted WorkItemRecentActivityType + Restored WorkItemRecentActivityType +} + +var WorkItemRecentActivityTypeValues = workItemRecentActivityTypeValuesType{ + Visited: "visited", + Edited: "edited", + Deleted: "deleted", + Restored: "restored", +} + +// Contains reference to a work item. +type WorkItemReference struct { + // Work item ID. + Id *int `json:"id,omitempty"` + // REST API URL of the resource + Url *string `json:"url,omitempty"` +} + +type WorkItemRelation struct { + // Collection of link attributes. + Attributes *map[string]interface{} `json:"attributes,omitempty"` + // Relation type. + Rel *string `json:"rel,omitempty"` + // Link url. + Url *string `json:"url,omitempty"` +} + +// Represents the work item type relation type. +type WorkItemRelationType struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // The name. + Name *string `json:"name,omitempty"` + // The reference name. + ReferenceName *string `json:"referenceName,omitempty"` + // The collection of relation type attributes. + Attributes *map[string]interface{} `json:"attributes,omitempty"` +} + +// Describes updates to a work item's relations. +type WorkItemRelationUpdates struct { + // List of newly added relations. + Added *[]WorkItemRelation `json:"added,omitempty"` + // List of removed relations. + Removed *[]WorkItemRelation `json:"removed,omitempty"` + // List of updated relations. + Updated *[]WorkItemRelation `json:"updated,omitempty"` +} + +// Work item type state name, color and state category +type WorkItemStateColor struct { + // Category of state + Category *string `json:"category,omitempty"` + // Color value + Color *string `json:"color,omitempty"` + // Work item type state name + Name *string `json:"name,omitempty"` +} + +// Describes a state transition in a work item. +type WorkItemStateTransition struct { + // Gets a list of actions needed to transition to that state. + Actions *[]string `json:"actions,omitempty"` + // Name of the next state. + To *string `json:"to,omitempty"` +} + +// Describes a work item template. +type WorkItemTemplate struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // The description of the work item template. + Description *string `json:"description,omitempty"` + // The identifier of the work item template. + Id *uuid.UUID `json:"id,omitempty"` + // The name of the work item template. + Name *string `json:"name,omitempty"` + // The name of the work item type. + WorkItemTypeName *string `json:"workItemTypeName,omitempty"` + // Mapping of field and its templated value. + Fields *map[string]string `json:"fields,omitempty"` +} + +// Describes a shallow reference to a work item template. +type WorkItemTemplateReference struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // The description of the work item template. + Description *string `json:"description,omitempty"` + // The identifier of the work item template. + Id *uuid.UUID `json:"id,omitempty"` + // The name of the work item template. + Name *string `json:"name,omitempty"` + // The name of the work item type. + WorkItemTypeName *string `json:"workItemTypeName,omitempty"` +} + +type WorkItemTrackingReference struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // The name. + Name *string `json:"name,omitempty"` + // The reference name. + ReferenceName *string `json:"referenceName,omitempty"` +} + +// Base class for WIT REST resources. +type WorkItemTrackingResource struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` +} + +// Base class for work item tracking resource references. +type WorkItemTrackingResourceReference struct { + Url *string `json:"url,omitempty"` +} + +// Describes a work item type. +type WorkItemType struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // The color. + Color *string `json:"color,omitempty"` + // The description of the work item type. + Description *string `json:"description,omitempty"` + // The fields that exist on the work item type. + FieldInstances *[]WorkItemTypeFieldInstance `json:"fieldInstances,omitempty"` + // The fields that exist on the work item type. + Fields *[]WorkItemTypeFieldInstance `json:"fields,omitempty"` + // The icon of the work item type. + Icon *WorkItemIcon `json:"icon,omitempty"` + // True if work item type is disabled + IsDisabled *bool `json:"isDisabled,omitempty"` + // Gets the name of the work item type. + Name *string `json:"name,omitempty"` + // The reference name of the work item type. + ReferenceName *string `json:"referenceName,omitempty"` + // Gets state information for the work item type. + States *[]WorkItemStateColor `json:"states,omitempty"` + // Gets the various state transition mappings in the work item type. + Transitions *map[string][]WorkItemStateTransition `json:"transitions,omitempty"` + // The XML form. + XmlForm *string `json:"xmlForm,omitempty"` +} + +// Describes a work item type category. +type WorkItemTypeCategory struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // Gets or sets the default type of the work item. + DefaultWorkItemType *WorkItemTypeReference `json:"defaultWorkItemType,omitempty"` + // The name of the category. + Name *string `json:"name,omitempty"` + // The reference name of the category. + ReferenceName *string `json:"referenceName,omitempty"` + // The work item types that belong to the category. + WorkItemTypes *[]WorkItemTypeReference `json:"workItemTypes,omitempty"` +} + +// Describes a work item type's colors. +type WorkItemTypeColor struct { + // Gets or sets the color of the primary. + PrimaryColor *string `json:"primaryColor,omitempty"` + // Gets or sets the color of the secondary. + SecondaryColor *string `json:"secondaryColor,omitempty"` + // The name of the work item type. + WorkItemTypeName *string `json:"workItemTypeName,omitempty"` +} + +// Describes work item type nam, its icon and color. +type WorkItemTypeColorAndIcon struct { + // The color of the work item type in hex format. + Color *string `json:"color,omitempty"` + // The work item type icon. + Icon *string `json:"icon,omitempty"` + // The name of the work item type. + WorkItemTypeName *string `json:"workItemTypeName,omitempty"` +} + +// Field instance of a work item type. +type WorkItemTypeFieldInstance struct { + // The friendly name of the field. + Name *string `json:"name,omitempty"` + // The reference name of the field. + ReferenceName *string `json:"referenceName,omitempty"` + // The REST URL of the resource. + Url *string `json:"url,omitempty"` + // Indicates whether field value is always required. + AlwaysRequired *bool `json:"alwaysRequired,omitempty"` + // The list of dependent fields. + DependentFields *[]WorkItemFieldReference `json:"dependentFields,omitempty"` + // Gets the help text for the field. + HelpText *string `json:"helpText,omitempty"` + // The list of field allowed values. + AllowedValues *[]string `json:"allowedValues,omitempty"` + // Represents the default value of the field. + DefaultValue *string `json:"defaultValue,omitempty"` +} + +// Base field instance for workItemType fields. +type WorkItemTypeFieldInstanceBase struct { + // The friendly name of the field. + Name *string `json:"name,omitempty"` + // The reference name of the field. + ReferenceName *string `json:"referenceName,omitempty"` + // The REST URL of the resource. + Url *string `json:"url,omitempty"` + // Indicates whether field value is always required. + AlwaysRequired *bool `json:"alwaysRequired,omitempty"` + // The list of dependent fields. + DependentFields *[]WorkItemFieldReference `json:"dependentFields,omitempty"` + // Gets the help text for the field. + HelpText *string `json:"helpText,omitempty"` +} + +// Expand options for the work item field(s) request. +type WorkItemTypeFieldsExpandLevel string + +type workItemTypeFieldsExpandLevelValuesType struct { + None WorkItemTypeFieldsExpandLevel + AllowedValues WorkItemTypeFieldsExpandLevel + DependentFields WorkItemTypeFieldsExpandLevel + All WorkItemTypeFieldsExpandLevel +} + +var WorkItemTypeFieldsExpandLevelValues = workItemTypeFieldsExpandLevelValuesType{ + // Includes only basic properties of the field. + None: "none", + // Includes allowed values for the field. + AllowedValues: "allowedValues", + // Includes dependent fields of the field. + DependentFields: "dependentFields", + // Includes allowed values and dependent fields of the field. + All: "all", +} + +// Field Instance of a workItemype with detailed references. +type WorkItemTypeFieldWithReferences struct { + // The friendly name of the field. + Name *string `json:"name,omitempty"` + // The reference name of the field. + ReferenceName *string `json:"referenceName,omitempty"` + // The REST URL of the resource. + Url *string `json:"url,omitempty"` + // Indicates whether field value is always required. + AlwaysRequired *bool `json:"alwaysRequired,omitempty"` + // The list of dependent fields. + DependentFields *[]WorkItemFieldReference `json:"dependentFields,omitempty"` + // Gets the help text for the field. + HelpText *string `json:"helpText,omitempty"` + // The list of field allowed values. + AllowedValues *[]interface{} `json:"allowedValues,omitempty"` + // Represents the default value of the field. + DefaultValue interface{} `json:"defaultValue,omitempty"` +} + +// Reference to a work item type. +type WorkItemTypeReference struct { + Url *string `json:"url,omitempty"` + // Name of the work item type. + Name *string `json:"name,omitempty"` +} + +// State colors for a work item type +type WorkItemTypeStateColors struct { + // Work item type state colors + StateColors *[]WorkItemStateColor `json:"stateColors,omitempty"` + // Work item type name + WorkItemTypeName *string `json:"workItemTypeName,omitempty"` +} + +// Describes a work item type template. +type WorkItemTypeTemplate struct { + // XML template in string format. + Template *string `json:"template,omitempty"` +} + +// Describes a update work item type template request body. +type WorkItemTypeTemplateUpdateModel struct { + // Describes the type of the action for the update request. + ActionType *ProvisioningActionType `json:"actionType,omitempty"` + // Methodology to which the template belongs, eg. Agile, Scrum, CMMI. + Methodology *string `json:"methodology,omitempty"` + // String representation of the work item type template. + Template *string `json:"template,omitempty"` + // The type of the template described in the request body. + TemplateType *TemplateType `json:"templateType,omitempty"` +} + +// Describes an update to a work item. +type WorkItemUpdate struct { + Url *string `json:"url,omitempty"` + // Link references to related REST resources. + Links interface{} `json:"_links,omitempty"` + // List of updates to fields. + Fields *map[string]WorkItemFieldUpdate `json:"fields,omitempty"` + // ID of update. + Id *int `json:"id,omitempty"` + // List of updates to relations. + Relations *WorkItemRelationUpdates `json:"relations,omitempty"` + // The revision number of work item update. + Rev *int `json:"rev,omitempty"` + // Identity for the work item update. + RevisedBy *IdentityReference `json:"revisedBy,omitempty"` + // The work item updates revision date. + RevisedDate *azuredevops.Time `json:"revisedDate,omitempty"` + // The work item ID. + WorkItemId *int `json:"workItemId,omitempty"` +} diff --git a/azuredevops/workitemtrackingprocess/client.go b/azuredevops/workitemtrackingprocess/client.go new file mode 100644 index 00000000..77af5ac9 --- /dev/null +++ b/azuredevops/workitemtrackingprocess/client.go @@ -0,0 +1,2182 @@ +// -------------------------------------------------------------------------------------------- +// 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 workitemtrackingprocess + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "net/http" + "net/url" +) + +var ResourceAreaId, _ = uuid.Parse("5264459e-e5e0-4bd8-b118-0985e68a4ec5") + +type Client interface { + // [Preview API] Adds a behavior to the work item type of the process. + AddBehaviorToWorkItemType(context.Context, AddBehaviorToWorkItemTypeArgs) (*WorkItemTypeBehavior, error) + // [Preview API] Adds a field to a work item type. + AddFieldToWorkItemType(context.Context, AddFieldToWorkItemTypeArgs) (*ProcessWorkItemTypeField, error) + // [Preview API] Adds a group to the work item form. + AddGroup(context.Context, AddGroupArgs) (*Group, error) + // [Preview API] Adds a page to the work item form. + AddPage(context.Context, AddPageArgs) (*Page, error) + // [Preview API] Adds a rule to work item type in the process. + AddProcessWorkItemTypeRule(context.Context, AddProcessWorkItemTypeRuleArgs) (*ProcessRule, error) + // [Preview API] Creates a control in a group. + CreateControlInGroup(context.Context, CreateControlInGroupArgs) (*Control, error) + // [Preview API] Creates a picklist. + CreateList(context.Context, CreateListArgs) (*PickList, error) + // [Preview API] Creates a process. + CreateNewProcess(context.Context, CreateNewProcessArgs) (*ProcessInfo, error) + // [Preview API] Creates a single behavior in the given process. + CreateProcessBehavior(context.Context, CreateProcessBehaviorArgs) (*ProcessBehavior, error) + // [Preview API] Creates a work item type in the process. + CreateProcessWorkItemType(context.Context, CreateProcessWorkItemTypeArgs) (*ProcessWorkItemType, error) + // [Preview API] Creates a state definition in the work item type of the process. + CreateStateDefinition(context.Context, CreateStateDefinitionArgs) (*WorkItemStateResultModel, error) + // [Preview API] Removes a picklist. + DeleteList(context.Context, DeleteListArgs) error + // [Preview API] Removes a behavior in the process. + DeleteProcessBehavior(context.Context, DeleteProcessBehaviorArgs) error + // [Preview API] Removes a process of a specific ID. + DeleteProcessById(context.Context, DeleteProcessByIdArgs) error + // [Preview API] Removes a work itewm type in the process. + DeleteProcessWorkItemType(context.Context, DeleteProcessWorkItemTypeArgs) error + // [Preview API] Removes a rule from the work item type in the process. + DeleteProcessWorkItemTypeRule(context.Context, DeleteProcessWorkItemTypeRuleArgs) error + // [Preview API] Removes a state definition in the work item type of the process. + DeleteStateDefinition(context.Context, DeleteStateDefinitionArgs) error + // [Preview API] Edit a process of a specific ID. + EditProcess(context.Context, EditProcessArgs) (*ProcessInfo, error) + // [Preview API] Returns a list of all fields in a work item type. + GetAllWorkItemTypeFields(context.Context, GetAllWorkItemTypeFieldsArgs) (*[]ProcessWorkItemTypeField, error) + // [Preview API] Returns a behavior for the work item type of the process. + GetBehaviorForWorkItemType(context.Context, GetBehaviorForWorkItemTypeArgs) (*WorkItemTypeBehavior, error) + // [Preview API] Returns a list of all behaviors for the work item type of the process. + GetBehaviorsForWorkItemType(context.Context, GetBehaviorsForWorkItemTypeArgs) (*[]WorkItemTypeBehavior, error) + // [Preview API] Gets the form layout. + GetFormLayout(context.Context, GetFormLayoutArgs) (*FormLayout, error) + // [Preview API] Returns a picklist. + GetList(context.Context, GetListArgs) (*PickList, error) + // [Preview API] Get list of all processes including system and inherited. + GetListOfProcesses(context.Context, GetListOfProcessesArgs) (*[]ProcessInfo, error) + // [Preview API] Returns meta data of the picklist. + GetListsMetadata(context.Context, GetListsMetadataArgs) (*[]PickListMetadata, error) + // [Preview API] Returns a behavior of the process. + GetProcessBehavior(context.Context, GetProcessBehaviorArgs) (*ProcessBehavior, error) + // [Preview API] Returns a list of all behaviors in the process. + GetProcessBehaviors(context.Context, GetProcessBehaviorsArgs) (*[]ProcessBehavior, error) + // [Preview API] Get a single process of a specified ID. + GetProcessByItsId(context.Context, GetProcessByItsIdArgs) (*ProcessInfo, error) + // [Preview API] Returns a single work item type in a process. + GetProcessWorkItemType(context.Context, GetProcessWorkItemTypeArgs) (*ProcessWorkItemType, error) + // [Preview API] Returns a single rule in the work item type of the process. + GetProcessWorkItemTypeRule(context.Context, GetProcessWorkItemTypeRuleArgs) (*ProcessRule, error) + // [Preview API] Returns a list of all rules in the work item type of the process. + GetProcessWorkItemTypeRules(context.Context, GetProcessWorkItemTypeRulesArgs) (*[]ProcessRule, error) + // [Preview API] Returns a list of all work item types in a process. + GetProcessWorkItemTypes(context.Context, GetProcessWorkItemTypesArgs) (*[]ProcessWorkItemType, error) + // [Preview API] Returns a single state definition in a work item type of the process. + GetStateDefinition(context.Context, GetStateDefinitionArgs) (*WorkItemStateResultModel, error) + // [Preview API] Returns a list of all state definitions in a work item type of the process. + GetStateDefinitions(context.Context, GetStateDefinitionsArgs) (*[]WorkItemStateResultModel, error) + // [Preview API] Returns a field in a work item type. + GetWorkItemTypeField(context.Context, GetWorkItemTypeFieldArgs) (*ProcessWorkItemTypeField, error) + // [Preview API] Hides a state definition in the work item type of the process.Only states with customizationType:System can be hidden. + HideStateDefinition(context.Context, HideStateDefinitionArgs) (*WorkItemStateResultModel, error) + // [Preview API] Moves a control to a specified group. + MoveControlToGroup(context.Context, MoveControlToGroupArgs) (*Control, error) + // [Preview API] Moves a group to a different page and section. + MoveGroupToPage(context.Context, MoveGroupToPageArgs) (*Group, error) + // [Preview API] Moves a group to a different section. + MoveGroupToSection(context.Context, MoveGroupToSectionArgs) (*Group, error) + // [Preview API] Removes a behavior for the work item type of the process. + RemoveBehaviorFromWorkItemType(context.Context, RemoveBehaviorFromWorkItemTypeArgs) error + // [Preview API] Removes a control from the work item form. + RemoveControlFromGroup(context.Context, RemoveControlFromGroupArgs) error + // [Preview API] Removes a group from the work item form. + RemoveGroup(context.Context, RemoveGroupArgs) error + // [Preview API] Removes a page from the work item form + RemovePage(context.Context, RemovePageArgs) error + // [Preview API] Removes a field from a work item type. Does not permanently delete the field. + RemoveWorkItemTypeField(context.Context, RemoveWorkItemTypeFieldArgs) error + // [Preview API] Updates a behavior for the work item type of the process. + UpdateBehaviorToWorkItemType(context.Context, UpdateBehaviorToWorkItemTypeArgs) (*WorkItemTypeBehavior, error) + // [Preview API] Updates a control on the work item form. + UpdateControl(context.Context, UpdateControlArgs) (*Control, error) + // [Preview API] Updates a group in the work item form. + UpdateGroup(context.Context, UpdateGroupArgs) (*Group, error) + // [Preview API] Updates a list. + UpdateList(context.Context, UpdateListArgs) (*PickList, error) + // [Preview API] Updates a page on the work item form + UpdatePage(context.Context, UpdatePageArgs) (*Page, error) + // [Preview API] Replaces a behavior in the process. + UpdateProcessBehavior(context.Context, UpdateProcessBehaviorArgs) (*ProcessBehavior, error) + // [Preview API] Updates a work item type of the process. + UpdateProcessWorkItemType(context.Context, UpdateProcessWorkItemTypeArgs) (*ProcessWorkItemType, error) + // [Preview API] Updates a rule in the work item type of the process. + UpdateProcessWorkItemTypeRule(context.Context, UpdateProcessWorkItemTypeRuleArgs) (*ProcessRule, error) + // [Preview API] Updates a given state definition in the work item type of the process. + UpdateStateDefinition(context.Context, UpdateStateDefinitionArgs) (*WorkItemStateResultModel, error) + // [Preview API] Updates a field in a work item type. + UpdateWorkItemTypeField(context.Context, UpdateWorkItemTypeFieldArgs) (*ProcessWorkItemTypeField, 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] Adds a behavior to the work item type of the process. +func (client *ClientImpl) AddBehaviorToWorkItemType(ctx context.Context, args AddBehaviorToWorkItemTypeArgs) (*WorkItemTypeBehavior, error) { + if args.Behavior == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Behavior"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefNameForBehaviors == nil || *args.WitRefNameForBehaviors == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefNameForBehaviors"} + } + routeValues["witRefNameForBehaviors"] = *args.WitRefNameForBehaviors + + body, marshalErr := json.Marshal(*args.Behavior) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("6d765a2e-4e1b-4b11-be93-f953be676024") + 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 WorkItemTypeBehavior + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddBehaviorToWorkItemType function +type AddBehaviorToWorkItemTypeArgs struct { + // (required) + Behavior *WorkItemTypeBehavior + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) Work item type reference name for the behavior + WitRefNameForBehaviors *string +} + +// [Preview API] Adds a field to a work item type. +func (client *ClientImpl) AddFieldToWorkItemType(ctx context.Context, args AddFieldToWorkItemTypeArgs) (*ProcessWorkItemTypeField, error) { + if args.Field == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Field"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + body, marshalErr := json.Marshal(*args.Field) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bc0ad8dc-e3f3-46b0-b06c-5bf861793196") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessWorkItemTypeField + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddFieldToWorkItemType function +type AddFieldToWorkItemTypeArgs struct { + // (required) + Field *AddProcessWorkItemTypeFieldRequest + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string +} + +// [Preview API] Adds a group to the work item form. +func (client *ClientImpl) AddGroup(ctx context.Context, args AddGroupArgs) (*Group, error) { + if args.Group == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Group"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.PageId == nil || *args.PageId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PageId"} + } + routeValues["pageId"] = *args.PageId + if args.SectionId == nil || *args.SectionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SectionId"} + } + routeValues["sectionId"] = *args.SectionId + + body, marshalErr := json.Marshal(*args.Group) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("766e44e1-36a8-41d7-9050-c343ff02f7a5") + 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 Group + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddGroup function +type AddGroupArgs struct { + // (required) The group. + Group *Group + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string + // (required) The ID of the page to add the group to. + PageId *string + // (required) The ID of the section to add the group to. + SectionId *string +} + +// [Preview API] Adds a page to the work item form. +func (client *ClientImpl) AddPage(ctx context.Context, args AddPageArgs) (*Page, error) { + if args.Page == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Page"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + body, marshalErr := json.Marshal(*args.Page) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1cc7b29f-6697-4d9d-b0a1-2650d3e1d584") + 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 Page + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddPage function +type AddPageArgs struct { + // (required) The page. + Page *Page + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string +} + +// [Preview API] Adds a rule to work item type in the process. +func (client *ClientImpl) AddProcessWorkItemTypeRule(ctx context.Context, args AddProcessWorkItemTypeRuleArgs) (*ProcessRule, error) { + if args.ProcessRuleCreate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessRuleCreate"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + body, marshalErr := json.Marshal(*args.ProcessRuleCreate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("76fe3432-d825-479d-a5f6-983bbb78b4f3") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessRule + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the AddProcessWorkItemTypeRule function +type AddProcessWorkItemTypeRuleArgs struct { + // (required) + ProcessRuleCreate *CreateProcessRuleRequest + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string +} + +// [Preview API] Creates a control in a group. +func (client *ClientImpl) CreateControlInGroup(ctx context.Context, args CreateControlInGroupArgs) (*Control, error) { + if args.Control == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Control"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.GroupId == nil || *args.GroupId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + + body, marshalErr := json.Marshal(*args.Control) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1f59b363-a2d0-4b7e-9bc6-eb9f5f3f0e58") + 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 Control + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateControlInGroup function +type CreateControlInGroupArgs struct { + // (required) The control. + Control *Control + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string + // (required) The ID of the group to add the control to. + GroupId *string +} + +// [Preview API] Creates a picklist. +func (client *ClientImpl) CreateList(ctx context.Context, args CreateListArgs) (*PickList, error) { + if args.Picklist == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Picklist"} + } + body, marshalErr := json.Marshal(*args.Picklist) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("01e15468-e27c-4e20-a974-bd957dcccebc") + 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 PickList + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateList function +type CreateListArgs struct { + // (required) Picklist + Picklist *PickList +} + +// [Preview API] Creates a process. +func (client *ClientImpl) CreateNewProcess(ctx context.Context, args CreateNewProcessArgs) (*ProcessInfo, error) { + if args.CreateRequest == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.CreateRequest"} + } + body, marshalErr := json.Marshal(*args.CreateRequest) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("02cc6a73-5cfb-427d-8c8e-b49fb086e8af") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessInfo + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateNewProcess function +type CreateNewProcessArgs struct { + // (required) CreateProcessModel. + CreateRequest *CreateProcessModel +} + +// [Preview API] Creates a single behavior in the given process. +func (client *ClientImpl) CreateProcessBehavior(ctx context.Context, args CreateProcessBehaviorArgs) (*ProcessBehavior, error) { + if args.Behavior == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Behavior"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + + body, marshalErr := json.Marshal(*args.Behavior) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d1800200-f184-4e75-a5f2-ad0b04b4373e") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessBehavior + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateProcessBehavior function +type CreateProcessBehaviorArgs struct { + // (required) + Behavior *ProcessBehaviorCreateRequest + // (required) The ID of the process + ProcessId *uuid.UUID +} + +// [Preview API] Creates a work item type in the process. +func (client *ClientImpl) CreateProcessWorkItemType(ctx context.Context, args CreateProcessWorkItemTypeArgs) (*ProcessWorkItemType, error) { + if args.WorkItemType == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemType"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + + body, marshalErr := json.Marshal(*args.WorkItemType) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e2e9d1a6-432d-4062-8870-bfcb8c324ad7") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessWorkItemType + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateProcessWorkItemType function +type CreateProcessWorkItemTypeArgs struct { + // (required) + WorkItemType *CreateProcessWorkItemTypeRequest + // (required) The ID of the process on which to create work item type. + ProcessId *uuid.UUID +} + +// [Preview API] Creates a state definition in the work item type of the process. +func (client *ClientImpl) CreateStateDefinition(ctx context.Context, args CreateStateDefinitionArgs) (*WorkItemStateResultModel, error) { + if args.StateModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.StateModel"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + body, marshalErr := json.Marshal(*args.StateModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("31015d57-2dff-4a46-adb3-2fb4ee3dcec9") + 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 WorkItemStateResultModel + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateStateDefinition function +type CreateStateDefinitionArgs struct { + // (required) + StateModel *WorkItemStateInputModel + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string +} + +// [Preview API] Removes a picklist. +func (client *ClientImpl) DeleteList(ctx context.Context, args DeleteListArgs) error { + routeValues := make(map[string]string) + if args.ListId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ListId"} + } + routeValues["listId"] = (*args.ListId).String() + + locationId, _ := uuid.Parse("01e15468-e27c-4e20-a974-bd957dcccebc") + _, 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 DeleteList function +type DeleteListArgs struct { + // (required) The ID of the list + ListId *uuid.UUID +} + +// [Preview API] Removes a behavior in the process. +func (client *ClientImpl) DeleteProcessBehavior(ctx context.Context, args DeleteProcessBehaviorArgs) error { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.BehaviorRefName == nil || *args.BehaviorRefName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.BehaviorRefName"} + } + routeValues["behaviorRefName"] = *args.BehaviorRefName + + locationId, _ := uuid.Parse("d1800200-f184-4e75-a5f2-ad0b04b4373e") + _, 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 DeleteProcessBehavior function +type DeleteProcessBehaviorArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the behavior + BehaviorRefName *string +} + +// [Preview API] Removes a process of a specific ID. +func (client *ClientImpl) DeleteProcessById(ctx context.Context, args DeleteProcessByIdArgs) error { + routeValues := make(map[string]string) + if args.ProcessTypeId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessTypeId"} + } + routeValues["processTypeId"] = (*args.ProcessTypeId).String() + + locationId, _ := uuid.Parse("02cc6a73-5cfb-427d-8c8e-b49fb086e8af") + _, 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 DeleteProcessById function +type DeleteProcessByIdArgs struct { + // (required) + ProcessTypeId *uuid.UUID +} + +// [Preview API] Removes a work itewm type in the process. +func (client *ClientImpl) DeleteProcessWorkItemType(ctx context.Context, args DeleteProcessWorkItemTypeArgs) error { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + locationId, _ := uuid.Parse("e2e9d1a6-432d-4062-8870-bfcb8c324ad7") + _, 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 DeleteProcessWorkItemType function +type DeleteProcessWorkItemTypeArgs struct { + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string +} + +// [Preview API] Removes a rule from the work item type in the process. +func (client *ClientImpl) DeleteProcessWorkItemTypeRule(ctx context.Context, args DeleteProcessWorkItemTypeRuleArgs) error { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.RuleId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.RuleId"} + } + routeValues["ruleId"] = (*args.RuleId).String() + + locationId, _ := uuid.Parse("76fe3432-d825-479d-a5f6-983bbb78b4f3") + _, 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 DeleteProcessWorkItemTypeRule function +type DeleteProcessWorkItemTypeRuleArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string + // (required) The ID of the rule + RuleId *uuid.UUID +} + +// [Preview API] Removes a state definition in the work item type of the process. +func (client *ClientImpl) DeleteStateDefinition(ctx context.Context, args DeleteStateDefinitionArgs) error { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.StateId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.StateId"} + } + routeValues["stateId"] = (*args.StateId).String() + + locationId, _ := uuid.Parse("31015d57-2dff-4a46-adb3-2fb4ee3dcec9") + _, 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 DeleteStateDefinition function +type DeleteStateDefinitionArgs struct { + // (required) ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string + // (required) ID of the state + StateId *uuid.UUID +} + +// [Preview API] Edit a process of a specific ID. +func (client *ClientImpl) EditProcess(ctx context.Context, args EditProcessArgs) (*ProcessInfo, error) { + if args.UpdateRequest == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UpdateRequest"} + } + routeValues := make(map[string]string) + if args.ProcessTypeId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessTypeId"} + } + routeValues["processTypeId"] = (*args.ProcessTypeId).String() + + body, marshalErr := json.Marshal(*args.UpdateRequest) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("02cc6a73-5cfb-427d-8c8e-b49fb086e8af") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessInfo + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the EditProcess function +type EditProcessArgs struct { + // (required) + UpdateRequest *UpdateProcessModel + // (required) + ProcessTypeId *uuid.UUID +} + +// [Preview API] Returns a list of all fields in a work item type. +func (client *ClientImpl) GetAllWorkItemTypeFields(ctx context.Context, args GetAllWorkItemTypeFieldsArgs) (*[]ProcessWorkItemTypeField, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + locationId, _ := uuid.Parse("bc0ad8dc-e3f3-46b0-b06c-5bf861793196") + 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 []ProcessWorkItemTypeField + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetAllWorkItemTypeFields function +type GetAllWorkItemTypeFieldsArgs struct { + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string +} + +// [Preview API] Returns a behavior for the work item type of the process. +func (client *ClientImpl) GetBehaviorForWorkItemType(ctx context.Context, args GetBehaviorForWorkItemTypeArgs) (*WorkItemTypeBehavior, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefNameForBehaviors == nil || *args.WitRefNameForBehaviors == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefNameForBehaviors"} + } + routeValues["witRefNameForBehaviors"] = *args.WitRefNameForBehaviors + if args.BehaviorRefName == nil || *args.BehaviorRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.BehaviorRefName"} + } + routeValues["behaviorRefName"] = *args.BehaviorRefName + + locationId, _ := uuid.Parse("6d765a2e-4e1b-4b11-be93-f953be676024") + 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 WorkItemTypeBehavior + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBehaviorForWorkItemType function +type GetBehaviorForWorkItemTypeArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) Work item type reference name for the behavior + WitRefNameForBehaviors *string + // (required) The reference name of the behavior + BehaviorRefName *string +} + +// [Preview API] Returns a list of all behaviors for the work item type of the process. +func (client *ClientImpl) GetBehaviorsForWorkItemType(ctx context.Context, args GetBehaviorsForWorkItemTypeArgs) (*[]WorkItemTypeBehavior, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefNameForBehaviors == nil || *args.WitRefNameForBehaviors == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefNameForBehaviors"} + } + routeValues["witRefNameForBehaviors"] = *args.WitRefNameForBehaviors + + locationId, _ := uuid.Parse("6d765a2e-4e1b-4b11-be93-f953be676024") + 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 []WorkItemTypeBehavior + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBehaviorsForWorkItemType function +type GetBehaviorsForWorkItemTypeArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) Work item type reference name for the behavior + WitRefNameForBehaviors *string +} + +// [Preview API] Gets the form layout. +func (client *ClientImpl) GetFormLayout(ctx context.Context, args GetFormLayoutArgs) (*FormLayout, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + locationId, _ := uuid.Parse("fa8646eb-43cd-4b71-9564-40106fd63e40") + 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 FormLayout + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFormLayout function +type GetFormLayoutArgs struct { + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string +} + +// [Preview API] Returns a picklist. +func (client *ClientImpl) GetList(ctx context.Context, args GetListArgs) (*PickList, error) { + routeValues := make(map[string]string) + if args.ListId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ListId"} + } + routeValues["listId"] = (*args.ListId).String() + + locationId, _ := uuid.Parse("01e15468-e27c-4e20-a974-bd957dcccebc") + 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 PickList + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetList function +type GetListArgs struct { + // (required) The ID of the list + ListId *uuid.UUID +} + +// [Preview API] Get list of all processes including system and inherited. +func (client *ClientImpl) GetListOfProcesses(ctx context.Context, args GetListOfProcessesArgs) (*[]ProcessInfo, error) { + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("02cc6a73-5cfb-427d-8c8e-b49fb086e8af") + 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 []ProcessInfo + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetListOfProcesses function +type GetListOfProcessesArgs struct { + // (optional) + Expand *GetProcessExpandLevel +} + +// [Preview API] Returns meta data of the picklist. +func (client *ClientImpl) GetListsMetadata(ctx context.Context, args GetListsMetadataArgs) (*[]PickListMetadata, error) { + locationId, _ := uuid.Parse("01e15468-e27c-4e20-a974-bd957dcccebc") + 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 []PickListMetadata + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetListsMetadata function +type GetListsMetadataArgs struct { +} + +// [Preview API] Returns a behavior of the process. +func (client *ClientImpl) GetProcessBehavior(ctx context.Context, args GetProcessBehaviorArgs) (*ProcessBehavior, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.BehaviorRefName == nil || *args.BehaviorRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.BehaviorRefName"} + } + routeValues["behaviorRefName"] = *args.BehaviorRefName + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("d1800200-f184-4e75-a5f2-ad0b04b4373e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessBehavior + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProcessBehavior function +type GetProcessBehaviorArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the behavior + BehaviorRefName *string + // (optional) + Expand *GetBehaviorsExpand +} + +// [Preview API] Returns a list of all behaviors in the process. +func (client *ClientImpl) GetProcessBehaviors(ctx context.Context, args GetProcessBehaviorsArgs) (*[]ProcessBehavior, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("d1800200-f184-4e75-a5f2-ad0b04b4373e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []ProcessBehavior + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProcessBehaviors function +type GetProcessBehaviorsArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (optional) + Expand *GetBehaviorsExpand +} + +// [Preview API] Get a single process of a specified ID. +func (client *ClientImpl) GetProcessByItsId(ctx context.Context, args GetProcessByItsIdArgs) (*ProcessInfo, error) { + routeValues := make(map[string]string) + if args.ProcessTypeId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessTypeId"} + } + routeValues["processTypeId"] = (*args.ProcessTypeId).String() + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("02cc6a73-5cfb-427d-8c8e-b49fb086e8af") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessInfo + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProcessByItsId function +type GetProcessByItsIdArgs struct { + // (required) + ProcessTypeId *uuid.UUID + // (optional) + Expand *GetProcessExpandLevel +} + +// [Preview API] Returns a single work item type in a process. +func (client *ClientImpl) GetProcessWorkItemType(ctx context.Context, args GetProcessWorkItemTypeArgs) (*ProcessWorkItemType, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("e2e9d1a6-432d-4062-8870-bfcb8c324ad7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessWorkItemType + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProcessWorkItemType function +type GetProcessWorkItemTypeArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string + // (optional) Flag to determine what properties of work item type to return + Expand *GetWorkItemTypeExpand +} + +// [Preview API] Returns a single rule in the work item type of the process. +func (client *ClientImpl) GetProcessWorkItemTypeRule(ctx context.Context, args GetProcessWorkItemTypeRuleArgs) (*ProcessRule, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.RuleId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RuleId"} + } + routeValues["ruleId"] = (*args.RuleId).String() + + locationId, _ := uuid.Parse("76fe3432-d825-479d-a5f6-983bbb78b4f3") + 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 ProcessRule + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProcessWorkItemTypeRule function +type GetProcessWorkItemTypeRuleArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string + // (required) The ID of the rule + RuleId *uuid.UUID +} + +// [Preview API] Returns a list of all rules in the work item type of the process. +func (client *ClientImpl) GetProcessWorkItemTypeRules(ctx context.Context, args GetProcessWorkItemTypeRulesArgs) (*[]ProcessRule, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + locationId, _ := uuid.Parse("76fe3432-d825-479d-a5f6-983bbb78b4f3") + 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 []ProcessRule + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProcessWorkItemTypeRules function +type GetProcessWorkItemTypeRulesArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string +} + +// [Preview API] Returns a list of all work item types in a process. +func (client *ClientImpl) GetProcessWorkItemTypes(ctx context.Context, args GetProcessWorkItemTypesArgs) (*[]ProcessWorkItemType, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + + queryParams := url.Values{} + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + locationId, _ := uuid.Parse("e2e9d1a6-432d-4062-8870-bfcb8c324ad7") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []ProcessWorkItemType + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetProcessWorkItemTypes function +type GetProcessWorkItemTypesArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (optional) Flag to determine what properties of work item type to return + Expand *GetWorkItemTypeExpand +} + +// [Preview API] Returns a single state definition in a work item type of the process. +func (client *ClientImpl) GetStateDefinition(ctx context.Context, args GetStateDefinitionArgs) (*WorkItemStateResultModel, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.StateId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.StateId"} + } + routeValues["stateId"] = (*args.StateId).String() + + locationId, _ := uuid.Parse("31015d57-2dff-4a46-adb3-2fb4ee3dcec9") + 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 WorkItemStateResultModel + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetStateDefinition function +type GetStateDefinitionArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string + // (required) The ID of the state + StateId *uuid.UUID +} + +// [Preview API] Returns a list of all state definitions in a work item type of the process. +func (client *ClientImpl) GetStateDefinitions(ctx context.Context, args GetStateDefinitionsArgs) (*[]WorkItemStateResultModel, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + locationId, _ := uuid.Parse("31015d57-2dff-4a46-adb3-2fb4ee3dcec9") + 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 []WorkItemStateResultModel + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetStateDefinitions function +type GetStateDefinitionsArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string +} + +// [Preview API] Returns a field in a work item type. +func (client *ClientImpl) GetWorkItemTypeField(ctx context.Context, args GetWorkItemTypeFieldArgs) (*ProcessWorkItemTypeField, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.FieldRefName == nil || *args.FieldRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FieldRefName"} + } + routeValues["fieldRefName"] = *args.FieldRefName + + locationId, _ := uuid.Parse("bc0ad8dc-e3f3-46b0-b06c-5bf861793196") + 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 ProcessWorkItemTypeField + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetWorkItemTypeField function +type GetWorkItemTypeFieldArgs struct { + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string + // (required) The reference name of the field. + FieldRefName *string +} + +// [Preview API] Hides a state definition in the work item type of the process.Only states with customizationType:System can be hidden. +func (client *ClientImpl) HideStateDefinition(ctx context.Context, args HideStateDefinitionArgs) (*WorkItemStateResultModel, error) { + if args.HideStateModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.HideStateModel"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.StateId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.StateId"} + } + routeValues["stateId"] = (*args.StateId).String() + + body, marshalErr := json.Marshal(*args.HideStateModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("31015d57-2dff-4a46-adb3-2fb4ee3dcec9") + resp, 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 nil, err + } + + var responseValue WorkItemStateResultModel + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the HideStateDefinition function +type HideStateDefinitionArgs struct { + // (required) + HideStateModel *HideStateModel + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string + // (required) The ID of the state + StateId *uuid.UUID +} + +// [Preview API] Moves a control to a specified group. +func (client *ClientImpl) MoveControlToGroup(ctx context.Context, args MoveControlToGroupArgs) (*Control, error) { + if args.Control == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Control"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.GroupId == nil || *args.GroupId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + if args.ControlId == nil || *args.ControlId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ControlId"} + } + routeValues["controlId"] = *args.ControlId + + queryParams := url.Values{} + if args.RemoveFromGroupId != nil { + queryParams.Add("removeFromGroupId", *args.RemoveFromGroupId) + } + body, marshalErr := json.Marshal(*args.Control) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1f59b363-a2d0-4b7e-9bc6-eb9f5f3f0e58") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Control + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the MoveControlToGroup function +type MoveControlToGroupArgs struct { + // (required) The control. + Control *Control + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string + // (required) The ID of the group to move the control to. + GroupId *string + // (required) The ID of the control. + ControlId *string + // (optional) The group ID to remove the control from. + RemoveFromGroupId *string +} + +// [Preview API] Moves a group to a different page and section. +func (client *ClientImpl) MoveGroupToPage(ctx context.Context, args MoveGroupToPageArgs) (*Group, error) { + if args.Group == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Group"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.PageId == nil || *args.PageId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PageId"} + } + routeValues["pageId"] = *args.PageId + if args.SectionId == nil || *args.SectionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SectionId"} + } + routeValues["sectionId"] = *args.SectionId + if args.GroupId == nil || *args.GroupId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + + queryParams := url.Values{} + if args.RemoveFromPageId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "removeFromPageId"} + } + queryParams.Add("removeFromPageId", *args.RemoveFromPageId) + if args.RemoveFromSectionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "removeFromSectionId"} + } + queryParams.Add("removeFromSectionId", *args.RemoveFromSectionId) + body, marshalErr := json.Marshal(*args.Group) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("766e44e1-36a8-41d7-9050-c343ff02f7a5") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Group + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the MoveGroupToPage function +type MoveGroupToPageArgs struct { + // (required) The updated group. + Group *Group + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string + // (required) The ID of the page the group is in. + PageId *string + // (required) The ID of the section the group is i.n + SectionId *string + // (required) The ID of the group. + GroupId *string + // (required) ID of the page to remove the group from. + RemoveFromPageId *string + // (required) ID of the section to remove the group from. + RemoveFromSectionId *string +} + +// [Preview API] Moves a group to a different section. +func (client *ClientImpl) MoveGroupToSection(ctx context.Context, args MoveGroupToSectionArgs) (*Group, error) { + if args.Group == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Group"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.PageId == nil || *args.PageId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PageId"} + } + routeValues["pageId"] = *args.PageId + if args.SectionId == nil || *args.SectionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SectionId"} + } + routeValues["sectionId"] = *args.SectionId + if args.GroupId == nil || *args.GroupId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + + queryParams := url.Values{} + if args.RemoveFromSectionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "removeFromSectionId"} + } + queryParams.Add("removeFromSectionId", *args.RemoveFromSectionId) + body, marshalErr := json.Marshal(*args.Group) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("766e44e1-36a8-41d7-9050-c343ff02f7a5") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Group + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the MoveGroupToSection function +type MoveGroupToSectionArgs struct { + // (required) The updated group. + Group *Group + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string + // (required) The ID of the page the group is in. + PageId *string + // (required) The ID of the section the group is in. + SectionId *string + // (required) The ID of the group. + GroupId *string + // (required) ID of the section to remove the group from. + RemoveFromSectionId *string +} + +// [Preview API] Removes a behavior for the work item type of the process. +func (client *ClientImpl) RemoveBehaviorFromWorkItemType(ctx context.Context, args RemoveBehaviorFromWorkItemTypeArgs) error { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefNameForBehaviors == nil || *args.WitRefNameForBehaviors == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefNameForBehaviors"} + } + routeValues["witRefNameForBehaviors"] = *args.WitRefNameForBehaviors + if args.BehaviorRefName == nil || *args.BehaviorRefName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.BehaviorRefName"} + } + routeValues["behaviorRefName"] = *args.BehaviorRefName + + locationId, _ := uuid.Parse("6d765a2e-4e1b-4b11-be93-f953be676024") + _, 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 RemoveBehaviorFromWorkItemType function +type RemoveBehaviorFromWorkItemTypeArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) Work item type reference name for the behavior + WitRefNameForBehaviors *string + // (required) The reference name of the behavior + BehaviorRefName *string +} + +// [Preview API] Removes a control from the work item form. +func (client *ClientImpl) RemoveControlFromGroup(ctx context.Context, args RemoveControlFromGroupArgs) error { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.GroupId == nil || *args.GroupId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + if args.ControlId == nil || *args.ControlId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ControlId"} + } + routeValues["controlId"] = *args.ControlId + + locationId, _ := uuid.Parse("1f59b363-a2d0-4b7e-9bc6-eb9f5f3f0e58") + _, 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 RemoveControlFromGroup function +type RemoveControlFromGroupArgs struct { + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string + // (required) The ID of the group. + GroupId *string + // (required) The ID of the control to remove. + ControlId *string +} + +// [Preview API] Removes a group from the work item form. +func (client *ClientImpl) RemoveGroup(ctx context.Context, args RemoveGroupArgs) error { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.PageId == nil || *args.PageId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PageId"} + } + routeValues["pageId"] = *args.PageId + if args.SectionId == nil || *args.SectionId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SectionId"} + } + routeValues["sectionId"] = *args.SectionId + if args.GroupId == nil || *args.GroupId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + + locationId, _ := uuid.Parse("766e44e1-36a8-41d7-9050-c343ff02f7a5") + _, 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 RemoveGroup function +type RemoveGroupArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string + // (required) The ID of the page the group is in + PageId *string + // (required) The ID of the section to the group is in + SectionId *string + // (required) The ID of the group + GroupId *string +} + +// [Preview API] Removes a page from the work item form +func (client *ClientImpl) RemovePage(ctx context.Context, args RemovePageArgs) error { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.PageId == nil || *args.PageId == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PageId"} + } + routeValues["pageId"] = *args.PageId + + locationId, _ := uuid.Parse("1cc7b29f-6697-4d9d-b0a1-2650d3e1d584") + _, 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 RemovePage function +type RemovePageArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string + // (required) The ID of the page + PageId *string +} + +// [Preview API] Removes a field from a work item type. Does not permanently delete the field. +func (client *ClientImpl) RemoveWorkItemTypeField(ctx context.Context, args RemoveWorkItemTypeFieldArgs) error { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.FieldRefName == nil || *args.FieldRefName == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FieldRefName"} + } + routeValues["fieldRefName"] = *args.FieldRefName + + locationId, _ := uuid.Parse("bc0ad8dc-e3f3-46b0-b06c-5bf861793196") + _, 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 RemoveWorkItemTypeField function +type RemoveWorkItemTypeFieldArgs struct { + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string + // (required) The reference name of the field. + FieldRefName *string +} + +// [Preview API] Updates a behavior for the work item type of the process. +func (client *ClientImpl) UpdateBehaviorToWorkItemType(ctx context.Context, args UpdateBehaviorToWorkItemTypeArgs) (*WorkItemTypeBehavior, error) { + if args.Behavior == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Behavior"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefNameForBehaviors == nil || *args.WitRefNameForBehaviors == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefNameForBehaviors"} + } + routeValues["witRefNameForBehaviors"] = *args.WitRefNameForBehaviors + + body, marshalErr := json.Marshal(*args.Behavior) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("6d765a2e-4e1b-4b11-be93-f953be676024") + 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 WorkItemTypeBehavior + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateBehaviorToWorkItemType function +type UpdateBehaviorToWorkItemTypeArgs struct { + // (required) + Behavior *WorkItemTypeBehavior + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) Work item type reference name for the behavior + WitRefNameForBehaviors *string +} + +// [Preview API] Updates a control on the work item form. +func (client *ClientImpl) UpdateControl(ctx context.Context, args UpdateControlArgs) (*Control, error) { + if args.Control == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Control"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.GroupId == nil || *args.GroupId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + if args.ControlId == nil || *args.ControlId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.ControlId"} + } + routeValues["controlId"] = *args.ControlId + + body, marshalErr := json.Marshal(*args.Control) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1f59b363-a2d0-4b7e-9bc6-eb9f5f3f0e58") + 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 Control + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateControl function +type UpdateControlArgs struct { + // (required) The updated control. + Control *Control + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string + // (required) The ID of the group. + GroupId *string + // (required) The ID of the control. + ControlId *string +} + +// [Preview API] Updates a group in the work item form. +func (client *ClientImpl) UpdateGroup(ctx context.Context, args UpdateGroupArgs) (*Group, error) { + if args.Group == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Group"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.PageId == nil || *args.PageId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.PageId"} + } + routeValues["pageId"] = *args.PageId + if args.SectionId == nil || *args.SectionId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.SectionId"} + } + routeValues["sectionId"] = *args.SectionId + if args.GroupId == nil || *args.GroupId == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.GroupId"} + } + routeValues["groupId"] = *args.GroupId + + body, marshalErr := json.Marshal(*args.Group) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("766e44e1-36a8-41d7-9050-c343ff02f7a5") + 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 Group + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateGroup function +type UpdateGroupArgs struct { + // (required) The updated group. + Group *Group + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string + // (required) The ID of the page the group is in. + PageId *string + // (required) The ID of the section the group is in. + SectionId *string + // (required) The ID of the group. + GroupId *string +} + +// [Preview API] Updates a list. +func (client *ClientImpl) UpdateList(ctx context.Context, args UpdateListArgs) (*PickList, error) { + if args.Picklist == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Picklist"} + } + routeValues := make(map[string]string) + if args.ListId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ListId"} + } + routeValues["listId"] = (*args.ListId).String() + + body, marshalErr := json.Marshal(*args.Picklist) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("01e15468-e27c-4e20-a974-bd957dcccebc") + resp, 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 nil, err + } + + var responseValue PickList + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateList function +type UpdateListArgs struct { + // (required) + Picklist *PickList + // (required) The ID of the list + ListId *uuid.UUID +} + +// [Preview API] Updates a page on the work item form +func (client *ClientImpl) UpdatePage(ctx context.Context, args UpdatePageArgs) (*Page, error) { + if args.Page == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Page"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + body, marshalErr := json.Marshal(*args.Page) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("1cc7b29f-6697-4d9d-b0a1-2650d3e1d584") + 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 Page + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdatePage function +type UpdatePageArgs struct { + // (required) The page + Page *Page + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string +} + +// [Preview API] Replaces a behavior in the process. +func (client *ClientImpl) UpdateProcessBehavior(ctx context.Context, args UpdateProcessBehaviorArgs) (*ProcessBehavior, error) { + if args.BehaviorData == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.BehaviorData"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.BehaviorRefName == nil || *args.BehaviorRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.BehaviorRefName"} + } + routeValues["behaviorRefName"] = *args.BehaviorRefName + + body, marshalErr := json.Marshal(*args.BehaviorData) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d1800200-f184-4e75-a5f2-ad0b04b4373e") + 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 ProcessBehavior + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateProcessBehavior function +type UpdateProcessBehaviorArgs struct { + // (required) + BehaviorData *ProcessBehaviorUpdateRequest + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the behavior + BehaviorRefName *string +} + +// [Preview API] Updates a work item type of the process. +func (client *ClientImpl) UpdateProcessWorkItemType(ctx context.Context, args UpdateProcessWorkItemTypeArgs) (*ProcessWorkItemType, error) { + if args.WorkItemTypeUpdate == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.WorkItemTypeUpdate"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + + body, marshalErr := json.Marshal(*args.WorkItemTypeUpdate) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("e2e9d1a6-432d-4062-8870-bfcb8c324ad7") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessWorkItemType + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateProcessWorkItemType function +type UpdateProcessWorkItemTypeArgs struct { + // (required) + WorkItemTypeUpdate *UpdateProcessWorkItemTypeRequest + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string +} + +// [Preview API] Updates a rule in the work item type of the process. +func (client *ClientImpl) UpdateProcessWorkItemTypeRule(ctx context.Context, args UpdateProcessWorkItemTypeRuleArgs) (*ProcessRule, error) { + if args.ProcessRule == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessRule"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.RuleId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RuleId"} + } + routeValues["ruleId"] = (*args.RuleId).String() + + body, marshalErr := json.Marshal(*args.ProcessRule) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("76fe3432-d825-479d-a5f6-983bbb78b4f3") + 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 ProcessRule + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateProcessWorkItemTypeRule function +type UpdateProcessWorkItemTypeRuleArgs struct { + // (required) + ProcessRule *UpdateProcessRuleRequest + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string + // (required) The ID of the rule + RuleId *uuid.UUID +} + +// [Preview API] Updates a given state definition in the work item type of the process. +func (client *ClientImpl) UpdateStateDefinition(ctx context.Context, args UpdateStateDefinitionArgs) (*WorkItemStateResultModel, error) { + if args.StateModel == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.StateModel"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.StateId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.StateId"} + } + routeValues["stateId"] = (*args.StateId).String() + + body, marshalErr := json.Marshal(*args.StateModel) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("31015d57-2dff-4a46-adb3-2fb4ee3dcec9") + 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 WorkItemStateResultModel + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateStateDefinition function +type UpdateStateDefinitionArgs struct { + // (required) + StateModel *WorkItemStateInputModel + // (required) ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the work item type + WitRefName *string + // (required) ID of the state + StateId *uuid.UUID +} + +// [Preview API] Updates a field in a work item type. +func (client *ClientImpl) UpdateWorkItemTypeField(ctx context.Context, args UpdateWorkItemTypeFieldArgs) (*ProcessWorkItemTypeField, error) { + if args.Field == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Field"} + } + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + if args.WitRefName == nil || *args.WitRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.WitRefName"} + } + routeValues["witRefName"] = *args.WitRefName + if args.FieldRefName == nil || *args.FieldRefName == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.FieldRefName"} + } + routeValues["fieldRefName"] = *args.FieldRefName + + body, marshalErr := json.Marshal(*args.Field) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("bc0ad8dc-e3f3-46b0-b06c-5bf861793196") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessWorkItemTypeField + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateWorkItemTypeField function +type UpdateWorkItemTypeFieldArgs struct { + // (required) + Field *UpdateProcessWorkItemTypeFieldRequest + // (required) The ID of the process. + ProcessId *uuid.UUID + // (required) The reference name of the work item type. + WitRefName *string + // (required) The reference name of the field. + FieldRefName *string +} diff --git a/azuredevops/workitemtrackingprocess/models.go b/azuredevops/workitemtrackingprocess/models.go new file mode 100644 index 00000000..01a40915 --- /dev/null +++ b/azuredevops/workitemtrackingprocess/models.go @@ -0,0 +1,850 @@ +// -------------------------------------------------------------------------------------------- +// 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 workitemtrackingprocess + +import ( + "github.com/google/uuid" +) + +// Class that describes a request to add a field in a work item type. +type AddProcessWorkItemTypeFieldRequest struct { + // Allow setting field value to a group identity. Only applies to identity fields. + AllowGroups *bool `json:"allowGroups,omitempty"` + // The default value of the field. + DefaultValue interface{} `json:"defaultValue,omitempty"` + // If true the field cannot be edited. + ReadOnly *bool `json:"readOnly,omitempty"` + // Reference name of the field. + ReferenceName *string `json:"referenceName,omitempty"` + // If true the field cannot be empty. + Required *bool `json:"required,omitempty"` +} + +// Represent a control in the form. +type Control struct { + // Contribution for the control. + Contribution *WitContribution `json:"contribution,omitempty"` + // Type of the control. + ControlType *string `json:"controlType,omitempty"` + // Height of the control, for html controls. + Height *int `json:"height,omitempty"` + // The id for the layout node. + Id *string `json:"id,omitempty"` + // A value indicating whether this layout node has been inherited. from a parent layout. This is expected to only be only set by the combiner. + Inherited *bool `json:"inherited,omitempty"` + // A value indicating if the layout node is contribution or not. + IsContribution *bool `json:"isContribution,omitempty"` + // Label for the field. + Label *string `json:"label,omitempty"` + // Inner text of the control. + Metadata *string `json:"metadata,omitempty"` + // Order in which the control should appear in its group. + Order *int `json:"order,omitempty"` + // A value indicating whether this layout node has been overridden . by a child layout. + Overridden *bool `json:"overridden,omitempty"` + // A value indicating if the control is readonly. + ReadOnly *bool `json:"readOnly,omitempty"` + // A value indicating if the control should be hidden or not. + Visible *bool `json:"visible,omitempty"` + // Watermark text for the textbox. + Watermark *string `json:"watermark,omitempty"` +} + +// Describes a process being created. +type CreateProcessModel struct { + // Description of the process + Description *string `json:"description,omitempty"` + // Name of the process + Name *string `json:"name,omitempty"` + // The ID of the parent process + ParentProcessTypeId *uuid.UUID `json:"parentProcessTypeId,omitempty"` + // Reference name of process being created. If not specified, server will assign a unique reference name + ReferenceName *string `json:"referenceName,omitempty"` +} + +// Request object/class for creating a rule on a work item type. +type CreateProcessRuleRequest struct { + // List of actions to take when the rule is triggered. + Actions *[]RuleAction `json:"actions,omitempty"` + // List of conditions when the rule should be triggered. + Conditions *[]RuleCondition `json:"conditions,omitempty"` + // Indicates if the rule is disabled. + IsDisabled *bool `json:"isDisabled,omitempty"` + // Name for the rule. + Name *string `json:"name,omitempty"` +} + +// Class for create work item type request +type CreateProcessWorkItemTypeRequest struct { + // Color hexadecimal code to represent the work item type + Color *string `json:"color,omitempty"` + // Description of the work item type + Description *string `json:"description,omitempty"` + // Icon to represent the work item type + Icon *string `json:"icon,omitempty"` + // Parent work item type for work item type + InheritsFrom *string `json:"inheritsFrom,omitempty"` + // True if the work item type need to be disabled + IsDisabled *bool `json:"isDisabled,omitempty"` + // Name of work item type + Name *string `json:"name,omitempty"` +} + +// Indicates the customization-type. Customization-type is System if is system generated or by default. Customization-type is Inherited if the existing workitemtype of inherited process is customized. Customization-type is Custom if the newly created workitemtype is customized. +type CustomizationType string + +type customizationTypeValuesType struct { + System CustomizationType + Inherited CustomizationType + Custom CustomizationType +} + +var CustomizationTypeValues = customizationTypeValuesType{ + // Customization-type is System if is system generated workitemtype. + System: "system", + // Customization-type is Inherited if the existing workitemtype of inherited process is customized. + Inherited: "inherited", + // Customization-type is Custom if the newly created workitemtype is customized. + Custom: "custom", +} + +// Represents the extensions part of the layout +type Extension struct { + // Id of the extension + Id *string `json:"id,omitempty"` +} + +type FieldModel struct { + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + IsIdentity *bool `json:"isIdentity,omitempty"` + Name *string `json:"name,omitempty"` + Type *FieldType `json:"type,omitempty"` + Url *string `json:"url,omitempty"` +} + +type FieldRuleModel struct { + Actions *[]RuleActionModel `json:"actions,omitempty"` + Conditions *[]RuleConditionModel `json:"conditions,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + IsDisabled *bool `json:"isDisabled,omitempty"` + IsSystem *bool `json:"isSystem,omitempty"` +} + +// Enum for the type of a field. +type FieldType string + +type fieldTypeValuesType struct { + String FieldType + Integer FieldType + DateTime FieldType + PlainText FieldType + Html FieldType + TreePath FieldType + History FieldType + Double FieldType + Guid FieldType + Boolean FieldType + Identity FieldType + PicklistInteger FieldType + PicklistString FieldType + PicklistDouble FieldType +} + +var FieldTypeValues = fieldTypeValuesType{ + // String field type. + String: "string", + // Integer field type. + Integer: "integer", + // DateTime field type. + DateTime: "dateTime", + // Plain text field type. + PlainText: "plainText", + // HTML (Multiline) field type. + Html: "html", + // Treepath field type. + TreePath: "treePath", + // History field type. + History: "history", + // Double field type. + Double: "double", + // Guid field type. + Guid: "guid", + // Boolean field type. + Boolean: "boolean", + // Identity field type. + Identity: "identity", + // Integer picklist field type. + PicklistInteger: "picklistInteger", + // String picklist field type. + PicklistString: "picklistString", + // Double picklist field type. + PicklistDouble: "picklistDouble", +} + +// Describes the layout of a work item type +type FormLayout struct { + // Gets and sets extensions list. + Extensions *[]Extension `json:"extensions,omitempty"` + // Top level tabs of the layout. + Pages *[]Page `json:"pages,omitempty"` + // Headers controls of the layout. + SystemControls *[]Control `json:"systemControls,omitempty"` +} + +// Expand options to fetch fields for behaviors API. +type GetBehaviorsExpand string + +type getBehaviorsExpandValuesType struct { + None GetBehaviorsExpand + Fields GetBehaviorsExpand + CombinedFields GetBehaviorsExpand +} + +var GetBehaviorsExpandValues = getBehaviorsExpandValuesType{ + // Default none option. + None: "none", + // This option returns fields associated with a behavior. + Fields: "fields", + // This option returns fields associated with this behavior and all behaviors from which it inherits. + CombinedFields: "combinedFields", +} + +// [Flags] The expand level of returned processes. +type GetProcessExpandLevel string + +type getProcessExpandLevelValuesType struct { + None GetProcessExpandLevel + Projects GetProcessExpandLevel +} + +var GetProcessExpandLevelValues = getProcessExpandLevelValuesType{ + // No expand level. + None: "none", + // Projects expand level. + Projects: "projects", +} + +// [Flags] Flag to define what properties to return in get work item type response. +type GetWorkItemTypeExpand string + +type getWorkItemTypeExpandValuesType struct { + None GetWorkItemTypeExpand + States GetWorkItemTypeExpand + Behaviors GetWorkItemTypeExpand + Layout GetWorkItemTypeExpand +} + +var GetWorkItemTypeExpandValues = getWorkItemTypeExpandValuesType{ + // Returns no properties in get work item type response. + None: "none", + // Returns states property in get work item type response. + States: "states", + // Returns behaviors property in get work item type response. + Behaviors: "behaviors", + // Returns layout property in get work item type response. + Layout: "layout", +} + +// Represent a group in the form that holds controls in it. +type Group struct { + // Contribution for the group. + Contribution *WitContribution `json:"contribution,omitempty"` + // Controls to be put in the group. + Controls *[]Control `json:"controls,omitempty"` + // The height for the contribution. + Height *int `json:"height,omitempty"` + // The id for the layout node. + Id *string `json:"id,omitempty"` + // A value indicating whether this layout node has been inherited from a parent layout. This is expected to only be only set by the combiner. + Inherited *bool `json:"inherited,omitempty"` + // A value indicating if the layout node is contribution are not. + IsContribution *bool `json:"isContribution,omitempty"` + // Label for the group. + Label *string `json:"label,omitempty"` + // Order in which the group should appear in the section. + Order *int `json:"order,omitempty"` + // A value indicating whether this layout node has been overridden by a child layout. + Overridden *bool `json:"overridden,omitempty"` + // A value indicating if the group should be hidden or not. + Visible *bool `json:"visible,omitempty"` +} + +// Class that describes the work item state is hidden. +type HideStateModel struct { + // Returns 'true', if workitem state is hidden, 'false' otherwise. + Hidden *bool `json:"hidden,omitempty"` +} + +// Describes a page in the work item form layout +type Page struct { + // Contribution for the page. + Contribution *WitContribution `json:"contribution,omitempty"` + // The id for the layout node. + Id *string `json:"id,omitempty"` + // A value indicating whether this layout node has been inherited from a parent layout. This is expected to only be only set by the combiner. + Inherited *bool `json:"inherited,omitempty"` + // A value indicating if the layout node is contribution are not. + IsContribution *bool `json:"isContribution,omitempty"` + // The label for the page. + Label *string `json:"label,omitempty"` + // A value indicating whether any user operations are permitted on this page and the contents of this page + Locked *bool `json:"locked,omitempty"` + // Order in which the page should appear in the layout. + Order *int `json:"order,omitempty"` + // A value indicating whether this layout node has been overridden by a child layout. + Overridden *bool `json:"overridden,omitempty"` + // The icon for the page. + PageType *PageType `json:"pageType,omitempty"` + // The sections of the page. + Sections *[]Section `json:"sections,omitempty"` + // A value indicating if the page should be hidden or not. + Visible *bool `json:"visible,omitempty"` +} + +// Enum for the types of pages in the work item form layout +type PageType string + +type pageTypeValuesType struct { + Custom PageType + History PageType + Links PageType + Attachments PageType +} + +var PageTypeValues = pageTypeValuesType{ + // Custom page type. + Custom: "custom", + // History page type. + History: "history", + // Link page type. + Links: "links", + // Attachment page type. + Attachments: "attachments", +} + +// Picklist. +type PickList struct { + // ID of the picklist + Id *uuid.UUID `json:"id,omitempty"` + // Indicates whether items outside of suggested list are allowed + IsSuggested *bool `json:"isSuggested,omitempty"` + // Name of the picklist + Name *string `json:"name,omitempty"` + // DataType of picklist + Type *string `json:"type,omitempty"` + // Url of the picklist + Url *string `json:"url,omitempty"` + // A list of PicklistItemModel. + Items *[]string `json:"items,omitempty"` +} + +// Metadata for picklist. +type PickListMetadata struct { + // ID of the picklist + Id *uuid.UUID `json:"id,omitempty"` + // Indicates whether items outside of suggested list are allowed + IsSuggested *bool `json:"isSuggested,omitempty"` + // Name of the picklist + Name *string `json:"name,omitempty"` + // DataType of picklist + Type *string `json:"type,omitempty"` + // Url of the picklist + Url *string `json:"url,omitempty"` +} + +// Process Behavior Model. +type ProcessBehavior struct { + // Color. + Color *string `json:"color,omitempty"` + // Indicates the type of customization on this work item. System behaviors are inherited from parent process but not modified. Inherited behaviors are modified modified behaviors that were inherited from parent process. Custom behaviors are behaviors created by user in current process. + Customization *CustomizationType `json:"customization,omitempty"` + // . Description + Description *string `json:"description,omitempty"` + // Process Behavior Fields. + Fields *[]ProcessBehaviorField `json:"fields,omitempty"` + // Parent behavior reference. + Inherits *ProcessBehaviorReference `json:"inherits,omitempty"` + // Behavior Name. + Name *string `json:"name,omitempty"` + // Rank of the behavior + Rank *int `json:"rank,omitempty"` + // Behavior Id + ReferenceName *string `json:"referenceName,omitempty"` + // Url of the behavior. + Url *string `json:"url,omitempty"` +} + +// Process Behavior Create Payload. +type ProcessBehaviorCreateRequest struct { + // Color. + Color *string `json:"color,omitempty"` + // Parent behavior id. + Inherits *string `json:"inherits,omitempty"` + // Name of the behavior. + Name *string `json:"name,omitempty"` + // ReferenceName is optional, if not specified will be auto-generated. + ReferenceName *string `json:"referenceName,omitempty"` +} + +// Process Behavior Field. +type ProcessBehaviorField struct { + // Name of the field. + Name *string `json:"name,omitempty"` + // Reference name of the field. + ReferenceName *string `json:"referenceName,omitempty"` + // Url to field. + Url *string `json:"url,omitempty"` +} + +// Process behavior Reference. +type ProcessBehaviorReference struct { + // Id of a Behavior. + BehaviorRefName *string `json:"behaviorRefName,omitempty"` + // Url to behavior. + Url *string `json:"url,omitempty"` +} + +// Process Behavior Replace Payload. +type ProcessBehaviorUpdateRequest struct { + // Color. + Color *string `json:"color,omitempty"` + // Behavior Name. + Name *string `json:"name,omitempty"` +} + +type ProcessClass string + +type processClassValuesType struct { + System ProcessClass + Derived ProcessClass + Custom ProcessClass +} + +var ProcessClassValues = processClassValuesType{ + System: "system", + Derived: "derived", + Custom: "custom", +} + +// Process. +type ProcessInfo struct { + // Indicates the type of customization on this process. System Process is default process. Inherited Process is modified process that was System process before. + CustomizationType *CustomizationType `json:"customizationType,omitempty"` + // Description of the process. + Description *string `json:"description,omitempty"` + // Is the process default. + IsDefault *bool `json:"isDefault,omitempty"` + // Is the process enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` + // Name of the process. + Name *string `json:"name,omitempty"` + // ID of the parent process. + ParentProcessTypeId *uuid.UUID `json:"parentProcessTypeId,omitempty"` + // Projects in this process to which the user is subscribed to. + Projects *[]ProjectReference `json:"projects,omitempty"` + // Reference name of the process. + ReferenceName *string `json:"referenceName,omitempty"` + // The ID of the process. + TypeId *uuid.UUID `json:"typeId,omitempty"` +} + +type ProcessModel struct { + // Description of the process + Description *string `json:"description,omitempty"` + // Name of the process + Name *string `json:"name,omitempty"` + // Projects in this process + Projects *[]ProjectReference `json:"projects,omitempty"` + // Properties of the process + Properties *ProcessProperties `json:"properties,omitempty"` + // Reference name of the process + ReferenceName *string `json:"referenceName,omitempty"` + // The ID of the process + TypeId *uuid.UUID `json:"typeId,omitempty"` +} + +// Properties of the process. +type ProcessProperties struct { + // Class of the process. + Class *ProcessClass `json:"class,omitempty"` + // Is the process default process. + IsDefault *bool `json:"isDefault,omitempty"` + // Is the process enabled. + IsEnabled *bool `json:"isEnabled,omitempty"` + // ID of the parent process. + ParentProcessTypeId *uuid.UUID `json:"parentProcessTypeId,omitempty"` + // Version of the process. + Version *string `json:"version,omitempty"` +} + +// Process Rule Response. +type ProcessRule struct { + // List of actions to take when the rule is triggered. + Actions *[]RuleAction `json:"actions,omitempty"` + // List of conditions when the rule should be triggered. + Conditions *[]RuleCondition `json:"conditions,omitempty"` + // Indicates if the rule is disabled. + IsDisabled *bool `json:"isDisabled,omitempty"` + // Name for the rule. + Name *string `json:"name,omitempty"` + // Indicates if the rule is system generated or created by user. + CustomizationType *CustomizationType `json:"customizationType,omitempty"` + // Id to uniquely identify the rule. + Id *uuid.UUID `json:"id,omitempty"` + // Resource Url. + Url *string `json:"url,omitempty"` +} + +// Class that describes a work item type object +type ProcessWorkItemType struct { + Behaviors *[]WorkItemTypeBehavior `json:"behaviors,omitempty"` + // Color hexadecimal code to represent the work item type + Color *string `json:"color,omitempty"` + // Indicates the type of customization on this work item System work item types are inherited from parent process but not modified Inherited work item types are modified work item that were inherited from parent process Custom work item types are work item types that were created in the current process + Customization *CustomizationType `json:"customization,omitempty"` + // Description of the work item type + Description *string `json:"description,omitempty"` + // Icon to represent the work item typ + Icon *string `json:"icon,omitempty"` + // Reference name of the parent work item type + Inherits *string `json:"inherits,omitempty"` + // Indicates if a work item type is disabled + IsDisabled *bool `json:"isDisabled,omitempty"` + Layout *FormLayout `json:"layout,omitempty"` + // Name of the work item type + Name *string `json:"name,omitempty"` + // Reference name of work item type + ReferenceName *string `json:"referenceName,omitempty"` + States *[]WorkItemStateResultModel `json:"states,omitempty"` + // Url of the work item type + Url *string `json:"url,omitempty"` +} + +// Class that describes a field in a work item type and its properties. +type ProcessWorkItemTypeField struct { + // Allow setting field value to a group identity. Only applies to identity fields. + AllowGroups *bool `json:"allowGroups,omitempty"` + // Indicates the type of customization on this work item. + Customization *CustomizationType `json:"customization,omitempty"` + // The default value of the field. + DefaultValue interface{} `json:"defaultValue,omitempty"` + // Description of the field. + Description *string `json:"description,omitempty"` + // Name of the field. + Name *string `json:"name,omitempty"` + // If true the field cannot be edited. + ReadOnly *bool `json:"readOnly,omitempty"` + // Reference name of the field. + ReferenceName *string `json:"referenceName,omitempty"` + // If true the field cannot be empty. + Required *bool `json:"required,omitempty"` + // Type of the field. + Type *FieldType `json:"type,omitempty"` + // Resource URL of the field. + Url *string `json:"url,omitempty"` +} + +// Defines the project reference class. +type ProjectReference struct { + // Description of the project + Description *string `json:"description,omitempty"` + // The ID of the project + Id *uuid.UUID `json:"id,omitempty"` + // Name of the project + Name *string `json:"name,omitempty"` + // Url of the project + Url *string `json:"url,omitempty"` +} + +// Action to take when the rule is triggered. +type RuleAction struct { + // Type of action to take when the rule is triggered. + ActionType *RuleActionType `json:"actionType,omitempty"` + // Field on which the action should be taken. + TargetField *string `json:"targetField,omitempty"` + // Value to apply on target field, once the action is taken. + Value *string `json:"value,omitempty"` +} + +// Action to take when the rule is triggered. +type RuleActionModel struct { + ActionType *string `json:"actionType,omitempty"` + TargetField *string `json:"targetField,omitempty"` + Value *string `json:"value,omitempty"` +} + +// Type of action to take when the rule is triggered. +type RuleActionType string + +type ruleActionTypeValuesType struct { + MakeRequired RuleActionType + MakeReadOnly RuleActionType + SetDefaultValue RuleActionType + SetDefaultFromClock RuleActionType + SetDefaultFromCurrentUser RuleActionType + SetDefaultFromField RuleActionType + CopyValue RuleActionType + CopyFromClock RuleActionType + CopyFromCurrentUser RuleActionType + CopyFromField RuleActionType + SetValueToEmpty RuleActionType + CopyFromServerClock RuleActionType + CopyFromServerCurrentUser RuleActionType +} + +var RuleActionTypeValues = ruleActionTypeValuesType{ + // Make the target field required. Example : {"actionType":"$makeRequired","targetField":"Microsoft.VSTS.Common.Activity","value":""} + MakeRequired: "makeRequired", + // Make the target field read-only. Example : {"actionType":"$makeReadOnly","targetField":"Microsoft.VSTS.Common.Activity","value":""} + MakeReadOnly: "makeReadOnly", + // Set a default value on the target field. This is used if the user creates a integer/string field and sets a default value of this field. + SetDefaultValue: "setDefaultValue", + // Set the default value on the target field from server clock. This is used if user creates the field like Date/Time and uses default value. + SetDefaultFromClock: "setDefaultFromClock", + // Set the default current user value on the target field. This is used if the user creates the field of type identity and uses default value. + SetDefaultFromCurrentUser: "setDefaultFromCurrentUser", + // Set the default value on from existing field to the target field. This used wants to set a existing field value to the current field. + SetDefaultFromField: "setDefaultFromField", + // Set the value of target field to given value. Example : {actionType: "$copyValue", targetField: "ScrumInherited.mypicklist", value: "samplevalue"} + CopyValue: "copyValue", + // Set the value from clock. + CopyFromClock: "copyFromClock", + // Set the current user to the target field. Example : {"actionType":"$copyFromCurrentUser","targetField":"System.AssignedTo","value":""}. + CopyFromCurrentUser: "copyFromCurrentUser", + // Copy the value from a specified field and set to target field. Example : {actionType: "$copyFromField", targetField: "System.AssignedTo", value:"System.ChangedBy"}. Here, value is copied from "System.ChangedBy" and set to "System.AssingedTo" field. + CopyFromField: "copyFromField", + // Set the value of the target field to empty. + SetValueToEmpty: "setValueToEmpty", + // Use the current time to set the value of the target field. Example : {actionType: "$copyFromServerClock", targetField: "System.CreatedDate", value: ""} + CopyFromServerClock: "copyFromServerClock", + // Use the current user to set the value of the target field. + CopyFromServerCurrentUser: "copyFromServerCurrentUser", +} + +// Defines a condition on a field when the rule should be triggered. +type RuleCondition struct { + // Type of condition. $When. This condition limits the execution of its children to cases when another field has a particular value, i.e. when the Is value of the referenced field is equal to the given literal value. $WhenNot.This condition limits the execution of its children to cases when another field does not have a particular value, i.e.when the Is value of the referenced field is not equal to the given literal value. $WhenChanged.This condition limits the execution of its children to cases when another field has changed, i.e.when the Is value of the referenced field is not equal to the Was value of that field. $WhenNotChanged.This condition limits the execution of its children to cases when another field has not changed, i.e.when the Is value of the referenced field is equal to the Was value of that field. + ConditionType *RuleConditionType `json:"conditionType,omitempty"` + // Field that defines condition. + Field *string `json:"field,omitempty"` + // Value of field to define the condition for rule. + Value *string `json:"value,omitempty"` +} + +type RuleConditionModel struct { + ConditionType *string `json:"conditionType,omitempty"` + Field *string `json:"field,omitempty"` + Value *string `json:"value,omitempty"` +} + +// Type of rule condition. +type RuleConditionType string + +type ruleConditionTypeValuesType struct { + When RuleConditionType + WhenNot RuleConditionType + WhenChanged RuleConditionType + WhenNotChanged RuleConditionType + WhenWas RuleConditionType + WhenStateChangedTo RuleConditionType + WhenStateChangedFromAndTo RuleConditionType + WhenWorkItemIsCreated RuleConditionType + WhenValueIsDefined RuleConditionType + WhenValueIsNotDefined RuleConditionType +} + +var RuleConditionTypeValues = ruleConditionTypeValuesType{ + // $When. This condition limits the execution of its children to cases when another field has a particular value, i.e. when the Is value of the referenced field is equal to the given literal value. + When: "when", + // $WhenNot.This condition limits the execution of its children to cases when another field does not have a particular value, i.e.when the Is value of the referenced field is not equal to the given literal value. + WhenNot: "whenNot", + // $WhenChanged.This condition limits the execution of its children to cases when another field has changed, i.e.when the Is value of the referenced field is not equal to the Was value of that field. + WhenChanged: "whenChanged", + // $WhenNotChanged.This condition limits the execution of its children to cases when another field has not changed, i.e.when the Is value of the referenced field is equal to the Was value of that field. + WhenNotChanged: "whenNotChanged", + WhenWas: "whenWas", + WhenStateChangedTo: "whenStateChangedTo", + WhenStateChangedFromAndTo: "whenStateChangedFromAndTo", + WhenWorkItemIsCreated: "whenWorkItemIsCreated", + WhenValueIsDefined: "whenValueIsDefined", + WhenValueIsNotDefined: "whenValueIsNotDefined", +} + +// Defines a section of the work item form layout +type Section struct { + // List of child groups in this section + Groups *[]Group `json:"groups,omitempty"` + // The id for the layout node. + Id *string `json:"id,omitempty"` + // A value indicating whether this layout node has been overridden by a child layout. + Overridden *bool `json:"overridden,omitempty"` +} + +// Describes a request to update a process +type UpdateProcessModel struct { + // New description of the process + Description *string `json:"description,omitempty"` + // If true new projects will use this process by default + IsDefault *bool `json:"isDefault,omitempty"` + // If false the process will be disabled and cannot be used to create projects + IsEnabled *bool `json:"isEnabled,omitempty"` + // New name of the process + Name *string `json:"name,omitempty"` +} + +// Request class/object to update the rule. +type UpdateProcessRuleRequest struct { + // List of actions to take when the rule is triggered. + Actions *[]RuleAction `json:"actions,omitempty"` + // List of conditions when the rule should be triggered. + Conditions *[]RuleCondition `json:"conditions,omitempty"` + // Indicates if the rule is disabled. + IsDisabled *bool `json:"isDisabled,omitempty"` + // Name for the rule. + Name *string `json:"name,omitempty"` + // Id to uniquely identify the rule. + Id *uuid.UUID `json:"id,omitempty"` +} + +// Class to describe a request that updates a field's properties in a work item type. +type UpdateProcessWorkItemTypeFieldRequest struct { + // Allow setting field value to a group identity. Only applies to identity fields. + AllowGroups *bool `json:"allowGroups,omitempty"` + // The default value of the field. + DefaultValue interface{} `json:"defaultValue,omitempty"` + // If true the field cannot be edited. + ReadOnly *bool `json:"readOnly,omitempty"` + // The default value of the field. + Required *bool `json:"required,omitempty"` +} + +// Class for update request on a work item type +type UpdateProcessWorkItemTypeRequest struct { + // Color of the work item type + Color *string `json:"color,omitempty"` + // Description of the work item type + Description *string `json:"description,omitempty"` + // Icon of the work item type + Icon *string `json:"icon,omitempty"` + // If set will disable the work item type + IsDisabled *bool `json:"isDisabled,omitempty"` +} + +// Properties of a work item form contribution +type WitContribution struct { + // The id for the contribution. + ContributionId *string `json:"contributionId,omitempty"` + // The height for the contribution. + Height *int `json:"height,omitempty"` + // A dictionary holding key value pairs for contribution inputs. + Inputs *map[string]interface{} `json:"inputs,omitempty"` + // A value indicating if the contribution should be show on deleted workItem. + ShowOnDeletedWorkItem *bool `json:"showOnDeletedWorkItem,omitempty"` +} + +type WorkItemBehavior struct { + Abstract *bool `json:"abstract,omitempty"` + Color *string `json:"color,omitempty"` + Description *string `json:"description,omitempty"` + Fields *[]WorkItemBehaviorField `json:"fields,omitempty"` + Id *string `json:"id,omitempty"` + Inherits *WorkItemBehaviorReference `json:"inherits,omitempty"` + Name *string `json:"name,omitempty"` + Overriden *bool `json:"overriden,omitempty"` + Rank *int `json:"rank,omitempty"` + Url *string `json:"url,omitempty"` +} + +type WorkItemBehaviorField struct { + BehaviorFieldId *string `json:"behaviorFieldId,omitempty"` + Id *string `json:"id,omitempty"` + Url *string `json:"url,omitempty"` +} + +// Reference to the behavior of a work item type. +type WorkItemBehaviorReference struct { + // The ID of the reference behavior. + Id *string `json:"id,omitempty"` + // The url of the reference behavior. + Url *string `json:"url,omitempty"` +} + +// Class That represents a work item state input. +type WorkItemStateInputModel struct { + // Color of the state + Color *string `json:"color,omitempty"` + // Name of the state + Name *string `json:"name,omitempty"` + // Order in which state should appear + Order *int `json:"order,omitempty"` + // Category of the state + StateCategory *string `json:"stateCategory,omitempty"` +} + +// Class that represents a work item state result. +type WorkItemStateResultModel struct { + // Work item state color. + Color *string `json:"color,omitempty"` + // Work item state customization type. + CustomizationType *CustomizationType `json:"customizationType,omitempty"` + // If the Work item state is hidden. + Hidden *bool `json:"hidden,omitempty"` + // Id of the Workitemstate. + Id *uuid.UUID `json:"id,omitempty"` + // Work item state name. + Name *string `json:"name,omitempty"` + // Work item state order. + Order *int `json:"order,omitempty"` + // Work item state statecategory. + StateCategory *string `json:"stateCategory,omitempty"` + // Work item state url. + Url *string `json:"url,omitempty"` +} + +// Association between a work item type and it's behavior +type WorkItemTypeBehavior struct { + // Reference to the behavior of a work item type + Behavior *WorkItemBehaviorReference `json:"behavior,omitempty"` + // If true the work item type is the default work item type in the behavior + IsDefault *bool `json:"isDefault,omitempty"` + // URL of the work item type behavior + Url *string `json:"url,omitempty"` +} + +type WorkItemTypeClass string + +type workItemTypeClassValuesType struct { + System WorkItemTypeClass + Derived WorkItemTypeClass + Custom WorkItemTypeClass +} + +var WorkItemTypeClassValues = workItemTypeClassValuesType{ + System: "system", + Derived: "derived", + Custom: "custom", +} + +type WorkItemTypeModel struct { + Behaviors *[]WorkItemTypeBehavior `json:"behaviors,omitempty"` + Class *WorkItemTypeClass `json:"class,omitempty"` + Color *string `json:"color,omitempty"` + Description *string `json:"description,omitempty"` + Icon *string `json:"icon,omitempty"` + Id *string `json:"id,omitempty"` + // Parent WIT Id/Internal ReferenceName that it inherits from + Inherits *string `json:"inherits,omitempty"` + IsDisabled *bool `json:"isDisabled,omitempty"` + Layout *FormLayout `json:"layout,omitempty"` + Name *string `json:"name,omitempty"` + States *[]WorkItemStateResultModel `json:"states,omitempty"` + Url *string `json:"url,omitempty"` +} diff --git a/azuredevops/workitemtrackingprocesstemplate/client.go b/azuredevops/workitemtrackingprocesstemplate/client.go new file mode 100644 index 00000000..32ebed67 --- /dev/null +++ b/azuredevops/workitemtrackingprocesstemplate/client.go @@ -0,0 +1,191 @@ +// -------------------------------------------------------------------------------------------- +// 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 workitemtrackingprocesstemplate + +import ( + "context" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "io" + "net/http" + "net/url" + "strconv" +) + +var ResourceAreaId, _ = uuid.Parse("5264459e-e5e0-4bd8-b118-0985e68a4ec5") + +type Client interface { + // [Preview API] Returns requested process template. + ExportProcessTemplate(context.Context, ExportProcessTemplateArgs) (io.ReadCloser, error) + // [Preview API] Returns a behavior for the process. + GetBehavior(context.Context, GetBehaviorArgs) (*AdminBehavior, error) + // [Preview API] Returns a list of behaviors for the process. + GetBehaviors(context.Context, GetBehaviorsArgs) (*[]AdminBehavior, error) + // [Preview API] Imports a process from zip file. + ImportProcessTemplate(context.Context, ImportProcessTemplateArgs) (*ProcessImportResult, error) + // [Preview API] Tells whether promote has completed for the specified promote job ID. + ImportProcessTemplateStatus(context.Context, ImportProcessTemplateStatusArgs) (*ProcessPromoteStatus, 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] Returns requested process template. +func (client *ClientImpl) ExportProcessTemplate(ctx context.Context, args ExportProcessTemplateArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = (*args.Id).String() + routeValues["action"] = "Export" + + locationId, _ := uuid.Parse("29e1f38d-9e9c-4358-86a5-cdf9896a5759") + 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 ExportProcessTemplate function +type ExportProcessTemplateArgs struct { + // (required) The ID of the process + Id *uuid.UUID +} + +// [Preview API] Returns a behavior for the process. +func (client *ClientImpl) GetBehavior(ctx context.Context, args GetBehaviorArgs) (*AdminBehavior, error) { + routeValues := make(map[string]string) + if args.ProcessId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ProcessId"} + } + routeValues["processId"] = (*args.ProcessId).String() + + queryParams := url.Values{} + if args.BehaviorRefName == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "behaviorRefName"} + } + queryParams.Add("behaviorRefName", *args.BehaviorRefName) + locationId, _ := uuid.Parse("90bf9317-3571-487b-bc8c-a523ba0e05d7") + 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 AdminBehavior + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBehavior function +type GetBehaviorArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID + // (required) The reference name of the behavior + BehaviorRefName *string +} + +// [Preview API] Returns a list of behaviors for the process. +func (client *ClientImpl) GetBehaviors(ctx context.Context, args GetBehaviorsArgs) (*[]AdminBehavior, 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("90bf9317-3571-487b-bc8c-a523ba0e05d7") + 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 []AdminBehavior + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetBehaviors function +type GetBehaviorsArgs struct { + // (required) The ID of the process + ProcessId *uuid.UUID +} + +// [Preview API] Imports a process from zip file. +func (client *ClientImpl) ImportProcessTemplate(ctx context.Context, args ImportProcessTemplateArgs) (*ProcessImportResult, error) { + if args.UploadStream == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.UploadStream"} + } + routeValues := make(map[string]string) + routeValues["action"] = "Import" + + queryParams := url.Values{} + if args.IgnoreWarnings != nil { + queryParams.Add("ignoreWarnings", strconv.FormatBool(*args.IgnoreWarnings)) + } + if args.ReplaceExistingTemplate != nil { + queryParams.Add("replaceExistingTemplate", strconv.FormatBool(*args.ReplaceExistingTemplate)) + } + locationId, _ := uuid.Parse("29e1f38d-9e9c-4358-86a5-cdf9896a5759") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, queryParams, args.UploadStream, "application/octet-stream", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ProcessImportResult + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ImportProcessTemplate function +type ImportProcessTemplateArgs struct { + // (required) Stream to upload + UploadStream io.Reader + // (optional) Ignores validation warnings. Default value is false. + IgnoreWarnings *bool + // (optional) Replaces the existing template. Default value is true. + ReplaceExistingTemplate *bool +} + +// [Preview API] Tells whether promote has completed for the specified promote job ID. +func (client *ClientImpl) ImportProcessTemplateStatus(ctx context.Context, args ImportProcessTemplateStatusArgs) (*ProcessPromoteStatus, error) { + routeValues := make(map[string]string) + if args.Id == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Id"} + } + routeValues["id"] = (*args.Id).String() + routeValues["action"] = "Status" + + locationId, _ := uuid.Parse("29e1f38d-9e9c-4358-86a5-cdf9896a5759") + 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 ProcessPromoteStatus + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the ImportProcessTemplateStatus function +type ImportProcessTemplateStatusArgs struct { + // (required) The ID of the promote job operation + Id *uuid.UUID +} diff --git a/azuredevops/workitemtrackingprocesstemplate/models.go b/azuredevops/workitemtrackingprocesstemplate/models.go new file mode 100644 index 00000000..fb3a7bd5 --- /dev/null +++ b/azuredevops/workitemtrackingprocesstemplate/models.go @@ -0,0 +1,111 @@ +// -------------------------------------------------------------------------------------------- +// 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 workitemtrackingprocesstemplate + +import ( + "github.com/google/uuid" +) + +// Describes an admin behavior for a process. +type AdminBehavior struct { + // Is the behavior abstract (i.e. can not be associated with any work item type). + Abstract *bool `json:"abstract,omitempty"` + // The color associated with the behavior. + Color *string `json:"color,omitempty"` + // Indicates if the behavior is custom. + Custom *bool `json:"custom,omitempty"` + // The description of the behavior. + Description *string `json:"description,omitempty"` + // List of behavior fields. + Fields *[]AdminBehaviorField `json:"fields,omitempty"` + // Behavior ID. + Id *string `json:"id,omitempty"` + // Parent behavior reference. + Inherits *string `json:"inherits,omitempty"` + // The behavior name. + Name *string `json:"name,omitempty"` + // Is the behavior overrides a behavior from system process. + Overriden *bool `json:"overriden,omitempty"` + // The rank. + Rank *int `json:"rank,omitempty"` +} + +// Describes an admin behavior field. +type AdminBehaviorField struct { + // The behavior field identifier. + BehaviorFieldId *string `json:"behaviorFieldId,omitempty"` + // The behavior ID. + Id *string `json:"id,omitempty"` + // The behavior name. + Name *string `json:"name,omitempty"` +} + +// Describes result of a check template existence request. +type CheckTemplateExistenceResult struct { + // Indicates whether a template exists. + DoesTemplateExist *bool `json:"doesTemplateExist,omitempty"` + // The name of the existing template. + ExistingTemplateName *string `json:"existingTemplateName,omitempty"` + // The existing template type identifier. + ExistingTemplateTypeId *uuid.UUID `json:"existingTemplateTypeId,omitempty"` + // The name of the requested template. + RequestedTemplateName *string `json:"requestedTemplateName,omitempty"` +} + +// Describes the result of a Process Import request. +type ProcessImportResult struct { + // Check template existence result. + CheckExistenceResult *CheckTemplateExistenceResult `json:"checkExistenceResult,omitempty"` + // Help URL. + HelpUrl *string `json:"helpUrl,omitempty"` + // ID of the import operation. + Id *uuid.UUID `json:"id,omitempty"` + // Whether this imported process is new. + IsNew *bool `json:"isNew,omitempty"` + // The promote job identifier. + PromoteJobId *uuid.UUID `json:"promoteJobId,omitempty"` + // The list of validation results. + ValidationResults *[]ValidationIssue `json:"validationResults,omitempty"` +} + +// Describes result of process operation promote. +type ProcessPromoteStatus struct { + // Number of projects for which promote is complete. + Complete *int `json:"complete,omitempty"` + // ID of the promote operation. + Id *uuid.UUID `json:"id,omitempty"` + // The error message associated with the promote operation. The string will be empty if there are no errors. + Message *string `json:"message,omitempty"` + // Number of projects for which promote is pending. + Pending *int `json:"pending,omitempty"` + // The remaining retries. + RemainingRetries *int `json:"remainingRetries,omitempty"` + // True if promote finished all the projects successfully. False if still in progress or any project promote failed. + Successful *bool `json:"successful,omitempty"` +} + +type ValidationIssue struct { + Description *string `json:"description,omitempty"` + File *string `json:"file,omitempty"` + HelpLink *string `json:"helpLink,omitempty"` + IssueType *ValidationIssueType `json:"issueType,omitempty"` + Line *int `json:"line,omitempty"` +} + +type ValidationIssueType string + +type validationIssueTypeValuesType struct { + Warning ValidationIssueType + Error ValidationIssueType +} + +var ValidationIssueTypeValues = validationIssueTypeValuesType{ + Warning: "warning", + Error: "error", +}