├── .gitattributes ├── .github └── workflows │ └── go.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SECURITY.md ├── SUPPORT.md ├── azure-pipelines.yml └── azuredevops ├── accounts ├── client.go └── models.go ├── audit ├── client.go └── models.go ├── build ├── client.go └── models.go ├── cix ├── client.go └── models.go ├── client.go ├── clientTrace ├── client.go └── models.go ├── client_options.go ├── client_test.go ├── cloudloadtest └── client.go ├── commerce └── models.go ├── connection.go ├── contributions ├── client.go └── models.go ├── core ├── client.go └── models.go ├── customerintelligence ├── client.go └── models.go ├── dashboard ├── client.go └── models.go ├── delegatedauthorization └── models.go ├── distributedtaskcommon └── models.go ├── errors.go ├── extensionmanagement ├── client.go └── models.go ├── featureavailability ├── client.go └── models.go ├── featuremanagement ├── client.go └── models.go ├── feed ├── client.go └── models.go ├── feedtoken ├── client.go └── models.go ├── filecontainer ├── client.go └── models.go ├── forminput └── models.go ├── gallery ├── client.go └── models.go ├── git ├── client.go └── models.go ├── go.mod ├── go.sum ├── graph ├── client.go └── models.go ├── identity ├── client.go └── models.go ├── licensing └── models.go ├── licensingrule └── models.go ├── location ├── client.go └── models.go ├── maven ├── client.go └── models.go ├── memberentitlementmanagement ├── client.go └── models.go ├── models.go ├── models_test.go ├── notification ├── client.go └── models.go ├── npm ├── client.go └── models.go ├── nuget ├── client.go └── models.go ├── operations ├── client.go └── models.go ├── packagingshared └── models.go ├── pipelinepermissions ├── client.go └── models.go ├── pipelines ├── client.go └── models.go ├── pipelineschecks ├── client.go └── models.go ├── policy ├── client.go └── models.go ├── profile ├── client.go └── models.go ├── profileregions ├── client.go └── models.go ├── projectanalysis ├── client.go └── models.go ├── provenance ├── client.go └── models.go ├── pypiapi ├── client.go └── models.go ├── release ├── client.go └── models.go ├── search ├── client.go └── models.go ├── searchshared └── models.go ├── security ├── client.go └── models.go ├── serviceendpoint ├── client.go └── models.go ├── servicehooks ├── client.go └── models.go ├── settings └── client.go ├── symbol ├── client.go └── models.go ├── symbolcommon └── models.go ├── system └── models.go ├── task ├── client.go └── models.go ├── taskagent ├── client.go └── models.go ├── test ├── client.go └── models.go ├── testplan ├── client.go └── models.go ├── testresults ├── client.go └── models.go ├── testservice └── models.go ├── tfvc └── client.go ├── tokenadmin ├── client.go └── models.go ├── tokenadministration ├── client.go └── models.go ├── universal ├── client.go └── models.go ├── upackpackaging ├── client.go └── models.go ├── v6 ├── accounts │ ├── client.go │ └── models.go ├── aexlicensingrule │ └── models.go ├── analytics │ ├── client.go │ └── models.go ├── audit │ ├── client.go │ └── models.go ├── build │ ├── client.go │ └── models.go ├── cix │ ├── client.go │ └── models.go ├── client.go ├── clientTrace │ ├── client.go │ └── models.go ├── client_options.go ├── client_test.go ├── cloudloadtest │ └── client.go ├── comments │ └── models.go ├── commerce │ └── models.go ├── connection.go ├── contributions │ ├── client.go │ └── models.go ├── core │ ├── client.go │ └── models.go ├── customerintelligence │ ├── client.go │ └── models.go ├── dashboard │ ├── client.go │ └── models.go ├── delegatedauthorization │ └── models.go ├── distributedtaskcommon │ └── models.go ├── errors.go ├── extensionmanagement │ ├── client.go │ └── models.go ├── featureavailability │ ├── client.go │ └── models.go ├── featuremanagement │ ├── client.go │ └── models.go ├── feed │ ├── client.go │ └── models.go ├── feedtoken │ ├── client.go │ └── models.go ├── filecontainer │ ├── client.go │ └── models.go ├── forminput │ └── models.go ├── gallery │ ├── client.go │ └── models.go ├── git │ ├── client.go │ └── models.go ├── go.mod ├── go.sum ├── graph │ ├── client.go │ └── models.go ├── identity │ ├── client.go │ └── models.go ├── licensing │ └── models.go ├── licensingrule │ └── models.go ├── location │ ├── client.go │ └── models.go ├── maven │ ├── client.go │ └── models.go ├── memberentitlementmanagement │ ├── client.go │ └── models.go ├── models.go ├── models_test.go ├── notification │ ├── client.go │ └── models.go ├── npm │ ├── client.go │ └── models.go ├── nuget │ ├── client.go │ └── models.go ├── operations │ ├── client.go │ └── models.go ├── packagingshared │ └── models.go ├── pipelinepermissions │ ├── client.go │ └── models.go ├── pipelines │ ├── client.go │ └── models.go ├── pipelinesapproval │ └── models.go ├── pipelineschecks │ ├── client.go │ └── models.go ├── pipelinestaskcheck │ └── models.go ├── policy │ ├── client.go │ └── models.go ├── profile │ ├── client.go │ └── models.go ├── profileregions │ ├── client.go │ └── models.go ├── projectanalysis │ ├── client.go │ └── models.go ├── provenance │ ├── client.go │ └── models.go ├── pypiapi │ ├── client.go │ └── models.go ├── release │ ├── client.go │ └── models.go ├── search │ ├── client.go │ └── models.go ├── searchshared │ └── models.go ├── security │ ├── client.go │ └── models.go ├── serviceendpoint │ ├── client.go │ └── models.go ├── servicehooks │ ├── client.go │ └── models.go ├── settings │ └── client.go ├── symbol │ ├── client.go │ └── models.go ├── symbolcommon │ └── models.go ├── system │ └── models.go ├── task │ ├── client.go │ └── models.go ├── taskagent │ ├── client.go │ └── models.go ├── test │ ├── client.go │ └── models.go ├── testplan │ ├── client.go │ └── models.go ├── testresults │ ├── client.go │ └── models.go ├── testservice │ └── models.go ├── tfvc │ └── client.go ├── tokenadmin │ ├── client.go │ └── models.go ├── tokenadministration │ ├── client.go │ └── models.go ├── universal │ ├── client.go │ └── models.go ├── upackpackaging │ ├── client.go │ └── models.go ├── version.go ├── versionnegotiation.go ├── versionnegotiation_test.go ├── webapi │ └── models.go ├── wiki │ ├── client.go │ └── models.go ├── work │ ├── client.go │ └── models.go ├── workitemtracking │ ├── client.go │ └── models.go ├── workitemtrackingprocess │ ├── client.go │ └── models.go └── workitemtrackingprocesstemplate │ ├── client.go │ └── models.go ├── v7 ├── accounts │ ├── client.go │ └── models.go ├── aexlicensingrule │ └── models.go ├── analytics │ ├── client.go │ └── models.go ├── audit │ ├── client.go │ └── models.go ├── build │ ├── client.go │ └── models.go ├── cix │ ├── client.go │ └── models.go ├── client.go ├── client_options.go ├── client_test.go ├── clienttrace │ ├── client.go │ └── models.go ├── comments │ └── models.go ├── commerce │ └── models.go ├── connection.go ├── contributions │ ├── client.go │ └── models.go ├── core │ ├── client.go │ └── models.go ├── customerintelligence │ ├── client.go │ └── models.go ├── dashboard │ ├── client.go │ └── models.go ├── delegatedauthorization │ └── models.go ├── distributedtaskcommon │ └── models.go ├── elastic │ ├── client.go │ └── models.go ├── errors.go ├── extensionmanagement │ ├── client.go │ └── models.go ├── featureavailability │ ├── client.go │ └── models.go ├── featuremanagement │ ├── client.go │ └── models.go ├── feed │ ├── client.go │ └── models.go ├── filecontainer │ ├── client.go │ └── models.go ├── forminput │ └── models.go ├── gallery │ ├── client.go │ └── models.go ├── git │ ├── client.go │ └── models.go ├── go.mod ├── go.sum ├── graph │ ├── client.go │ └── models.go ├── identity │ ├── client.go │ └── models.go ├── licensing │ └── models.go ├── licensingrule │ └── models.go ├── location │ ├── client.go │ └── models.go ├── maven │ ├── client.go │ └── models.go ├── memberentitlementmanagement │ ├── client.go │ └── models.go ├── models.go ├── models_test.go ├── notification │ ├── client.go │ └── models.go ├── npm │ ├── client.go │ └── models.go ├── nuget │ ├── client.go │ └── models.go ├── operations │ ├── client.go │ └── models.go ├── packagingshared │ └── models.go ├── pipelinepermissions │ ├── client.go │ └── models.go ├── pipelines │ ├── client.go │ └── models.go ├── pipelinesapproval │ ├── client.go │ └── models.go ├── pipelineschecks │ ├── client.go │ └── models.go ├── pipelinestaskcheck │ └── models.go ├── policy │ ├── client.go │ └── models.go ├── profile │ ├── client.go │ └── models.go ├── profileregions │ ├── client.go │ └── models.go ├── projectanalysis │ ├── client.go │ └── models.go ├── provenance │ ├── client.go │ └── models.go ├── pypiapi │ ├── client.go │ └── models.go ├── release │ ├── client.go │ └── models.go ├── search │ ├── client.go │ └── models.go ├── searchshared │ └── models.go ├── security │ ├── client.go │ └── models.go ├── serviceendpoint │ ├── client.go │ └── models.go ├── servicehooks │ ├── client.go │ └── models.go ├── settings │ └── client.go ├── symbol │ ├── client.go │ └── models.go ├── symbolcommon │ └── models.go ├── system │ └── models.go ├── task │ ├── client.go │ └── models.go ├── taskagent │ ├── client.go │ └── models.go ├── test │ ├── client.go │ └── models.go ├── testplan │ ├── client.go │ └── models.go ├── testresults │ ├── client.go │ └── models.go ├── tfvc │ └── client.go ├── tokenadmin │ ├── client.go │ └── models.go ├── universal │ ├── client.go │ └── models.go ├── upackpackaging │ ├── client.go │ └── models.go ├── version.go ├── versionnegotiation.go ├── versionnegotiation_test.go ├── webapi │ └── models.go ├── wiki │ ├── client.go │ └── models.go ├── work │ ├── client.go │ └── models.go ├── workitemtracking │ ├── client.go │ └── models.go ├── workitemtrackingprocess │ ├── client.go │ └── models.go └── workitemtrackingprocesstemplate │ ├── client.go │ └── models.go ├── version.go ├── versionnegotiation.go ├── versionnegotiation_test.go ├── webapi └── models.go ├── wiki ├── client.go └── models.go ├── work ├── client.go └── models.go ├── workitemtracking ├── client.go └── models.go ├── workitemtrackingprocess ├── client.go └── models.go └── workitemtrackingprocesstemplate ├── client.go └── models.go /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior (used when a rule below doesn't match) 2 | * text=auto 3 | 4 | # Go files 5 | *.go text eol=lf 6 | *.mod text eol=lf 7 | *.sum text eol=lf 8 | 9 | # Some Windows-specific files should always be CRLF 10 | *.bat text eol=crlf 11 | 12 | # Shell scripts 13 | *.sh text eol=lf 14 | -------------------------------------------------------------------------------- /.github/workflows/go.yml: -------------------------------------------------------------------------------- 1 | name: Go 2 | on: [push] 3 | jobs: 4 | 5 | build: 6 | name: Build 7 | runs-on: ubuntu-latest 8 | strategy: 9 | matrix: 10 | go: [ '1.13', '1.14', '1.18' ] 11 | dir: [ './azuredevops', './azuredevops/v6', './azuredevops/v7'] 12 | steps: 13 | - name: Check out code into the Go module directory 14 | uses: actions/checkout@v2 15 | 16 | - name: Setup go 17 | uses: actions/setup-go@v2 18 | with: 19 | go-version: ${{ matrix.go }} 20 | id: go 21 | 22 | - name: Get dependencies 23 | working-directory: ${{ matrix.dir }} 24 | run: go get github.com/google/uuid 25 | 26 | - name: go build 27 | working-directory: ${{ matrix.dir }} 28 | run: go build -v ./... 29 | 30 | - name: go fmt 31 | working-directory: ${{ matrix.dir }} 32 | run: go fmt ./... 33 | 34 | - name: go vet 35 | working-directory: ${{ matrix.dir }} 36 | run: go vet ./... 37 | 38 | - name: go test 39 | working-directory: ${{ matrix.dir }} 40 | run: go test ./... 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | .idea/ 15 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Support 2 | ## How to file issues and get help 3 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new Issue. 4 | 5 | ## Microsoft Support Policy 6 | Support for Azure DevOps Go API is limited to the resources listed above. -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # This Yaml Document has been converted by ESAI Yaml Pipeline Conversion Tool. 2 | # Please make sure to check all the converted content, it is your team's responsibility to make sure that the pipeline is still valid and functions as expected. 3 | # This pipeline will be extended to the MicroBuild template 4 | trigger: 5 | - dev 6 | schedules: 7 | - cron: "0 2 15 * *" 8 | displayName: "Monthly Run" 9 | branches: 10 | include: 11 | - dev 12 | always: true 13 | resources: 14 | repositories: 15 | - repository: MicroBuildTemplate 16 | type: git 17 | name: 1ESPipelineTemplates/MicroBuildTemplate 18 | ref: refs/tags/release 19 | extends: 20 | template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate 21 | parameters: 22 | sdl: 23 | sourceAnalysisPool: 1ESPtTfsAgentBuildPoolSDL 24 | pool: 25 | name: Azure-Pipelines-1ESPT-ExDShared 26 | customBuildTags: 27 | - ES365AIMigrationTooling 28 | stages: 29 | - stage: stage 30 | jobs: 31 | - job: job 32 | pool: 33 | name: 1ES-Shared-Hosted-Pool_Linux-Mariner-2 34 | os: linux 35 | vmImage: 'ubuntu-latest' 36 | steps: 37 | - task: GoTool@0 38 | inputs: 39 | version: '1.13.5' 40 | - task: Go@0 41 | inputs: 42 | command: 'get' 43 | arguments: '-d' 44 | workingDirectory: '$(System.DefaultWorkingDirectory)/azuredevops' 45 | - task: Go@0 46 | inputs: 47 | command: 'clean' 48 | workingDirectory: '$(System.DefaultWorkingDirectory)/azuredevops' 49 | - task: Go@0 50 | inputs: 51 | command: 'build' 52 | workingDirectory: '$(System.DefaultWorkingDirectory)/azuredevops' 53 | -------------------------------------------------------------------------------- /azuredevops/accounts/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package accounts 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops" 15 | "net/http" 16 | "net/url" 17 | ) 18 | 19 | var ResourceAreaId, _ = uuid.Parse("0d55247a-1c47-4462-9b1f-5e2125590ee6") 20 | 21 | type Client interface { 22 | // Get a list of accounts for a specific owner or a specific member. 23 | GetAccounts(context.Context, GetAccountsArgs) (*[]Account, error) 24 | } 25 | 26 | type ClientImpl struct { 27 | Client azuredevops.Client 28 | } 29 | 30 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 31 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 32 | if err != nil { 33 | return nil, err 34 | } 35 | return &ClientImpl{ 36 | Client: *client, 37 | }, nil 38 | } 39 | 40 | // Get a list of accounts for a specific owner or a specific member. 41 | func (client *ClientImpl) GetAccounts(ctx context.Context, args GetAccountsArgs) (*[]Account, error) { 42 | queryParams := url.Values{} 43 | if args.OwnerId != nil { 44 | queryParams.Add("ownerId", (*args.OwnerId).String()) 45 | } 46 | if args.MemberId != nil { 47 | queryParams.Add("memberId", (*args.MemberId).String()) 48 | } 49 | if args.Properties != nil { 50 | queryParams.Add("properties", *args.Properties) 51 | } 52 | locationId, _ := uuid.Parse("229a6a53-b428-4ffb-a835-e8f36b5b4b1e") 53 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil) 54 | if err != nil { 55 | return nil, err 56 | } 57 | 58 | var responseValue []Account 59 | err = client.Client.UnmarshalCollectionBody(resp, &responseValue) 60 | return &responseValue, err 61 | } 62 | 63 | // Arguments for the GetAccounts function 64 | type GetAccountsArgs struct { 65 | // (optional) ID for the owner of the accounts. 66 | OwnerId *uuid.UUID 67 | // (optional) ID for a member of the accounts. 68 | MemberId *uuid.UUID 69 | // (optional) 70 | Properties *string 71 | } 72 | -------------------------------------------------------------------------------- /azuredevops/audit/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package audit 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | "github.com/microsoft/azure-devops-go-api/azuredevops" 14 | ) 15 | 16 | // Defines all the categories an AuditAction can be 17 | type AuditActionCategory string 18 | 19 | type auditActionCategoryValuesType struct { 20 | Unknown AuditActionCategory 21 | Modify AuditActionCategory 22 | Remove AuditActionCategory 23 | Create AuditActionCategory 24 | Access AuditActionCategory 25 | } 26 | 27 | var AuditActionCategoryValues = auditActionCategoryValuesType{ 28 | // The category is not known 29 | Unknown: "unknown", 30 | // An artifact has been Modified 31 | Modify: "modify", 32 | // An artifact has been Removed 33 | Remove: "remove", 34 | // An artifact has been Created 35 | Create: "create", 36 | // An artifact has been Accessed 37 | Access: "access", 38 | } 39 | 40 | // The object returned when the audit log is queried. It contains the log and the information needed to query more audit entries. 41 | type AuditLogQueryResult struct { 42 | // The continuation token to pass to get the next set of results 43 | ContinuationToken *string `json:"continuationToken,omitempty"` 44 | // The list of audit log entries 45 | DecoratedAuditLogEntries *[]DecoratedAuditLogEntry `json:"decoratedAuditLogEntries,omitempty"` 46 | // True when there are more matching results to be fetched, false otherwise. 47 | HasMore *bool `json:"hasMore,omitempty"` 48 | } 49 | 50 | type DecoratedAuditLogEntry struct { 51 | // The action if for the event, i.e Git.CreateRepo, Project.RenameProject 52 | ActionId *string `json:"actionId,omitempty"` 53 | // ActivityId 54 | ActivityId *uuid.UUID `json:"activityId,omitempty"` 55 | // The Actor's CUID 56 | ActorCUID *uuid.UUID `json:"actorCUID,omitempty"` 57 | // DisplayName of the user who initiated the action 58 | ActorDisplayName *string `json:"actorDisplayName,omitempty"` 59 | // URL of Actor's Profile image 60 | ActorImageUrl *string `json:"actorImageUrl,omitempty"` 61 | // The Actor's User Id 62 | ActorUserId *uuid.UUID `json:"actorUserId,omitempty"` 63 | // Area of Azure DevOps the action occurred 64 | Area *string `json:"area,omitempty"` 65 | // Type of authentication used by the actor 66 | AuthenticationMechanism *string `json:"authenticationMechanism,omitempty"` 67 | // Type of action executed 68 | Category *AuditActionCategory `json:"category,omitempty"` 69 | // DisplayName of the category 70 | CategoryDisplayName *string `json:"categoryDisplayName,omitempty"` 71 | // 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. 72 | CorrelationId *uuid.UUID `json:"correlationId,omitempty"` 73 | // External data such as CUIDs, item names, etc. 74 | Data *map[string]interface{} `json:"data,omitempty"` 75 | // Decorated details 76 | Details *string `json:"details,omitempty"` 77 | // EventId - Needs to be unique per service 78 | Id *string `json:"id,omitempty"` 79 | // IP Address where the event was originated 80 | IpAddress *string `json:"ipAddress,omitempty"` 81 | // DisplayName of the scope 82 | ScopeDisplayName *string `json:"scopeDisplayName,omitempty"` 83 | // The organization or project Id 84 | ScopeId *uuid.UUID `json:"scopeId,omitempty"` 85 | // The type of the scope, Organization or Project 86 | ScopeType *string `json:"scopeType,omitempty"` 87 | // The time when the event occurred in UTC 88 | Timestamp *azuredevops.Time `json:"timestamp,omitempty"` 89 | // The user agent from the request 90 | UserAgent *string `json:"userAgent,omitempty"` 91 | } 92 | -------------------------------------------------------------------------------- /azuredevops/clientTrace/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package clienttrace 10 | 11 | import ( 12 | "bytes" 13 | "context" 14 | "encoding/json" 15 | "github.com/google/uuid" 16 | "github.com/microsoft/azure-devops-go-api/azuredevops" 17 | "net/http" 18 | ) 19 | 20 | type Client interface { 21 | // [Preview API] 22 | PublishEvents(context.Context, PublishEventsArgs) error 23 | } 24 | 25 | type ClientImpl struct { 26 | Client azuredevops.Client 27 | } 28 | 29 | func NewClient(ctx context.Context, connection *azuredevops.Connection) Client { 30 | client := connection.GetClientByUrl(connection.BaseUrl) 31 | return &ClientImpl{ 32 | Client: *client, 33 | } 34 | } 35 | 36 | // [Preview API] 37 | func (client *ClientImpl) PublishEvents(ctx context.Context, args PublishEventsArgs) error { 38 | if args.Events == nil { 39 | return &azuredevops.ArgumentNilError{ArgumentName: "args.Events"} 40 | } 41 | body, marshalErr := json.Marshal(*args.Events) 42 | if marshalErr != nil { 43 | return marshalErr 44 | } 45 | locationId, _ := uuid.Parse("06bcc74a-1491-4eb8-a0eb-704778f9d041") 46 | _, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) 47 | if err != nil { 48 | return err 49 | } 50 | 51 | return nil 52 | } 53 | 54 | // Arguments for the PublishEvents function 55 | type PublishEventsArgs struct { 56 | // (required) 57 | Events *[]ClientTraceEvent 58 | } 59 | -------------------------------------------------------------------------------- /azuredevops/clientTrace/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package clienttrace 10 | 11 | type ClientTraceEvent struct { 12 | Area *string `json:"area,omitempty"` 13 | Component *string `json:"component,omitempty"` 14 | ExceptionType *string `json:"exceptionType,omitempty"` 15 | Feature *string `json:"feature,omitempty"` 16 | Level *Level `json:"level,omitempty"` 17 | Message *string `json:"message,omitempty"` 18 | Method *string `json:"method,omitempty"` 19 | Properties *map[string]interface{} `json:"properties,omitempty"` 20 | } 21 | 22 | type Level string 23 | 24 | type levelValuesType struct { 25 | Off Level 26 | Error Level 27 | Warning Level 28 | Info Level 29 | Verbose Level 30 | } 31 | 32 | var LevelValues = levelValuesType{ 33 | Off: "off", 34 | Error: "error", 35 | Warning: "warning", 36 | Info: "info", 37 | Verbose: "verbose", 38 | } 39 | -------------------------------------------------------------------------------- /azuredevops/client_options.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | // ClientOptionFunc can be used customize a new AzureDevops API client. 8 | type ClientOptionFunc func(*Client) 9 | 10 | // WithHTTPClient can be used to configure a custom HTTP client. 11 | func WithHTTPClient(httpClient *http.Client) ClientOptionFunc { 12 | return func(c *Client) { 13 | c.client = httpClient 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /azuredevops/client_test.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | import ( 4 | "crypto/tls" 5 | "net/http" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | func TestClient_NewClient(t *testing.T) { 11 | tlsConfig := &tls.Config{} 12 | timeout := 20 * time.Millisecond 13 | 14 | conn := &Connection{ 15 | TlsConfig: tlsConfig, 16 | Timeout: &timeout, 17 | } 18 | baseURL := "localhost" 19 | client := NewClient(conn, baseURL) 20 | if client.baseUrl != baseURL { 21 | t.Errorf("Expected baseURL: %v Actual baseURL: %v", baseURL, client.baseUrl) 22 | } 23 | if actualTLSConfig := client.client.Transport.(*http.Transport).TLSClientConfig; actualTLSConfig != tlsConfig { 24 | t.Errorf("Expected tlsConfig: %v Actual tlsConfig: %v", tlsConfig, actualTLSConfig) 25 | } 26 | } 27 | 28 | func TestClient_NewClientWithOptions_WithHTTPClient(t *testing.T) { 29 | tlsConfig := &tls.Config{} 30 | httpTimeout := 20 * time.Millisecond 31 | connTimeout := 40 * time.Millisecond 32 | 33 | conn := &Connection{ 34 | TlsConfig: tlsConfig, 35 | Timeout: &connTimeout, // will be ignored in favour of httpTimeout 36 | } 37 | 38 | httpClient := &http.Client{Timeout: httpTimeout} 39 | baseURL := "localhost" 40 | 41 | client := NewClientWithOptions(conn, baseURL, WithHTTPClient(httpClient)) 42 | if client.baseUrl != baseURL { 43 | t.Errorf("Expected baseURL: %v Actual baseURL: %v", baseURL, client.baseUrl) 44 | } 45 | if actualHTTPClient := client.client; actualHTTPClient.Timeout != httpClient.Timeout { 46 | t.Errorf("Expected httpClient.Timeout: %#v Actual httpClient.Timeout: %#v", httpClient.Timeout, actualHTTPClient.Timeout) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /azuredevops/customerintelligence/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package customerintelligence 10 | 11 | import ( 12 | "bytes" 13 | "context" 14 | "encoding/json" 15 | "github.com/google/uuid" 16 | "github.com/microsoft/azure-devops-go-api/azuredevops" 17 | "net/http" 18 | ) 19 | 20 | type Client interface { 21 | // [Preview API] 22 | PublishEvents(context.Context, PublishEventsArgs) error 23 | } 24 | 25 | type ClientImpl struct { 26 | Client azuredevops.Client 27 | } 28 | 29 | func NewClient(ctx context.Context, connection *azuredevops.Connection) Client { 30 | client := connection.GetClientByUrl(connection.BaseUrl) 31 | return &ClientImpl{ 32 | Client: *client, 33 | } 34 | } 35 | 36 | // [Preview API] 37 | func (client *ClientImpl) PublishEvents(ctx context.Context, args PublishEventsArgs) error { 38 | if args.Events == nil { 39 | return &azuredevops.ArgumentNilError{ArgumentName: "args.Events"} 40 | } 41 | body, marshalErr := json.Marshal(*args.Events) 42 | if marshalErr != nil { 43 | return marshalErr 44 | } 45 | locationId, _ := uuid.Parse("b5cc35c2-ff2b-491d-a085-24b6e9f396fd") 46 | _, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) 47 | if err != nil { 48 | return err 49 | } 50 | 51 | return nil 52 | } 53 | 54 | // Arguments for the PublishEvents function 55 | type PublishEventsArgs struct { 56 | // (required) 57 | Events *[]CustomerIntelligenceEvent 58 | } 59 | -------------------------------------------------------------------------------- /azuredevops/customerintelligence/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package customerintelligence 10 | 11 | type CustomerIntelligenceEvent struct { 12 | Area *string `json:"area,omitempty"` 13 | Feature *string `json:"feature,omitempty"` 14 | Properties *map[string]interface{} `json:"properties,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /azuredevops/distributedtaskcommon/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package distributedtaskcommon 10 | 11 | type AuthorizationHeader struct { 12 | Name *string `json:"name,omitempty"` 13 | Value *string `json:"value,omitempty"` 14 | } 15 | 16 | // Represents binding of data source for the service endpoint request. 17 | type DataSourceBindingBase struct { 18 | // Pagination format supported by this data source(ContinuationToken/SkipTop). 19 | CallbackContextTemplate *string `json:"callbackContextTemplate,omitempty"` 20 | // Subsequent calls needed? 21 | CallbackRequiredTemplate *string `json:"callbackRequiredTemplate,omitempty"` 22 | // Gets or sets the name of the data source. 23 | DataSourceName *string `json:"dataSourceName,omitempty"` 24 | // Gets or sets the endpoint Id. 25 | EndpointId *string `json:"endpointId,omitempty"` 26 | // Gets or sets the url of the service endpoint. 27 | EndpointUrl *string `json:"endpointUrl,omitempty"` 28 | // Gets or sets the authorization headers. 29 | Headers *[]AuthorizationHeader `json:"headers,omitempty"` 30 | // Defines the initial value of the query params 31 | InitialContextTemplate *string `json:"initialContextTemplate,omitempty"` 32 | // Gets or sets the parameters for the data source. 33 | Parameters *map[string]string `json:"parameters,omitempty"` 34 | // Gets or sets http request body 35 | RequestContent *string `json:"requestContent,omitempty"` 36 | // Gets or sets http request verb 37 | RequestVerb *string `json:"requestVerb,omitempty"` 38 | // Gets or sets the result selector. 39 | ResultSelector *string `json:"resultSelector,omitempty"` 40 | // Gets or sets the result template. 41 | ResultTemplate *string `json:"resultTemplate,omitempty"` 42 | // Gets or sets the target of the data source. 43 | Target *string `json:"target,omitempty"` 44 | } 45 | 46 | type ProcessParameters struct { 47 | DataSourceBindings *[]DataSourceBindingBase `json:"dataSourceBindings,omitempty"` 48 | Inputs *[]TaskInputDefinitionBase `json:"inputs,omitempty"` 49 | SourceDefinitions *[]TaskSourceDefinitionBase `json:"sourceDefinitions,omitempty"` 50 | } 51 | 52 | type TaskInputDefinitionBase struct { 53 | Aliases *[]string `json:"aliases,omitempty"` 54 | DefaultValue *string `json:"defaultValue,omitempty"` 55 | GroupName *string `json:"groupName,omitempty"` 56 | HelpMarkDown *string `json:"helpMarkDown,omitempty"` 57 | Label *string `json:"label,omitempty"` 58 | Name *string `json:"name,omitempty"` 59 | Options *map[string]string `json:"options,omitempty"` 60 | Properties *map[string]string `json:"properties,omitempty"` 61 | Required *bool `json:"required,omitempty"` 62 | Type *string `json:"type,omitempty"` 63 | Validation *TaskInputValidation `json:"validation,omitempty"` 64 | VisibleRule *string `json:"visibleRule,omitempty"` 65 | } 66 | 67 | type TaskInputValidation struct { 68 | // Conditional expression 69 | Expression *string `json:"expression,omitempty"` 70 | // Message explaining how user can correct if validation fails 71 | Message *string `json:"message,omitempty"` 72 | } 73 | 74 | type TaskSourceDefinitionBase struct { 75 | AuthKey *string `json:"authKey,omitempty"` 76 | Endpoint *string `json:"endpoint,omitempty"` 77 | KeySelector *string `json:"keySelector,omitempty"` 78 | Selector *string `json:"selector,omitempty"` 79 | Target *string `json:"target,omitempty"` 80 | } 81 | -------------------------------------------------------------------------------- /azuredevops/errors.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | type ArgumentNilError struct { 4 | ArgumentName string 5 | } 6 | 7 | func (e ArgumentNilError) Error() string { 8 | return "Argument " + e.ArgumentName + " can not be nil" 9 | } 10 | 11 | type ArgumentNilOrEmptyError struct { 12 | ArgumentName string 13 | } 14 | 15 | func (e ArgumentNilOrEmptyError) Error() string { 16 | return "Argument " + e.ArgumentName + " can not be nil or empty" 17 | } 18 | -------------------------------------------------------------------------------- /azuredevops/featureavailability/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package featureavailability 10 | 11 | type FeatureFlag struct { 12 | Description *string `json:"description,omitempty"` 13 | EffectiveState *string `json:"effectiveState,omitempty"` 14 | ExplicitState *string `json:"explicitState,omitempty"` 15 | Name *string `json:"name,omitempty"` 16 | Uri *string `json:"uri,omitempty"` 17 | } 18 | 19 | // This is passed to the FeatureFlagController to edit the status of a feature flag 20 | type FeatureFlagPatch struct { 21 | State *string `json:"state,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /azuredevops/feedtoken/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package feedtoken 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops" 15 | "net/http" 16 | ) 17 | 18 | var ResourceAreaId, _ = uuid.Parse("cdeb6c7d-6b25-4d6f-b664-c2e3ede202e8") 19 | 20 | type Client interface { 21 | // [Preview API] Get a time-limited session token representing the current user, with permissions scoped to the read/write of Artifacts. 22 | GetPersonalAccessToken(context.Context, GetPersonalAccessTokenArgs) (*FeedSessionToken, error) 23 | } 24 | 25 | type ClientImpl struct { 26 | Client azuredevops.Client 27 | } 28 | 29 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 30 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 31 | if err != nil { 32 | return nil, err 33 | } 34 | return &ClientImpl{ 35 | Client: *client, 36 | }, nil 37 | } 38 | 39 | // [Preview API] Get a time-limited session token representing the current user, with permissions scoped to the read/write of Artifacts. 40 | func (client *ClientImpl) GetPersonalAccessToken(ctx context.Context, args GetPersonalAccessTokenArgs) (*FeedSessionToken, error) { 41 | routeValues := make(map[string]string) 42 | if args.FeedName != nil && *args.FeedName != "" { 43 | routeValues["feedName"] = *args.FeedName 44 | } 45 | 46 | locationId, _ := uuid.Parse("dfdb7ad7-3d8e-4907-911e-19b4a8330550") 47 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) 48 | if err != nil { 49 | return nil, err 50 | } 51 | 52 | var responseValue FeedSessionToken 53 | err = client.Client.UnmarshalBody(resp, &responseValue) 54 | return &responseValue, err 55 | } 56 | 57 | // Arguments for the GetPersonalAccessToken function 58 | type GetPersonalAccessTokenArgs struct { 59 | // (optional) 60 | FeedName *string 61 | } 62 | -------------------------------------------------------------------------------- /azuredevops/feedtoken/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package feedtoken 10 | 11 | import ( 12 | "github.com/microsoft/azure-devops-go-api/azuredevops" 13 | ) 14 | 15 | // 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 16 | type FeedSessionToken struct { 17 | Token *string `json:"token,omitempty"` 18 | ValidTo *azuredevops.Time `json:"validTo,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /azuredevops/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/microsoft/azure-devops-go-api/azuredevops 2 | 3 | go 1.12 4 | 5 | require github.com/google/uuid v1.1.1 6 | -------------------------------------------------------------------------------- /azuredevops/go.sum: -------------------------------------------------------------------------------- 1 | github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= 2 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 3 | -------------------------------------------------------------------------------- /azuredevops/models_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | package azuredevops 5 | 6 | import ( 7 | "encoding/json" 8 | "github.com/google/uuid" 9 | "testing" 10 | "time" 11 | ) 12 | 13 | func TestModels_Unmarshal_Time(t *testing.T) { 14 | 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\"}") 15 | testModel := TestModel{} 16 | 17 | testModel.Time1 = &Time{} 18 | testModel.Time1.Time = time.Now() // this ensures we test the value is set back to default when issue #17 is hit. 19 | 20 | err := json.Unmarshal(text, &testModel) 21 | if err != nil { 22 | t.Errorf("Error occurred during deserialization: %v", err) 23 | } 24 | if (testModel.Time1.Time != time.Time{}) { 25 | t.Errorf("Expecting deserialized time to equal default time. Actual time: %v", testModel.Time1) 26 | } 27 | 28 | parsedTime, err := time.Parse(time.RFC3339Nano, "2019-09-01T00:07:26Z") 29 | if err != nil { 30 | t.Errorf(err.Error()) 31 | } 32 | if testModel.Time2.Time != parsedTime { 33 | t.Errorf("Expected time: %v Actual time: %v", parsedTime, testModel.Time2.Time) 34 | } 35 | 36 | // Test workaround for issue #59 https://github.com/microsoft/azure-devops-go-api/issues/59 37 | parsedTime59, err := time.Parse("2006-01-02T15:04:05.999999999", "2020-05-16T20:55:32.0116793") 38 | if testModel.Time3.Time != parsedTime59 { 39 | t.Errorf("Expected time: %v Actual time: %v", parsedTime59, testModel.Time3.Time) 40 | } 41 | } 42 | 43 | func TestModels_Marshal_Unmarshal_Time(t *testing.T) { 44 | testModel1 := TestModel{} 45 | testModel1.Time1 = &Time{} 46 | testModel1.Time1.Time = time.Now() 47 | b, err := json.Marshal(testModel1) 48 | if err != nil { 49 | t.Errorf(err.Error()) 50 | } 51 | 52 | testModel2 := TestModel{} 53 | err = json.Unmarshal(b, &testModel2) 54 | if err != nil { 55 | t.Errorf(err.Error()) 56 | } 57 | 58 | if testModel1.Time1 != testModel1.Time1 { 59 | t.Errorf("Expected time: %v Actual time: %v", testModel1.Time1, testModel1.Time2) 60 | } 61 | 62 | if testModel1.Time1.Time != testModel1.Time1.Time { 63 | t.Errorf("Expected time: %v Actual time: %v", testModel1.Time1.Time, testModel1.Time2.Time) 64 | } 65 | } 66 | 67 | func TestModels_Time_AsQueryParameter(t *testing.T) { 68 | tt := &Time{ 69 | // NOTE: set nsec to 0 to avoid precision loss 70 | Time: time.Date(2006, 1, 2, 3, 4, 5, 0, time.UTC), 71 | } 72 | queryParameterValue := tt.AsQueryParameter() 73 | parsedTime, err := time.Parse(time.RFC3339Nano, queryParameterValue) 74 | if err != nil { 75 | t.Errorf("invalid query parameter %s value for time: %s", tt.Time, queryParameterValue) 76 | } 77 | if !tt.Time.Equal(parsedTime) { 78 | t.Errorf("should convert back to original value: %s %s", tt.Time, parsedTime) 79 | } 80 | } 81 | 82 | type TestModel struct { 83 | Id *uuid.UUID `json:"id,omitempty"` 84 | Time1 *Time `json:"time1,omitempty"` 85 | Time2 *Time `json:"time2,omitempty"` 86 | Time3 *Time `json:"time3,omitempty"` 87 | Int *uint64 `json:"int,omitempty"` 88 | String *string `json:"string,omitempty"` 89 | } 90 | -------------------------------------------------------------------------------- /azuredevops/operations/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package operations 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops" 15 | "net/http" 16 | "net/url" 17 | ) 18 | 19 | type Client interface { 20 | // Gets an operation from the the operationId using the given pluginId. 21 | GetOperation(context.Context, GetOperationArgs) (*Operation, error) 22 | } 23 | 24 | type ClientImpl struct { 25 | Client azuredevops.Client 26 | } 27 | 28 | func NewClient(ctx context.Context, connection *azuredevops.Connection) Client { 29 | client := connection.GetClientByUrl(connection.BaseUrl) 30 | return &ClientImpl{ 31 | Client: *client, 32 | } 33 | } 34 | 35 | // Gets an operation from the the operationId using the given pluginId. 36 | func (client *ClientImpl) GetOperation(ctx context.Context, args GetOperationArgs) (*Operation, error) { 37 | routeValues := make(map[string]string) 38 | if args.OperationId == nil { 39 | return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.OperationId"} 40 | } 41 | routeValues["operationId"] = (*args.OperationId).String() 42 | 43 | queryParams := url.Values{} 44 | if args.PluginId != nil { 45 | queryParams.Add("pluginId", (*args.PluginId).String()) 46 | } 47 | locationId, _ := uuid.Parse("9a1b74b4-2ca8-4a9f-8470-c2f2e6fdc949") 48 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) 49 | if err != nil { 50 | return nil, err 51 | } 52 | 53 | var responseValue Operation 54 | err = client.Client.UnmarshalBody(resp, &responseValue) 55 | return &responseValue, err 56 | } 57 | 58 | // Arguments for the GetOperation function 59 | type GetOperationArgs struct { 60 | // (required) The ID for the operation. 61 | OperationId *uuid.UUID 62 | // (optional) The ID for the plugin. 63 | PluginId *uuid.UUID 64 | } 65 | -------------------------------------------------------------------------------- /azuredevops/operations/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package operations 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | ) 14 | 15 | // Contains information about the progress or result of an async operation. 16 | type Operation struct { 17 | // Unique identifier for the operation. 18 | Id *uuid.UUID `json:"id,omitempty"` 19 | // Unique identifier for the plugin. 20 | PluginId *uuid.UUID `json:"pluginId,omitempty"` 21 | // The current status of the operation. 22 | Status *OperationStatus `json:"status,omitempty"` 23 | // URL to get the full operation object. 24 | Url *string `json:"url,omitempty"` 25 | // Links to other related objects. 26 | Links interface{} `json:"_links,omitempty"` 27 | // Detailed messaged about the status of an operation. 28 | DetailedMessage *string `json:"detailedMessage,omitempty"` 29 | // Result message for an operation. 30 | ResultMessage *string `json:"resultMessage,omitempty"` 31 | // URL to the operation result. 32 | ResultUrl *OperationResultReference `json:"resultUrl,omitempty"` 33 | } 34 | 35 | // Reference for an async operation. 36 | type OperationReference struct { 37 | // Unique identifier for the operation. 38 | Id *uuid.UUID `json:"id,omitempty"` 39 | // Unique identifier for the plugin. 40 | PluginId *uuid.UUID `json:"pluginId,omitempty"` 41 | // The current status of the operation. 42 | Status *OperationStatus `json:"status,omitempty"` 43 | // URL to get the full operation object. 44 | Url *string `json:"url,omitempty"` 45 | } 46 | 47 | type OperationResultReference struct { 48 | // URL to the operation result. 49 | ResultUrl *string `json:"resultUrl,omitempty"` 50 | } 51 | 52 | // The status of an operation. 53 | type OperationStatus string 54 | 55 | type operationStatusValuesType struct { 56 | NotSet OperationStatus 57 | Queued OperationStatus 58 | InProgress OperationStatus 59 | Cancelled OperationStatus 60 | Succeeded OperationStatus 61 | Failed OperationStatus 62 | } 63 | 64 | var OperationStatusValues = operationStatusValuesType{ 65 | // The operation does not have a status set. 66 | NotSet: "notSet", 67 | // The operation has been queued. 68 | Queued: "queued", 69 | // The operation is in progress. 70 | InProgress: "inProgress", 71 | // The operation was cancelled by the user. 72 | Cancelled: "cancelled", 73 | // The operation completed successfully. 74 | Succeeded: "succeeded", 75 | // The operation completed with a failure. 76 | Failed: "failed", 77 | } 78 | -------------------------------------------------------------------------------- /azuredevops/packagingshared/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package packagingshared 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | ) 14 | 15 | // Data required for promoting multiple package versions. Pass this while performing {protocol}BatchOperationTypes.Promote batch operation. 16 | type BatchPromoteData struct { 17 | // Id or Name of the view, packages need to be promoted to. 18 | ViewId *string `json:"viewId,omitempty"` 19 | } 20 | 21 | // Minimal package details required to identify a package within a protocol. 22 | type MinimalPackageDetails struct { 23 | // Package name. 24 | Id *string `json:"id,omitempty"` 25 | // Package version. 26 | Version *string `json:"version,omitempty"` 27 | } 28 | 29 | // Type of an upstream source, such as Public or Internal. 30 | type PackagingSourceType string 31 | 32 | type packagingSourceTypeValuesType struct { 33 | Public PackagingSourceType 34 | Internal PackagingSourceType 35 | } 36 | 37 | var PackagingSourceTypeValues = packagingSourceTypeValuesType{ 38 | // Publicly available source. 39 | Public: "public", 40 | // Azure DevOps upstream source. 41 | Internal: "internal", 42 | } 43 | 44 | // Upstream source definition, including its Identity, package type, and other associated information. 45 | type UpstreamSourceInfo struct { 46 | // Locator for connecting to the upstream source in a user friendly format, that may potentially change over time 47 | DisplayLocation *string `json:"displayLocation,omitempty"` 48 | // Identity of the upstream source. 49 | Id *uuid.UUID `json:"id,omitempty"` 50 | // Locator for connecting to the upstream source 51 | Location *string `json:"location,omitempty"` 52 | // Display name. 53 | Name *string `json:"name,omitempty"` 54 | // Source type, such as Public or Internal. 55 | SourceType *PackagingSourceType `json:"sourceType,omitempty"` 56 | } 57 | -------------------------------------------------------------------------------- /azuredevops/pipelinepermissions/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package pipelinepermissions 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | "github.com/microsoft/azure-devops-go-api/azuredevops" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/pipelineschecks" 15 | "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" 16 | ) 17 | 18 | type Permission struct { 19 | Authorized *bool `json:"authorized,omitempty"` 20 | AuthorizedBy *webapi.IdentityRef `json:"authorizedBy,omitempty"` 21 | AuthorizedOn *azuredevops.Time `json:"authorizedOn,omitempty"` 22 | } 23 | 24 | type PipelinePermission struct { 25 | Authorized *bool `json:"authorized,omitempty"` 26 | AuthorizedBy *webapi.IdentityRef `json:"authorizedBy,omitempty"` 27 | AuthorizedOn *azuredevops.Time `json:"authorizedOn,omitempty"` 28 | Id *int `json:"id,omitempty"` 29 | } 30 | 31 | type PipelineProcessResources struct { 32 | Resources *[]PipelineResourceReference `json:"resources,omitempty"` 33 | } 34 | 35 | type PipelineResourceReference struct { 36 | Authorized *bool `json:"authorized,omitempty"` 37 | AuthorizedBy *uuid.UUID `json:"authorizedBy,omitempty"` 38 | AuthorizedOn *azuredevops.Time `json:"authorizedOn,omitempty"` 39 | DefinitionId *int `json:"definitionId,omitempty"` 40 | Id *string `json:"id,omitempty"` 41 | Type *string `json:"type,omitempty"` 42 | } 43 | 44 | type ResourcePipelinePermissions struct { 45 | AllPipelines *Permission `json:"allPipelines,omitempty"` 46 | Pipelines *[]PipelinePermission `json:"pipelines,omitempty"` 47 | Resource *pipelineschecks.Resource `json:"resource,omitempty"` 48 | } 49 | -------------------------------------------------------------------------------- /azuredevops/profile/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package profile 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops" 15 | "net/http" 16 | "net/url" 17 | "strconv" 18 | ) 19 | 20 | var ResourceAreaId, _ = uuid.Parse("8ccfef3d-2b87-4e99-8ccb-66e343d2daa8") 21 | 22 | type Client interface { 23 | // Gets a user profile. 24 | GetProfile(context.Context, GetProfileArgs) (*Profile, error) 25 | } 26 | 27 | type ClientImpl struct { 28 | Client azuredevops.Client 29 | } 30 | 31 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 32 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 33 | if err != nil { 34 | return nil, err 35 | } 36 | return &ClientImpl{ 37 | Client: *client, 38 | }, nil 39 | } 40 | 41 | // Gets a user profile. 42 | func (client *ClientImpl) GetProfile(ctx context.Context, args GetProfileArgs) (*Profile, error) { 43 | routeValues := make(map[string]string) 44 | if args.Id == nil || *args.Id == "" { 45 | return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Id"} 46 | } 47 | routeValues["id"] = *args.Id 48 | 49 | queryParams := url.Values{} 50 | if args.Details != nil { 51 | queryParams.Add("details", strconv.FormatBool(*args.Details)) 52 | } 53 | if args.WithAttributes != nil { 54 | queryParams.Add("withAttributes", strconv.FormatBool(*args.WithAttributes)) 55 | } 56 | if args.Partition != nil { 57 | queryParams.Add("partition", *args.Partition) 58 | } 59 | if args.CoreAttributes != nil { 60 | queryParams.Add("coreAttributes", *args.CoreAttributes) 61 | } 62 | if args.ForceRefresh != nil { 63 | queryParams.Add("forceRefresh", strconv.FormatBool(*args.ForceRefresh)) 64 | } 65 | locationId, _ := uuid.Parse("f83735dc-483f-4238-a291-d45f6080a9af") 66 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) 67 | if err != nil { 68 | return nil, err 69 | } 70 | 71 | var responseValue Profile 72 | err = client.Client.UnmarshalBody(resp, &responseValue) 73 | return &responseValue, err 74 | } 75 | 76 | // Arguments for the GetProfile function 77 | type GetProfileArgs struct { 78 | // (required) The ID of the target user profile within the same organization, or 'me' to get the profile of the current authenticated user. 79 | Id *string 80 | // (optional) Return public profile information such as display name, email address, country, etc. If false, the withAttributes parameter is ignored. 81 | Details *bool 82 | // (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. 83 | WithAttributes *bool 84 | // (optional) The partition (named group) of attributes to return. 85 | Partition *string 86 | // (optional) A comma-delimited list of core profile attributes to return. Valid values are Email, Avatar, DisplayName, and ContactWithOffers. 87 | CoreAttributes *string 88 | // (optional) Not used in this version of the API. 89 | ForceRefresh *bool 90 | } 91 | -------------------------------------------------------------------------------- /azuredevops/profileregions/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package profileregions 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops" 15 | "net/http" 16 | "net/url" 17 | ) 18 | 19 | var ResourceAreaId, _ = uuid.Parse("8ccfef3d-2b87-4e99-8ccb-66e343d2daa8") 20 | 21 | type Client interface { 22 | // [Preview API] Lookup up country/region based on provided IPv4, null if using the remote IPv4 address. 23 | GetGeoRegion(context.Context, GetGeoRegionArgs) (*GeoRegion, error) 24 | // [Preview API] 25 | GetRegions(context.Context, GetRegionsArgs) (*ProfileRegions, error) 26 | } 27 | 28 | type ClientImpl struct { 29 | Client azuredevops.Client 30 | } 31 | 32 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 33 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 34 | if err != nil { 35 | return nil, err 36 | } 37 | return &ClientImpl{ 38 | Client: *client, 39 | }, nil 40 | } 41 | 42 | // [Preview API] Lookup up country/region based on provided IPv4, null if using the remote IPv4 address. 43 | func (client *ClientImpl) GetGeoRegion(ctx context.Context, args GetGeoRegionArgs) (*GeoRegion, error) { 44 | queryParams := url.Values{} 45 | if args.Ip == nil { 46 | return nil, &azuredevops.ArgumentNilError{ArgumentName: "ip"} 47 | } 48 | queryParams.Add("ip", *args.Ip) 49 | locationId, _ := uuid.Parse("35b3ff1d-ab4c-4d1c-98bb-f6ea21d86bd9") 50 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, queryParams, nil, "", "application/json", nil) 51 | if err != nil { 52 | return nil, err 53 | } 54 | 55 | var responseValue GeoRegion 56 | err = client.Client.UnmarshalBody(resp, &responseValue) 57 | return &responseValue, err 58 | } 59 | 60 | // Arguments for the GetGeoRegion function 61 | type GetGeoRegionArgs struct { 62 | // (required) 63 | Ip *string 64 | } 65 | 66 | // [Preview API] 67 | func (client *ClientImpl) GetRegions(ctx context.Context, args GetRegionsArgs) (*ProfileRegions, error) { 68 | locationId, _ := uuid.Parse("b129ca90-999d-47bb-ab37-0dcf784ee633") 69 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", nil, nil, nil, "", "application/json", nil) 70 | if err != nil { 71 | return nil, err 72 | } 73 | 74 | var responseValue ProfileRegions 75 | err = client.Client.UnmarshalBody(resp, &responseValue) 76 | return &responseValue, err 77 | } 78 | 79 | // Arguments for the GetRegions function 80 | type GetRegionsArgs struct { 81 | } 82 | -------------------------------------------------------------------------------- /azuredevops/profileregions/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package profileregions 10 | 11 | type GeoRegion struct { 12 | RegionCode *string `json:"regionCode,omitempty"` 13 | } 14 | 15 | // Country/region information 16 | type ProfileRegion struct { 17 | // The two-letter code defined in ISO 3166 for the country/region. 18 | Code *string `json:"code,omitempty"` 19 | // Localized country/region name 20 | Name *string `json:"name,omitempty"` 21 | } 22 | 23 | // Container of country/region information 24 | type ProfileRegions struct { 25 | // List of country/region code with contact consent requirement type of notice 26 | NoticeContactConsentRequirementRegions *[]string `json:"noticeContactConsentRequirementRegions,omitempty"` 27 | // List of country/region code with contact consent requirement type of opt-out 28 | OptOutContactConsentRequirementRegions *[]string `json:"optOutContactConsentRequirementRegions,omitempty"` 29 | // List of country/regions 30 | Regions *[]ProfileRegion `json:"regions,omitempty"` 31 | } 32 | -------------------------------------------------------------------------------- /azuredevops/provenance/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package provenance 10 | 11 | import ( 12 | "bytes" 13 | "context" 14 | "encoding/json" 15 | "github.com/google/uuid" 16 | "github.com/microsoft/azure-devops-go-api/azuredevops" 17 | "net/http" 18 | ) 19 | 20 | var ResourceAreaId, _ = uuid.Parse("b40c1171-807a-493a-8f3f-5c26d5e2f5aa") 21 | 22 | type Client interface { 23 | // [Preview API] Creates a session, a wrapper around a feed that can store additional metadata on the packages published to it. 24 | CreateSession(context.Context, CreateSessionArgs) (*SessionResponse, error) 25 | } 26 | 27 | type ClientImpl struct { 28 | Client azuredevops.Client 29 | } 30 | 31 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 32 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 33 | if err != nil { 34 | return nil, err 35 | } 36 | return &ClientImpl{ 37 | Client: *client, 38 | }, nil 39 | } 40 | 41 | // [Preview API] Creates a session, a wrapper around a feed that can store additional metadata on the packages published to it. 42 | func (client *ClientImpl) CreateSession(ctx context.Context, args CreateSessionArgs) (*SessionResponse, error) { 43 | if args.SessionRequest == nil { 44 | return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SessionRequest"} 45 | } 46 | routeValues := make(map[string]string) 47 | if args.Project != nil && *args.Project != "" { 48 | routeValues["project"] = *args.Project 49 | } 50 | if args.Protocol == nil || *args.Protocol == "" { 51 | return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Protocol"} 52 | } 53 | routeValues["protocol"] = *args.Protocol 54 | 55 | body, marshalErr := json.Marshal(*args.SessionRequest) 56 | if marshalErr != nil { 57 | return nil, marshalErr 58 | } 59 | locationId, _ := uuid.Parse("503b4e54-ebf4-4d04-8eee-21c00823c2ac") 60 | resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) 61 | if err != nil { 62 | return nil, err 63 | } 64 | 65 | var responseValue SessionResponse 66 | err = client.Client.UnmarshalBody(resp, &responseValue) 67 | return &responseValue, err 68 | } 69 | 70 | // Arguments for the CreateSession function 71 | type CreateSessionArgs struct { 72 | // (required) The feed and metadata for the session 73 | SessionRequest *SessionRequest 74 | // (required) The protocol that the session will target 75 | Protocol *string 76 | // (optional) Project ID or project name 77 | Project *string 78 | } 79 | -------------------------------------------------------------------------------- /azuredevops/provenance/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package provenance 10 | 11 | type SessionRequest struct { 12 | // Generic property bag to store data about the session 13 | Data *map[string]string `json:"data,omitempty"` 14 | // The feed name or id for the session 15 | Feed *string `json:"feed,omitempty"` 16 | // 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 17 | Source *string `json:"source,omitempty"` 18 | } 19 | 20 | type SessionResponse struct { 21 | // The unique identifier for the session 22 | SessionId *string `json:"sessionId,omitempty"` 23 | // The name for the session 24 | SessionName *string `json:"sessionName,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /azuredevops/pypiapi/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package pypiapi 10 | 11 | import ( 12 | "github.com/microsoft/azure-devops-go-api/azuredevops" 13 | "github.com/microsoft/azure-devops-go-api/azuredevops/packagingshared" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" 15 | ) 16 | 17 | // Package version metadata for a Python package 18 | type Package struct { 19 | // Related REST links. 20 | Links interface{} `json:"_links,omitempty"` 21 | // If and when the package was deleted. 22 | DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` 23 | // Package Id. 24 | Id *string `json:"id,omitempty"` 25 | // The display name of the package. 26 | Name *string `json:"name,omitempty"` 27 | // If and when the package was permanently deleted. 28 | PermanentlyDeletedDate *azuredevops.Time `json:"permanentlyDeletedDate,omitempty"` 29 | // The history of upstream sources for this package. The first source in the list is the immediate source from which this package was saved. 30 | SourceChain *[]packagingshared.UpstreamSourceInfo `json:"sourceChain,omitempty"` 31 | // The version of the package. 32 | Version *string `json:"version,omitempty"` 33 | } 34 | 35 | type PackageVersionDetails struct { 36 | // The view to which the package version will be added 37 | Views *webapi.JsonPatchOperation `json:"views,omitempty"` 38 | } 39 | 40 | // Describes PyPi batch operation types. 41 | type PyPiBatchOperationType string 42 | 43 | type pyPiBatchOperationTypeValuesType struct { 44 | Promote PyPiBatchOperationType 45 | Delete PyPiBatchOperationType 46 | PermanentDelete PyPiBatchOperationType 47 | RestoreToFeed PyPiBatchOperationType 48 | } 49 | 50 | var PyPiBatchOperationTypeValues = pyPiBatchOperationTypeValuesType{ 51 | // 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. 52 | Promote: "promote", 53 | // Move package versions to the feed's Recycle Bin. Not supported in the Recycle Bin. 54 | Delete: "delete", 55 | // Permanently delete package versions. Only supported in the Recycle Bin. 56 | PermanentDelete: "permanentDelete", 57 | // Restore deleted package versions to the feed. Only supported in the Recycle Bin. 58 | RestoreToFeed: "restoreToFeed", 59 | } 60 | 61 | // A batch of operations to apply to package versions. 62 | type PyPiPackagesBatchRequest struct { 63 | // Data required to perform the operation. This is optional based on the type of the operation. Use BatchPromoteData if performing a promote operation. 64 | Data interface{} `json:"data,omitempty"` 65 | // Type of operation that needs to be performed on packages. 66 | Operation *PyPiBatchOperationType `json:"operation,omitempty"` 67 | // The packages onto which the operation will be performed. 68 | Packages *[]packagingshared.MinimalPackageDetails `json:"packages,omitempty"` 69 | } 70 | 71 | // Deletion state of a Python package. 72 | type PyPiPackageVersionDeletionState struct { 73 | // UTC date the package was deleted. 74 | DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` 75 | // Name of the package. 76 | Name *string `json:"name,omitempty"` 77 | // Version of the package. 78 | Version *string `json:"version,omitempty"` 79 | } 80 | 81 | type PyPiRecycleBinPackageVersionDetails struct { 82 | // Setting to false will undo earlier deletion and restore the package to feed. 83 | Deleted *bool `json:"deleted,omitempty"` 84 | } 85 | -------------------------------------------------------------------------------- /azuredevops/symbolcommon/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package symbolcommon 10 | 11 | // [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. 12 | type DebugInformationLevel string 13 | 14 | type debugInformationLevelValuesType struct { 15 | None DebugInformationLevel 16 | Binary DebugInformationLevel 17 | Publics DebugInformationLevel 18 | TraceFormatPresent DebugInformationLevel 19 | TypeInfo DebugInformationLevel 20 | LineNumbers DebugInformationLevel 21 | GlobalSymbols DebugInformationLevel 22 | Private DebugInformationLevel 23 | SourceIndexed DebugInformationLevel 24 | } 25 | 26 | var DebugInformationLevelValues = debugInformationLevelValuesType{ 27 | // If set, the .pdb file contains no debug information. 28 | None: "none", 29 | // If set, the .pdb file contains debug information which is binary. 30 | Binary: "binary", 31 | // If set, the .pdb file contains public symbols. 32 | Publics: "publics", 33 | // If set, the .pdb file contains trace format. 34 | TraceFormatPresent: "traceFormatPresent", 35 | // If set, the .pdb file contains type information. 36 | TypeInfo: "typeInfo", 37 | // If set, the .pdb file contains line number information. 38 | LineNumbers: "lineNumbers", 39 | // If set, the .pdb file contains symbol information. 40 | GlobalSymbols: "globalSymbols", 41 | // If set, the .pdb file contains public symbols and has type, line number and symbol information. 42 | Private: "private", 43 | // If set, the .pdb file supports the source server. 44 | SourceIndexed: "sourceIndexed", 45 | } 46 | -------------------------------------------------------------------------------- /azuredevops/system/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package system 10 | 11 | type SqlDbType string 12 | 13 | type sqlDbTypeValuesType struct { 14 | BigInt SqlDbType 15 | Binary SqlDbType 16 | Bit SqlDbType 17 | Char SqlDbType 18 | DateTime SqlDbType 19 | Decimal SqlDbType 20 | Float SqlDbType 21 | Image SqlDbType 22 | Int SqlDbType 23 | Money SqlDbType 24 | NChar SqlDbType 25 | NText SqlDbType 26 | NVarChar SqlDbType 27 | Real SqlDbType 28 | UniqueIdentifier SqlDbType 29 | SmallDateTime SqlDbType 30 | SmallInt SqlDbType 31 | SmallMoney SqlDbType 32 | Text SqlDbType 33 | Timestamp SqlDbType 34 | TinyInt SqlDbType 35 | VarBinary SqlDbType 36 | VarChar SqlDbType 37 | Variant SqlDbType 38 | Xml SqlDbType 39 | Udt SqlDbType 40 | Structured SqlDbType 41 | Date SqlDbType 42 | Time SqlDbType 43 | DateTime2 SqlDbType 44 | DateTimeOffset SqlDbType 45 | } 46 | 47 | var SqlDbTypeValues = sqlDbTypeValuesType{ 48 | BigInt: "bigInt", 49 | Binary: "binary", 50 | Bit: "bit", 51 | Char: "char", 52 | DateTime: "dateTime", 53 | Decimal: "decimal", 54 | Float: "float", 55 | Image: "image", 56 | Int: "int", 57 | Money: "money", 58 | NChar: "nChar", 59 | NText: "nText", 60 | NVarChar: "nVarChar", 61 | Real: "real", 62 | UniqueIdentifier: "uniqueIdentifier", 63 | SmallDateTime: "smallDateTime", 64 | SmallInt: "smallInt", 65 | SmallMoney: "smallMoney", 66 | Text: "text", 67 | Timestamp: "timestamp", 68 | TinyInt: "tinyInt", 69 | VarBinary: "varBinary", 70 | VarChar: "varChar", 71 | Variant: "variant", 72 | Xml: "xml", 73 | Udt: "udt", 74 | Structured: "structured", 75 | Date: "date", 76 | Time: "time", 77 | DateTime2: "dateTime2", 78 | DateTimeOffset: "dateTimeOffset", 79 | } 80 | 81 | type TraceLevel string 82 | 83 | type traceLevelValuesType struct { 84 | Off TraceLevel 85 | Error TraceLevel 86 | Warning TraceLevel 87 | Info TraceLevel 88 | Verbose TraceLevel 89 | } 90 | 91 | var TraceLevelValues = traceLevelValuesType{ 92 | Off: "off", 93 | Error: "error", 94 | Warning: "warning", 95 | Info: "info", 96 | Verbose: "verbose", 97 | } 98 | -------------------------------------------------------------------------------- /azuredevops/testresults/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package testresults 10 | 11 | type Attachment struct { 12 | CompressionType *string `json:"compressionType,omitempty"` 13 | FileName *string `json:"fileName,omitempty"` 14 | Stream interface{} `json:"stream,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /azuredevops/tokenadmin/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package tokenadmin 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | "github.com/microsoft/azure-devops-go-api/azuredevops" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/delegatedauthorization" 15 | ) 16 | 17 | // A paginated list of session tokens. Session tokens correspond to OAuth credentials such as personal access tokens (PATs) and other OAuth authorizations. 18 | type TokenAdminPagedSessionTokens struct { 19 | // The continuation token that can be used to retrieve the next page of session tokens, or null if there is no next page. 20 | ContinuationToken *uuid.UUID `json:"continuationToken,omitempty"` 21 | // The list of all session tokens in the current page. 22 | Value *[]delegatedauthorization.SessionToken `json:"value,omitempty"` 23 | } 24 | 25 | // A request to revoke a particular delegated authorization. 26 | type TokenAdminRevocation struct { 27 | // The authorization ID of the OAuth authorization to revoke. 28 | AuthorizationId *uuid.UUID `json:"authorizationId,omitempty"` 29 | } 30 | 31 | // A rule which is applied to disable any incoming delegated authorization which matches the given properties. 32 | type TokenAdminRevocationRule struct { 33 | // 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. 34 | CreatedBefore *azuredevops.Time `json:"createdBefore,omitempty"` 35 | // 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. 36 | Scopes *string `json:"scopes,omitempty"` 37 | } 38 | -------------------------------------------------------------------------------- /azuredevops/tokenadministration/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package tokenadministration 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | ) 14 | 15 | type TokenAdministrationRevocation struct { 16 | // A list of audience (target accounts) to limit the revocations to 17 | Audience *[]string `json:"audience,omitempty"` 18 | // A list of authorization ID of the OAuth authorization to revoke. 19 | AuthorizationIds *[]uuid.UUID `json:"authorizationIds,omitempty"` 20 | } 21 | -------------------------------------------------------------------------------- /azuredevops/upackpackaging/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package upackpackaging 10 | 11 | import ( 12 | "github.com/microsoft/azure-devops-go-api/azuredevops" 13 | ) 14 | 15 | // Describes UPack batch operation types. 16 | type UPackBatchOperationType string 17 | 18 | type uPackBatchOperationTypeValuesType struct { 19 | Promote UPackBatchOperationType 20 | Delete UPackBatchOperationType 21 | PermanentDelete UPackBatchOperationType 22 | RestoreToFeed UPackBatchOperationType 23 | } 24 | 25 | var UPackBatchOperationTypeValues = uPackBatchOperationTypeValuesType{ 26 | // 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. 27 | Promote: "promote", 28 | // Move package versions to the feed's Recycle Bin. Not supported in the Recycle Bin. 29 | Delete: "delete", 30 | // Permanently delete package versions. Only supported in the Recycle Bin. 31 | PermanentDelete: "permanentDelete", 32 | // Restore deleted package versions to the feed. Only supported in the Recycle Bin. 33 | RestoreToFeed: "restoreToFeed", 34 | } 35 | 36 | // Describes intent when calling the API GetPackageMetadata. 37 | type UPackGetPackageMetadataIntent string 38 | 39 | type uPackGetPackageMetadataIntentValuesType struct { 40 | FetchMetadataOnly UPackGetPackageMetadataIntent 41 | Download UPackGetPackageMetadataIntent 42 | } 43 | 44 | var UPackGetPackageMetadataIntentValues = uPackGetPackageMetadataIntentValuesType{ 45 | // Default. The call intends only to retrieve the package metadata. 46 | FetchMetadataOnly: "fetchMetadataOnly", 47 | // The call is part of the download flow. 48 | Download: "download", 49 | } 50 | 51 | type UPackLimitedPackageMetadata struct { 52 | Version *string `json:"version,omitempty"` 53 | } 54 | 55 | type UPackLimitedPackageMetadataListResponse struct { 56 | Count *int `json:"count,omitempty"` 57 | Value *[]UPackLimitedPackageMetadata `json:"value,omitempty"` 58 | } 59 | 60 | type UPackPackageMetadata struct { 61 | Description *string `json:"description,omitempty"` 62 | ManifestId *string `json:"manifestId,omitempty"` 63 | SuperRootId *string `json:"superRootId,omitempty"` 64 | Version *string `json:"version,omitempty"` 65 | } 66 | 67 | type UPackPackagePushMetadata struct { 68 | Description *string `json:"description,omitempty"` 69 | ManifestId *string `json:"manifestId,omitempty"` 70 | SuperRootId *string `json:"superRootId,omitempty"` 71 | Version *string `json:"version,omitempty"` 72 | ProofNodes *[]string `json:"proofNodes,omitempty"` 73 | } 74 | 75 | // Deletion state of a Universal package. 76 | type UPackPackageVersionDeletionState struct { 77 | // UTC date the package was deleted. 78 | DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` 79 | // Name of the package. 80 | Name *string `json:"name,omitempty"` 81 | // Version of the package. 82 | Version *string `json:"version,omitempty"` 83 | } 84 | -------------------------------------------------------------------------------- /azuredevops/v6/accounts/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package accounts 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 15 | "net/http" 16 | "net/url" 17 | ) 18 | 19 | var ResourceAreaId, _ = uuid.Parse("0d55247a-1c47-4462-9b1f-5e2125590ee6") 20 | 21 | type Client interface { 22 | // Get a list of accounts for a specific owner or a specific member. One of the following parameters is required: ownerId, memberId. 23 | GetAccounts(context.Context, GetAccountsArgs) (*[]Account, error) 24 | } 25 | 26 | type ClientImpl struct { 27 | Client azuredevops.Client 28 | } 29 | 30 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 31 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 32 | if err != nil { 33 | return nil, err 34 | } 35 | return &ClientImpl{ 36 | Client: *client, 37 | }, nil 38 | } 39 | 40 | // Get a list of accounts for a specific owner or a specific member. One of the following parameters is required: ownerId, memberId. 41 | func (client *ClientImpl) GetAccounts(ctx context.Context, args GetAccountsArgs) (*[]Account, error) { 42 | queryParams := url.Values{} 43 | if args.OwnerId != nil { 44 | queryParams.Add("ownerId", (*args.OwnerId).String()) 45 | } 46 | if args.MemberId != nil { 47 | queryParams.Add("memberId", (*args.MemberId).String()) 48 | } 49 | if args.Properties != nil { 50 | queryParams.Add("properties", *args.Properties) 51 | } 52 | locationId, _ := uuid.Parse("229a6a53-b428-4ffb-a835-e8f36b5b4b1e") 53 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0", nil, queryParams, nil, "", "application/json", nil) 54 | if err != nil { 55 | return nil, err 56 | } 57 | 58 | var responseValue []Account 59 | err = client.Client.UnmarshalCollectionBody(resp, &responseValue) 60 | return &responseValue, err 61 | } 62 | 63 | // Arguments for the GetAccounts function 64 | type GetAccountsArgs struct { 65 | // (optional) ID for the owner of the accounts. 66 | OwnerId *uuid.UUID 67 | // (optional) ID for a member of the accounts. 68 | MemberId *uuid.UUID 69 | // (optional) 70 | Properties *string 71 | } 72 | -------------------------------------------------------------------------------- /azuredevops/v6/clientTrace/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package clienttrace 10 | 11 | import ( 12 | "bytes" 13 | "context" 14 | "encoding/json" 15 | "github.com/google/uuid" 16 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 17 | "net/http" 18 | ) 19 | 20 | type Client interface { 21 | // [Preview API] 22 | PublishEvents(context.Context, PublishEventsArgs) error 23 | } 24 | 25 | type ClientImpl struct { 26 | Client azuredevops.Client 27 | } 28 | 29 | func NewClient(ctx context.Context, connection *azuredevops.Connection) Client { 30 | client := connection.GetClientByUrl(connection.BaseUrl) 31 | return &ClientImpl{ 32 | Client: *client, 33 | } 34 | } 35 | 36 | // [Preview API] 37 | func (client *ClientImpl) PublishEvents(ctx context.Context, args PublishEventsArgs) error { 38 | if args.Events == nil { 39 | return &azuredevops.ArgumentNilError{ArgumentName: "args.Events"} 40 | } 41 | body, marshalErr := json.Marshal(*args.Events) 42 | if marshalErr != nil { 43 | return marshalErr 44 | } 45 | locationId, _ := uuid.Parse("06bcc74a-1491-4eb8-a0eb-704778f9d041") 46 | _, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) 47 | if err != nil { 48 | return err 49 | } 50 | 51 | return nil 52 | } 53 | 54 | // Arguments for the PublishEvents function 55 | type PublishEventsArgs struct { 56 | // (required) 57 | Events *[]ClientTraceEvent 58 | } 59 | -------------------------------------------------------------------------------- /azuredevops/v6/clientTrace/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package clienttrace 10 | 11 | type ClientTraceEvent struct { 12 | Area *string `json:"area,omitempty"` 13 | Component *string `json:"component,omitempty"` 14 | ExceptionType *string `json:"exceptionType,omitempty"` 15 | Feature *string `json:"feature,omitempty"` 16 | Level *Level `json:"level,omitempty"` 17 | Message *string `json:"message,omitempty"` 18 | Method *string `json:"method,omitempty"` 19 | Properties *map[string]interface{} `json:"properties,omitempty"` 20 | } 21 | 22 | type Level string 23 | 24 | type levelValuesType struct { 25 | Off Level 26 | Error Level 27 | Warning Level 28 | Info Level 29 | Verbose Level 30 | } 31 | 32 | var LevelValues = levelValuesType{ 33 | Off: "off", 34 | Error: "error", 35 | Warning: "warning", 36 | Info: "info", 37 | Verbose: "verbose", 38 | } 39 | -------------------------------------------------------------------------------- /azuredevops/v6/client_options.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | // ClientOptionFunc can be used customize a new AzureDevops API client. 8 | type ClientOptionFunc func(*Client) 9 | 10 | // WithHTTPClient can be used to configure a custom HTTP client. 11 | func WithHTTPClient(httpClient *http.Client) ClientOptionFunc { 12 | return func(c *Client) { 13 | c.client = httpClient 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /azuredevops/v6/client_test.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | import ( 4 | "crypto/tls" 5 | "net/http" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | func TestClient_NewClient(t *testing.T) { 11 | tlsConfig := &tls.Config{} 12 | timeout := 20 * time.Millisecond 13 | 14 | conn := &Connection{ 15 | TlsConfig: tlsConfig, 16 | Timeout: &timeout, 17 | } 18 | baseURL := "localhost" 19 | client := NewClient(conn, baseURL) 20 | if client.baseUrl != baseURL { 21 | t.Errorf("Expected baseURL: %v Actual baseURL: %v", baseURL, client.baseUrl) 22 | } 23 | if actualTLSConfig := client.client.Transport.(*http.Transport).TLSClientConfig; actualTLSConfig != tlsConfig { 24 | t.Errorf("Expected tlsConfig: %v Actual tlsConfig: %v", tlsConfig, actualTLSConfig) 25 | } 26 | } 27 | 28 | func TestClient_NewClientWithOptions_WithHTTPClient(t *testing.T) { 29 | tlsConfig := &tls.Config{} 30 | httpTimeout := 20 * time.Millisecond 31 | connTimeout := 40 * time.Millisecond 32 | 33 | conn := &Connection{ 34 | TlsConfig: tlsConfig, 35 | Timeout: &connTimeout, // will be ignored in favour of httpTimeout 36 | } 37 | 38 | httpClient := &http.Client{Timeout: httpTimeout} 39 | baseURL := "localhost" 40 | 41 | client := NewClientWithOptions(conn, baseURL, WithHTTPClient(httpClient)) 42 | if client.baseUrl != baseURL { 43 | t.Errorf("Expected baseURL: %v Actual baseURL: %v", baseURL, client.baseUrl) 44 | } 45 | if actualHTTPClient := client.client; actualHTTPClient.Timeout != httpClient.Timeout { 46 | t.Errorf("Expected httpClient.Timeout: %#v Actual httpClient.Timeout: %#v", httpClient.Timeout, actualHTTPClient.Timeout) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /azuredevops/v6/customerintelligence/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package customerintelligence 10 | 11 | import ( 12 | "bytes" 13 | "context" 14 | "encoding/json" 15 | "github.com/google/uuid" 16 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 17 | "net/http" 18 | ) 19 | 20 | type Client interface { 21 | // [Preview API] 22 | PublishEvents(context.Context, PublishEventsArgs) error 23 | } 24 | 25 | type ClientImpl struct { 26 | Client azuredevops.Client 27 | } 28 | 29 | func NewClient(ctx context.Context, connection *azuredevops.Connection) Client { 30 | client := connection.GetClientByUrl(connection.BaseUrl) 31 | return &ClientImpl{ 32 | Client: *client, 33 | } 34 | } 35 | 36 | // [Preview API] 37 | func (client *ClientImpl) PublishEvents(ctx context.Context, args PublishEventsArgs) error { 38 | if args.Events == nil { 39 | return &azuredevops.ArgumentNilError{ArgumentName: "args.Events"} 40 | } 41 | body, marshalErr := json.Marshal(*args.Events) 42 | if marshalErr != nil { 43 | return marshalErr 44 | } 45 | locationId, _ := uuid.Parse("b5cc35c2-ff2b-491d-a085-24b6e9f396fd") 46 | _, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) 47 | if err != nil { 48 | return err 49 | } 50 | 51 | return nil 52 | } 53 | 54 | // Arguments for the PublishEvents function 55 | type PublishEventsArgs struct { 56 | // (required) 57 | Events *[]CustomerIntelligenceEvent 58 | } 59 | -------------------------------------------------------------------------------- /azuredevops/v6/customerintelligence/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package customerintelligence 10 | 11 | type CustomerIntelligenceEvent struct { 12 | Area *string `json:"area,omitempty"` 13 | Feature *string `json:"feature,omitempty"` 14 | Properties *map[string]interface{} `json:"properties,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /azuredevops/v6/distributedtaskcommon/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package distributedtaskcommon 10 | 11 | type AuthorizationHeader struct { 12 | Name *string `json:"name,omitempty"` 13 | Value *string `json:"value,omitempty"` 14 | } 15 | 16 | // Represents binding of data source for the service endpoint request. 17 | type DataSourceBindingBase struct { 18 | // Pagination format supported by this data source(ContinuationToken/SkipTop). 19 | CallbackContextTemplate *string `json:"callbackContextTemplate,omitempty"` 20 | // Subsequent calls needed? 21 | CallbackRequiredTemplate *string `json:"callbackRequiredTemplate,omitempty"` 22 | // Gets or sets the name of the data source. 23 | DataSourceName *string `json:"dataSourceName,omitempty"` 24 | // Gets or sets the endpoint Id. 25 | EndpointId *string `json:"endpointId,omitempty"` 26 | // Gets or sets the url of the service endpoint. 27 | EndpointUrl *string `json:"endpointUrl,omitempty"` 28 | // Gets or sets the authorization headers. 29 | Headers *[]AuthorizationHeader `json:"headers,omitempty"` 30 | // Defines the initial value of the query params 31 | InitialContextTemplate *string `json:"initialContextTemplate,omitempty"` 32 | // Gets or sets the parameters for the data source. 33 | Parameters *map[string]string `json:"parameters,omitempty"` 34 | // Gets or sets http request body 35 | RequestContent *string `json:"requestContent,omitempty"` 36 | // Gets or sets http request verb 37 | RequestVerb *string `json:"requestVerb,omitempty"` 38 | // Gets or sets the result selector. 39 | ResultSelector *string `json:"resultSelector,omitempty"` 40 | // Gets or sets the result template. 41 | ResultTemplate *string `json:"resultTemplate,omitempty"` 42 | // Gets or sets the target of the data source. 43 | Target *string `json:"target,omitempty"` 44 | } 45 | 46 | type ProcessParameters struct { 47 | DataSourceBindings *[]DataSourceBindingBase `json:"dataSourceBindings,omitempty"` 48 | Inputs *[]TaskInputDefinitionBase `json:"inputs,omitempty"` 49 | SourceDefinitions *[]TaskSourceDefinitionBase `json:"sourceDefinitions,omitempty"` 50 | } 51 | 52 | type TaskInputDefinitionBase struct { 53 | Aliases *[]string `json:"aliases,omitempty"` 54 | DefaultValue *string `json:"defaultValue,omitempty"` 55 | GroupName *string `json:"groupName,omitempty"` 56 | HelpMarkDown *string `json:"helpMarkDown,omitempty"` 57 | Label *string `json:"label,omitempty"` 58 | Name *string `json:"name,omitempty"` 59 | Options *map[string]string `json:"options,omitempty"` 60 | Properties *map[string]string `json:"properties,omitempty"` 61 | Required *bool `json:"required,omitempty"` 62 | Type *string `json:"type,omitempty"` 63 | Validation *TaskInputValidation `json:"validation,omitempty"` 64 | VisibleRule *string `json:"visibleRule,omitempty"` 65 | } 66 | 67 | type TaskInputValidation struct { 68 | // Conditional expression 69 | Expression *string `json:"expression,omitempty"` 70 | // Message explaining how user can correct if validation fails 71 | Message *string `json:"message,omitempty"` 72 | } 73 | 74 | type TaskSourceDefinitionBase struct { 75 | AuthKey *string `json:"authKey,omitempty"` 76 | Endpoint *string `json:"endpoint,omitempty"` 77 | KeySelector *string `json:"keySelector,omitempty"` 78 | Selector *string `json:"selector,omitempty"` 79 | Target *string `json:"target,omitempty"` 80 | } 81 | -------------------------------------------------------------------------------- /azuredevops/v6/errors.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | type ArgumentNilError struct { 4 | ArgumentName string 5 | } 6 | 7 | func (e ArgumentNilError) Error() string { 8 | return "Argument " + e.ArgumentName + " can not be nil" 9 | } 10 | 11 | type ArgumentNilOrEmptyError struct { 12 | ArgumentName string 13 | } 14 | 15 | func (e ArgumentNilOrEmptyError) Error() string { 16 | return "Argument " + e.ArgumentName + " can not be nil or empty" 17 | } 18 | -------------------------------------------------------------------------------- /azuredevops/v6/featureavailability/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package featureavailability 10 | 11 | type FeatureFlag struct { 12 | Description *string `json:"description,omitempty"` 13 | EffectiveState *string `json:"effectiveState,omitempty"` 14 | ExplicitState *string `json:"explicitState,omitempty"` 15 | Name *string `json:"name,omitempty"` 16 | Uri *string `json:"uri,omitempty"` 17 | } 18 | 19 | // This is passed to the FeatureFlagController to edit the status of a feature flag 20 | type FeatureFlagPatch struct { 21 | State *string `json:"state,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /azuredevops/v6/feedtoken/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package feedtoken 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 15 | "net/http" 16 | ) 17 | 18 | var ResourceAreaId, _ = uuid.Parse("cdeb6c7d-6b25-4d6f-b664-c2e3ede202e8") 19 | 20 | type Client interface { 21 | // [Preview API] Get a time-limited session token representing the current user, with permissions scoped to the read/write of Artifacts. 22 | GetPersonalAccessToken(context.Context, GetPersonalAccessTokenArgs) (*FeedSessionToken, error) 23 | } 24 | 25 | type ClientImpl struct { 26 | Client azuredevops.Client 27 | } 28 | 29 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 30 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 31 | if err != nil { 32 | return nil, err 33 | } 34 | return &ClientImpl{ 35 | Client: *client, 36 | }, nil 37 | } 38 | 39 | // [Preview API] Get a time-limited session token representing the current user, with permissions scoped to the read/write of Artifacts. 40 | func (client *ClientImpl) GetPersonalAccessToken(ctx context.Context, args GetPersonalAccessTokenArgs) (*FeedSessionToken, error) { 41 | routeValues := make(map[string]string) 42 | if args.FeedName != nil && *args.FeedName != "" { 43 | routeValues["feedName"] = *args.FeedName 44 | } 45 | 46 | locationId, _ := uuid.Parse("dfdb7ad7-3d8e-4907-911e-19b4a8330550") 47 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) 48 | if err != nil { 49 | return nil, err 50 | } 51 | 52 | var responseValue FeedSessionToken 53 | err = client.Client.UnmarshalBody(resp, &responseValue) 54 | return &responseValue, err 55 | } 56 | 57 | // Arguments for the GetPersonalAccessToken function 58 | type GetPersonalAccessTokenArgs struct { 59 | // (optional) 60 | FeedName *string 61 | } 62 | -------------------------------------------------------------------------------- /azuredevops/v6/feedtoken/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package feedtoken 10 | 11 | import ( 12 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 13 | ) 14 | 15 | // 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 16 | type FeedSessionToken struct { 17 | Token *string `json:"token,omitempty"` 18 | ValidTo *azuredevops.Time `json:"validTo,omitempty"` 19 | } 20 | -------------------------------------------------------------------------------- /azuredevops/v6/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/microsoft/azure-devops-go-api/azuredevops/v6 2 | 3 | go 1.12 4 | 5 | require github.com/google/uuid v1.1.1 6 | -------------------------------------------------------------------------------- /azuredevops/v6/go.sum: -------------------------------------------------------------------------------- 1 | github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= 2 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 3 | -------------------------------------------------------------------------------- /azuredevops/v6/models_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | package azuredevops 5 | 6 | import ( 7 | "encoding/json" 8 | "github.com/google/uuid" 9 | "testing" 10 | "time" 11 | ) 12 | 13 | func TestModels_Unmarshal_Time(t *testing.T) { 14 | 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\"}") 15 | testModel := TestModel{} 16 | 17 | testModel.Time1 = &Time{} 18 | testModel.Time1.Time = time.Now() // this ensures we test the value is set back to default when issue #17 is hit. 19 | 20 | err := json.Unmarshal(text, &testModel) 21 | if err != nil { 22 | t.Errorf("Error occurred during deserialization: %v", err) 23 | } 24 | if (testModel.Time1.Time != time.Time{}) { 25 | t.Errorf("Expecting deserialized time to equal default time. Actual time: %v", testModel.Time1) 26 | } 27 | 28 | parsedTime, err := time.Parse(time.RFC3339Nano, "2019-09-01T00:07:26Z") 29 | if err != nil { 30 | t.Errorf(err.Error()) 31 | } 32 | if testModel.Time2.Time != parsedTime { 33 | t.Errorf("Expected time: %v Actual time: %v", parsedTime, testModel.Time2.Time) 34 | } 35 | 36 | // Test workaround for issue #59 https://github.com/microsoft/azure-devops-go-api/issues/59 37 | parsedTime59, err := time.Parse("2006-01-02T15:04:05.999999999", "2020-05-16T20:55:32.0116793") 38 | if testModel.Time3.Time != parsedTime59 { 39 | t.Errorf("Expected time: %v Actual time: %v", parsedTime59, testModel.Time3.Time) 40 | } 41 | } 42 | 43 | func TestModels_Marshal_Unmarshal_Time(t *testing.T) { 44 | testModel1 := TestModel{} 45 | testModel1.Time1 = &Time{} 46 | testModel1.Time1.Time = time.Now() 47 | b, err := json.Marshal(testModel1) 48 | if err != nil { 49 | t.Errorf(err.Error()) 50 | } 51 | 52 | testModel2 := TestModel{} 53 | err = json.Unmarshal(b, &testModel2) 54 | if err != nil { 55 | t.Errorf(err.Error()) 56 | } 57 | 58 | if testModel1.Time1 != testModel1.Time1 { 59 | t.Errorf("Expected time: %v Actual time: %v", testModel1.Time1, testModel1.Time2) 60 | } 61 | 62 | if testModel1.Time1.Time != testModel1.Time1.Time { 63 | t.Errorf("Expected time: %v Actual time: %v", testModel1.Time1.Time, testModel1.Time2.Time) 64 | } 65 | } 66 | 67 | func TestModels_Time_AsQueryParameter(t *testing.T) { 68 | tt := &Time{ 69 | // NOTE: set nsec to 0 to avoid precision loss 70 | Time: time.Date(2006, 1, 2, 3, 4, 5, 0, time.UTC), 71 | } 72 | queryParameterValue := tt.AsQueryParameter() 73 | parsedTime, err := time.Parse(time.RFC3339Nano, queryParameterValue) 74 | if err != nil { 75 | t.Errorf("invalid query parameter %s value for time: %s", tt.Time, queryParameterValue) 76 | } 77 | if !tt.Time.Equal(parsedTime) { 78 | t.Errorf("should convert back to original value: %s %s", tt.Time, parsedTime) 79 | } 80 | } 81 | 82 | type TestModel struct { 83 | Id *uuid.UUID `json:"id,omitempty"` 84 | Time1 *Time `json:"time1,omitempty"` 85 | Time2 *Time `json:"time2,omitempty"` 86 | Time3 *Time `json:"time3,omitempty"` 87 | Int *uint64 `json:"int,omitempty"` 88 | String *string `json:"string,omitempty"` 89 | } 90 | -------------------------------------------------------------------------------- /azuredevops/v6/operations/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package operations 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 15 | "net/http" 16 | "net/url" 17 | ) 18 | 19 | type Client interface { 20 | // Gets an operation from the the operationId using the given pluginId. 21 | GetOperation(context.Context, GetOperationArgs) (*Operation, error) 22 | } 23 | 24 | type ClientImpl struct { 25 | Client azuredevops.Client 26 | } 27 | 28 | func NewClient(ctx context.Context, connection *azuredevops.Connection) Client { 29 | client := connection.GetClientByUrl(connection.BaseUrl) 30 | return &ClientImpl{ 31 | Client: *client, 32 | } 33 | } 34 | 35 | // Gets an operation from the the operationId using the given pluginId. 36 | func (client *ClientImpl) GetOperation(ctx context.Context, args GetOperationArgs) (*Operation, error) { 37 | routeValues := make(map[string]string) 38 | if args.OperationId == nil { 39 | return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.OperationId"} 40 | } 41 | routeValues["operationId"] = (*args.OperationId).String() 42 | 43 | queryParams := url.Values{} 44 | if args.PluginId != nil { 45 | queryParams.Add("pluginId", (*args.PluginId).String()) 46 | } 47 | locationId, _ := uuid.Parse("9a1b74b4-2ca8-4a9f-8470-c2f2e6fdc949") 48 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0", routeValues, queryParams, nil, "", "application/json", nil) 49 | if err != nil { 50 | return nil, err 51 | } 52 | 53 | var responseValue Operation 54 | err = client.Client.UnmarshalBody(resp, &responseValue) 55 | return &responseValue, err 56 | } 57 | 58 | // Arguments for the GetOperation function 59 | type GetOperationArgs struct { 60 | // (required) The ID for the operation. 61 | OperationId *uuid.UUID 62 | // (optional) The ID for the plugin. 63 | PluginId *uuid.UUID 64 | } 65 | -------------------------------------------------------------------------------- /azuredevops/v6/operations/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package operations 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | ) 14 | 15 | // Contains information about the progress or result of an async operation. 16 | type Operation struct { 17 | // Unique identifier for the operation. 18 | Id *uuid.UUID `json:"id,omitempty"` 19 | // Unique identifier for the plugin. 20 | PluginId *uuid.UUID `json:"pluginId,omitempty"` 21 | // The current status of the operation. 22 | Status *OperationStatus `json:"status,omitempty"` 23 | // URL to get the full operation object. 24 | Url *string `json:"url,omitempty"` 25 | // Links to other related objects. 26 | Links interface{} `json:"_links,omitempty"` 27 | // Detailed messaged about the status of an operation. 28 | DetailedMessage *string `json:"detailedMessage,omitempty"` 29 | // Result message for an operation. 30 | ResultMessage *string `json:"resultMessage,omitempty"` 31 | // URL to the operation result. 32 | ResultUrl *OperationResultReference `json:"resultUrl,omitempty"` 33 | } 34 | 35 | // Reference for an async operation. 36 | type OperationReference struct { 37 | // Unique identifier for the operation. 38 | Id *uuid.UUID `json:"id,omitempty"` 39 | // Unique identifier for the plugin. 40 | PluginId *uuid.UUID `json:"pluginId,omitempty"` 41 | // The current status of the operation. 42 | Status *OperationStatus `json:"status,omitempty"` 43 | // URL to get the full operation object. 44 | Url *string `json:"url,omitempty"` 45 | } 46 | 47 | type OperationResultReference struct { 48 | // URL to the operation result. 49 | ResultUrl *string `json:"resultUrl,omitempty"` 50 | } 51 | 52 | // The status of an operation. 53 | type OperationStatus string 54 | 55 | type operationStatusValuesType struct { 56 | NotSet OperationStatus 57 | Queued OperationStatus 58 | InProgress OperationStatus 59 | Cancelled OperationStatus 60 | Succeeded OperationStatus 61 | Failed OperationStatus 62 | } 63 | 64 | var OperationStatusValues = operationStatusValuesType{ 65 | // The operation does not have a status set. 66 | NotSet: "notSet", 67 | // The operation has been queued. 68 | Queued: "queued", 69 | // The operation is in progress. 70 | InProgress: "inProgress", 71 | // The operation was cancelled by the user. 72 | Cancelled: "cancelled", 73 | // The operation completed successfully. 74 | Succeeded: "succeeded", 75 | // The operation completed with a failure. 76 | Failed: "failed", 77 | } 78 | -------------------------------------------------------------------------------- /azuredevops/v6/packagingshared/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package packagingshared 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | ) 14 | 15 | // Data required for promoting multiple package versions. Pass this while performing {protocol}BatchOperationTypes.Promote batch operation. 16 | type BatchPromoteData struct { 17 | // Id or Name of the view, packages need to be promoted to. 18 | ViewId *string `json:"viewId,omitempty"` 19 | } 20 | 21 | // Minimal package details required to identify a package within a protocol. 22 | type MinimalPackageDetails struct { 23 | // Package name. 24 | Id *string `json:"id,omitempty"` 25 | // Package version. 26 | Version *string `json:"version,omitempty"` 27 | } 28 | 29 | // Type of an upstream source, such as Public or Internal. 30 | type PackagingSourceType string 31 | 32 | type packagingSourceTypeValuesType struct { 33 | Public PackagingSourceType 34 | Internal PackagingSourceType 35 | } 36 | 37 | var PackagingSourceTypeValues = packagingSourceTypeValuesType{ 38 | // Publicly available source. 39 | Public: "public", 40 | // Azure DevOps upstream source. 41 | Internal: "internal", 42 | } 43 | 44 | // Upstream source definition, including its Identity, package type, and other associated information. 45 | type UpstreamSourceInfo struct { 46 | // Locator for connecting to the upstream source in a user friendly format, that may potentially change over time 47 | DisplayLocation *string `json:"displayLocation,omitempty"` 48 | // Identity of the upstream source. 49 | Id *uuid.UUID `json:"id,omitempty"` 50 | // Locator for connecting to the upstream source 51 | Location *string `json:"location,omitempty"` 52 | // Display name. 53 | Name *string `json:"name,omitempty"` 54 | // Source type, such as Public or Internal. 55 | SourceType *PackagingSourceType `json:"sourceType,omitempty"` 56 | } 57 | -------------------------------------------------------------------------------- /azuredevops/v6/pipelinepermissions/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package pipelinepermissions 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6/pipelineschecks" 15 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6/webapi" 16 | ) 17 | 18 | type Permission struct { 19 | Authorized *bool `json:"authorized,omitempty"` 20 | AuthorizedBy *webapi.IdentityRef `json:"authorizedBy,omitempty"` 21 | AuthorizedOn *azuredevops.Time `json:"authorizedOn,omitempty"` 22 | } 23 | 24 | type PipelinePermission struct { 25 | Authorized *bool `json:"authorized,omitempty"` 26 | AuthorizedBy *webapi.IdentityRef `json:"authorizedBy,omitempty"` 27 | AuthorizedOn *azuredevops.Time `json:"authorizedOn,omitempty"` 28 | Id *int `json:"id,omitempty"` 29 | } 30 | 31 | type PipelineProcessResources struct { 32 | Resources *[]PipelineResourceReference `json:"resources,omitempty"` 33 | } 34 | 35 | type PipelineResourceReference struct { 36 | Authorized *bool `json:"authorized,omitempty"` 37 | AuthorizedBy *uuid.UUID `json:"authorizedBy,omitempty"` 38 | AuthorizedOn *azuredevops.Time `json:"authorizedOn,omitempty"` 39 | DefinitionId *int `json:"definitionId,omitempty"` 40 | Id *string `json:"id,omitempty"` 41 | Type *string `json:"type,omitempty"` 42 | } 43 | 44 | type ResourcePipelinePermissions struct { 45 | AllPipelines *Permission `json:"allPipelines,omitempty"` 46 | Pipelines *[]PipelinePermission `json:"pipelines,omitempty"` 47 | Resource *pipelineschecks.Resource `json:"resource,omitempty"` 48 | } 49 | -------------------------------------------------------------------------------- /azuredevops/v6/pipelinestaskcheck/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package pipelinestaskcheck 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | ) 14 | 15 | // Config to facilitate task check 16 | type TaskCheckConfig struct { 17 | DefinitionRef *TaskCheckDefinitionReference `json:"definitionRef,omitempty"` 18 | DisplayName *string `json:"displayName,omitempty"` 19 | Inputs *map[string]string `json:"inputs,omitempty"` 20 | LinkedVariableGroup *string `json:"linkedVariableGroup,omitempty"` 21 | RetryInterval *int `json:"retryInterval,omitempty"` 22 | } 23 | 24 | type TaskCheckDefinitionReference struct { 25 | Id *uuid.UUID `json:"id,omitempty"` 26 | Name *string `json:"name,omitempty"` 27 | Version *string `json:"version,omitempty"` 28 | } 29 | -------------------------------------------------------------------------------- /azuredevops/v6/profile/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package profile 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 15 | "net/http" 16 | "net/url" 17 | "strconv" 18 | ) 19 | 20 | var ResourceAreaId, _ = uuid.Parse("8ccfef3d-2b87-4e99-8ccb-66e343d2daa8") 21 | 22 | type Client interface { 23 | // Gets a user profile. 24 | GetProfile(context.Context, GetProfileArgs) (*Profile, error) 25 | } 26 | 27 | type ClientImpl struct { 28 | Client azuredevops.Client 29 | } 30 | 31 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 32 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 33 | if err != nil { 34 | return nil, err 35 | } 36 | return &ClientImpl{ 37 | Client: *client, 38 | }, nil 39 | } 40 | 41 | // Gets a user profile. 42 | func (client *ClientImpl) GetProfile(ctx context.Context, args GetProfileArgs) (*Profile, error) { 43 | routeValues := make(map[string]string) 44 | if args.Id == nil || *args.Id == "" { 45 | return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Id"} 46 | } 47 | routeValues["id"] = *args.Id 48 | 49 | queryParams := url.Values{} 50 | if args.Details != nil { 51 | queryParams.Add("details", strconv.FormatBool(*args.Details)) 52 | } 53 | if args.WithAttributes != nil { 54 | queryParams.Add("withAttributes", strconv.FormatBool(*args.WithAttributes)) 55 | } 56 | if args.Partition != nil { 57 | queryParams.Add("partition", *args.Partition) 58 | } 59 | if args.CoreAttributes != nil { 60 | queryParams.Add("coreAttributes", *args.CoreAttributes) 61 | } 62 | if args.ForceRefresh != nil { 63 | queryParams.Add("forceRefresh", strconv.FormatBool(*args.ForceRefresh)) 64 | } 65 | locationId, _ := uuid.Parse("f83735dc-483f-4238-a291-d45f6080a9af") 66 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0", routeValues, queryParams, nil, "", "application/json", nil) 67 | if err != nil { 68 | return nil, err 69 | } 70 | 71 | var responseValue Profile 72 | err = client.Client.UnmarshalBody(resp, &responseValue) 73 | return &responseValue, err 74 | } 75 | 76 | // Arguments for the GetProfile function 77 | type GetProfileArgs struct { 78 | // (required) The ID of the target user profile within the same organization, or 'me' to get the profile of the current authenticated user. 79 | Id *string 80 | // (optional) Return public profile information such as display name, email address, country, etc. If false, the withAttributes parameter is ignored. 81 | Details *bool 82 | // (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. 83 | WithAttributes *bool 84 | // (optional) The partition (named group) of attributes to return. 85 | Partition *string 86 | // (optional) A comma-delimited list of core profile attributes to return. Valid values are Email, Avatar, DisplayName, and ContactWithOffers. 87 | CoreAttributes *string 88 | // (optional) Not used in this version of the API. 89 | ForceRefresh *bool 90 | } 91 | -------------------------------------------------------------------------------- /azuredevops/v6/profileregions/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package profileregions 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 15 | "net/http" 16 | "net/url" 17 | ) 18 | 19 | var ResourceAreaId, _ = uuid.Parse("8ccfef3d-2b87-4e99-8ccb-66e343d2daa8") 20 | 21 | type Client interface { 22 | // [Preview API] Lookup up country/region based on provided IPv4, null if using the remote IPv4 address. 23 | GetGeoRegion(context.Context, GetGeoRegionArgs) (*GeoRegion, error) 24 | // [Preview API] 25 | GetRegions(context.Context, GetRegionsArgs) (*ProfileRegions, error) 26 | } 27 | 28 | type ClientImpl struct { 29 | Client azuredevops.Client 30 | } 31 | 32 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 33 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 34 | if err != nil { 35 | return nil, err 36 | } 37 | return &ClientImpl{ 38 | Client: *client, 39 | }, nil 40 | } 41 | 42 | // [Preview API] Lookup up country/region based on provided IPv4, null if using the remote IPv4 address. 43 | func (client *ClientImpl) GetGeoRegion(ctx context.Context, args GetGeoRegionArgs) (*GeoRegion, error) { 44 | queryParams := url.Values{} 45 | if args.Ip == nil { 46 | return nil, &azuredevops.ArgumentNilError{ArgumentName: "ip"} 47 | } 48 | queryParams.Add("ip", *args.Ip) 49 | locationId, _ := uuid.Parse("35b3ff1d-ab4c-4d1c-98bb-f6ea21d86bd9") 50 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0-preview.1", nil, queryParams, nil, "", "application/json", nil) 51 | if err != nil { 52 | return nil, err 53 | } 54 | 55 | var responseValue GeoRegion 56 | err = client.Client.UnmarshalBody(resp, &responseValue) 57 | return &responseValue, err 58 | } 59 | 60 | // Arguments for the GetGeoRegion function 61 | type GetGeoRegionArgs struct { 62 | // (required) 63 | Ip *string 64 | } 65 | 66 | // [Preview API] 67 | func (client *ClientImpl) GetRegions(ctx context.Context, args GetRegionsArgs) (*ProfileRegions, error) { 68 | locationId, _ := uuid.Parse("b129ca90-999d-47bb-ab37-0dcf784ee633") 69 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "6.0-preview.1", nil, nil, nil, "", "application/json", nil) 70 | if err != nil { 71 | return nil, err 72 | } 73 | 74 | var responseValue ProfileRegions 75 | err = client.Client.UnmarshalBody(resp, &responseValue) 76 | return &responseValue, err 77 | } 78 | 79 | // Arguments for the GetRegions function 80 | type GetRegionsArgs struct { 81 | } 82 | -------------------------------------------------------------------------------- /azuredevops/v6/profileregions/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package profileregions 10 | 11 | type GeoRegion struct { 12 | RegionCode *string `json:"regionCode,omitempty"` 13 | } 14 | 15 | // Country/region information 16 | type ProfileRegion struct { 17 | // The two-letter code defined in ISO 3166 for the country/region. 18 | Code *string `json:"code,omitempty"` 19 | // Localized country/region name 20 | Name *string `json:"name,omitempty"` 21 | } 22 | 23 | // Container of country/region information 24 | type ProfileRegions struct { 25 | // List of country/region code with contact consent requirement type of notice 26 | NoticeContactConsentRequirementRegions *[]string `json:"noticeContactConsentRequirementRegions,omitempty"` 27 | // List of country/region code with contact consent requirement type of opt-out 28 | OptOutContactConsentRequirementRegions *[]string `json:"optOutContactConsentRequirementRegions,omitempty"` 29 | // List of country/regions 30 | Regions *[]ProfileRegion `json:"regions,omitempty"` 31 | } 32 | -------------------------------------------------------------------------------- /azuredevops/v6/provenance/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package provenance 10 | 11 | import ( 12 | "bytes" 13 | "context" 14 | "encoding/json" 15 | "github.com/google/uuid" 16 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 17 | "net/http" 18 | ) 19 | 20 | var ResourceAreaId, _ = uuid.Parse("b40c1171-807a-493a-8f3f-5c26d5e2f5aa") 21 | 22 | type Client interface { 23 | // [Preview API] Creates a session, a wrapper around a feed that can store additional metadata on the packages published to it. 24 | CreateSession(context.Context, CreateSessionArgs) (*SessionResponse, error) 25 | } 26 | 27 | type ClientImpl struct { 28 | Client azuredevops.Client 29 | } 30 | 31 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 32 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 33 | if err != nil { 34 | return nil, err 35 | } 36 | return &ClientImpl{ 37 | Client: *client, 38 | }, nil 39 | } 40 | 41 | // [Preview API] Creates a session, a wrapper around a feed that can store additional metadata on the packages published to it. 42 | func (client *ClientImpl) CreateSession(ctx context.Context, args CreateSessionArgs) (*SessionResponse, error) { 43 | if args.SessionRequest == nil { 44 | return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SessionRequest"} 45 | } 46 | routeValues := make(map[string]string) 47 | if args.Project != nil && *args.Project != "" { 48 | routeValues["project"] = *args.Project 49 | } 50 | if args.Protocol == nil || *args.Protocol == "" { 51 | return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Protocol"} 52 | } 53 | routeValues["protocol"] = *args.Protocol 54 | 55 | body, marshalErr := json.Marshal(*args.SessionRequest) 56 | if marshalErr != nil { 57 | return nil, marshalErr 58 | } 59 | locationId, _ := uuid.Parse("503b4e54-ebf4-4d04-8eee-21c00823c2ac") 60 | resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "6.0-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) 61 | if err != nil { 62 | return nil, err 63 | } 64 | 65 | var responseValue SessionResponse 66 | err = client.Client.UnmarshalBody(resp, &responseValue) 67 | return &responseValue, err 68 | } 69 | 70 | // Arguments for the CreateSession function 71 | type CreateSessionArgs struct { 72 | // (required) The feed and metadata for the session 73 | SessionRequest *SessionRequest 74 | // (required) The protocol that the session will target 75 | Protocol *string 76 | // (optional) Project ID or project name 77 | Project *string 78 | } 79 | -------------------------------------------------------------------------------- /azuredevops/v6/provenance/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package provenance 10 | 11 | type SessionRequest struct { 12 | // Generic property bag to store data about the session 13 | Data *map[string]string `json:"data,omitempty"` 14 | // The feed name or id for the session 15 | Feed *string `json:"feed,omitempty"` 16 | // 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 17 | Source *string `json:"source,omitempty"` 18 | } 19 | 20 | type SessionResponse struct { 21 | // The unique identifier for the session 22 | SessionId *string `json:"sessionId,omitempty"` 23 | // The name for the session 24 | SessionName *string `json:"sessionName,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /azuredevops/v6/pypiapi/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package pypiapi 10 | 11 | import ( 12 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 13 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6/packagingshared" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6/webapi" 15 | ) 16 | 17 | // Package version metadata for a Python package 18 | type Package struct { 19 | // Related REST links. 20 | Links interface{} `json:"_links,omitempty"` 21 | // If and when the package was deleted. 22 | DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` 23 | // Package Id. 24 | Id *string `json:"id,omitempty"` 25 | // The display name of the package. 26 | Name *string `json:"name,omitempty"` 27 | // If and when the package was permanently deleted. 28 | PermanentlyDeletedDate *azuredevops.Time `json:"permanentlyDeletedDate,omitempty"` 29 | // The history of upstream sources for this package. The first source in the list is the immediate source from which this package was saved. 30 | SourceChain *[]packagingshared.UpstreamSourceInfo `json:"sourceChain,omitempty"` 31 | // The version of the package. 32 | Version *string `json:"version,omitempty"` 33 | } 34 | 35 | type PackageVersionDetails struct { 36 | // The view to which the package version will be added 37 | Views *webapi.JsonPatchOperation `json:"views,omitempty"` 38 | } 39 | 40 | // Describes PyPi batch operation types. 41 | type PyPiBatchOperationType string 42 | 43 | type pyPiBatchOperationTypeValuesType struct { 44 | Promote PyPiBatchOperationType 45 | Delete PyPiBatchOperationType 46 | PermanentDelete PyPiBatchOperationType 47 | RestoreToFeed PyPiBatchOperationType 48 | } 49 | 50 | var PyPiBatchOperationTypeValues = pyPiBatchOperationTypeValuesType{ 51 | // 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. 52 | Promote: "promote", 53 | // Move package versions to the feed's Recycle Bin. Not supported in the Recycle Bin. 54 | Delete: "delete", 55 | // Permanently delete package versions. Only supported in the Recycle Bin. 56 | PermanentDelete: "permanentDelete", 57 | // Restore deleted package versions to the feed. Only supported in the Recycle Bin. 58 | RestoreToFeed: "restoreToFeed", 59 | } 60 | 61 | // A batch of operations to apply to package versions. 62 | type PyPiPackagesBatchRequest struct { 63 | // Data required to perform the operation. This is optional based on the type of the operation. Use BatchPromoteData if performing a promote operation. 64 | Data interface{} `json:"data,omitempty"` 65 | // Type of operation that needs to be performed on packages. 66 | Operation *PyPiBatchOperationType `json:"operation,omitempty"` 67 | // The packages onto which the operation will be performed. 68 | Packages *[]packagingshared.MinimalPackageDetails `json:"packages,omitempty"` 69 | } 70 | 71 | // Deletion state of a Python package. 72 | type PyPiPackageVersionDeletionState struct { 73 | // UTC date the package was deleted. 74 | DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` 75 | // Name of the package. 76 | Name *string `json:"name,omitempty"` 77 | // Version of the package. 78 | Version *string `json:"version,omitempty"` 79 | } 80 | 81 | type PyPiRecycleBinPackageVersionDetails struct { 82 | // Setting to false will undo earlier deletion and restore the package to feed. 83 | Deleted *bool `json:"deleted,omitempty"` 84 | } 85 | -------------------------------------------------------------------------------- /azuredevops/v6/symbolcommon/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package symbolcommon 10 | 11 | // [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. 12 | type DebugInformationLevel string 13 | 14 | type debugInformationLevelValuesType struct { 15 | None DebugInformationLevel 16 | Binary DebugInformationLevel 17 | Publics DebugInformationLevel 18 | TraceFormatPresent DebugInformationLevel 19 | TypeInfo DebugInformationLevel 20 | LineNumbers DebugInformationLevel 21 | GlobalSymbols DebugInformationLevel 22 | Private DebugInformationLevel 23 | SourceIndexed DebugInformationLevel 24 | } 25 | 26 | var DebugInformationLevelValues = debugInformationLevelValuesType{ 27 | // If set, the .pdb file contains no debug information. 28 | None: "none", 29 | // If set, the .pdb file contains debug information which is binary. 30 | Binary: "binary", 31 | // If set, the .pdb file contains public symbols. 32 | Publics: "publics", 33 | // If set, the .pdb file contains trace format. 34 | TraceFormatPresent: "traceFormatPresent", 35 | // If set, the .pdb file contains type information. 36 | TypeInfo: "typeInfo", 37 | // If set, the .pdb file contains line number information. 38 | LineNumbers: "lineNumbers", 39 | // If set, the .pdb file contains symbol information. 40 | GlobalSymbols: "globalSymbols", 41 | // If set, the .pdb file contains public symbols and has type, line number and symbol information. 42 | Private: "private", 43 | // If set, the .pdb file supports the source server. 44 | SourceIndexed: "sourceIndexed", 45 | } 46 | -------------------------------------------------------------------------------- /azuredevops/v6/system/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package system 10 | 11 | type SqlDbType string 12 | 13 | type sqlDbTypeValuesType struct { 14 | BigInt SqlDbType 15 | Binary SqlDbType 16 | Bit SqlDbType 17 | Char SqlDbType 18 | DateTime SqlDbType 19 | Decimal SqlDbType 20 | Float SqlDbType 21 | Image SqlDbType 22 | Int SqlDbType 23 | Money SqlDbType 24 | NChar SqlDbType 25 | NText SqlDbType 26 | NVarChar SqlDbType 27 | Real SqlDbType 28 | UniqueIdentifier SqlDbType 29 | SmallDateTime SqlDbType 30 | SmallInt SqlDbType 31 | SmallMoney SqlDbType 32 | Text SqlDbType 33 | Timestamp SqlDbType 34 | TinyInt SqlDbType 35 | VarBinary SqlDbType 36 | VarChar SqlDbType 37 | Variant SqlDbType 38 | Xml SqlDbType 39 | Udt SqlDbType 40 | Structured SqlDbType 41 | Date SqlDbType 42 | Time SqlDbType 43 | DateTime2 SqlDbType 44 | DateTimeOffset SqlDbType 45 | } 46 | 47 | var SqlDbTypeValues = sqlDbTypeValuesType{ 48 | BigInt: "bigInt", 49 | Binary: "binary", 50 | Bit: "bit", 51 | Char: "char", 52 | DateTime: "dateTime", 53 | Decimal: "decimal", 54 | Float: "float", 55 | Image: "image", 56 | Int: "int", 57 | Money: "money", 58 | NChar: "nChar", 59 | NText: "nText", 60 | NVarChar: "nVarChar", 61 | Real: "real", 62 | UniqueIdentifier: "uniqueIdentifier", 63 | SmallDateTime: "smallDateTime", 64 | SmallInt: "smallInt", 65 | SmallMoney: "smallMoney", 66 | Text: "text", 67 | Timestamp: "timestamp", 68 | TinyInt: "tinyInt", 69 | VarBinary: "varBinary", 70 | VarChar: "varChar", 71 | Variant: "variant", 72 | Xml: "xml", 73 | Udt: "udt", 74 | Structured: "structured", 75 | Date: "date", 76 | Time: "time", 77 | DateTime2: "dateTime2", 78 | DateTimeOffset: "dateTimeOffset", 79 | } 80 | 81 | type TraceLevel string 82 | 83 | type traceLevelValuesType struct { 84 | Off TraceLevel 85 | Error TraceLevel 86 | Warning TraceLevel 87 | Info TraceLevel 88 | Verbose TraceLevel 89 | } 90 | 91 | var TraceLevelValues = traceLevelValuesType{ 92 | Off: "off", 93 | Error: "error", 94 | Warning: "warning", 95 | Info: "info", 96 | Verbose: "verbose", 97 | } 98 | -------------------------------------------------------------------------------- /azuredevops/v6/testresults/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package testresults 10 | 11 | type Attachment struct { 12 | CompressionType *string `json:"compressionType,omitempty"` 13 | FileName *string `json:"fileName,omitempty"` 14 | Stream interface{} `json:"stream,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /azuredevops/v6/tokenadmin/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package tokenadmin 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6/delegatedauthorization" 15 | ) 16 | 17 | // A paginated list of session tokens. Session tokens correspond to OAuth credentials such as personal access tokens (PATs) and other OAuth authorizations. 18 | type TokenAdminPagedSessionTokens struct { 19 | // The continuation token that can be used to retrieve the next page of session tokens, or null if there is no next page. 20 | ContinuationToken *uuid.UUID `json:"continuationToken,omitempty"` 21 | // The list of all session tokens in the current page. 22 | Value *[]delegatedauthorization.SessionToken `json:"value,omitempty"` 23 | } 24 | 25 | // A request to revoke a particular delegated authorization. 26 | type TokenAdminRevocation struct { 27 | // The authorization ID of the OAuth authorization to revoke. 28 | AuthorizationId *uuid.UUID `json:"authorizationId,omitempty"` 29 | } 30 | 31 | // A rule which is applied to disable any incoming delegated authorization which matches the given properties. 32 | type TokenAdminRevocationRule struct { 33 | // 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. 34 | CreatedBefore *azuredevops.Time `json:"createdBefore,omitempty"` 35 | // 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. 36 | Scopes *string `json:"scopes,omitempty"` 37 | } 38 | -------------------------------------------------------------------------------- /azuredevops/v6/tokenadministration/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package tokenadministration 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | ) 14 | 15 | type TokenAdministrationRevocation struct { 16 | // A list of audience (target accounts) to limit the revocations to 17 | Audience *[]string `json:"audience,omitempty"` 18 | // A list of authorization ID of the OAuth authorization to revoke. 19 | AuthorizationIds *[]uuid.UUID `json:"authorizationIds,omitempty"` 20 | } 21 | -------------------------------------------------------------------------------- /azuredevops/v6/upackpackaging/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package upackpackaging 10 | 11 | import ( 12 | "github.com/microsoft/azure-devops-go-api/azuredevops/v6" 13 | ) 14 | 15 | // Describes UPack batch operation types. 16 | type UPackBatchOperationType string 17 | 18 | type uPackBatchOperationTypeValuesType struct { 19 | Promote UPackBatchOperationType 20 | Delete UPackBatchOperationType 21 | PermanentDelete UPackBatchOperationType 22 | RestoreToFeed UPackBatchOperationType 23 | } 24 | 25 | var UPackBatchOperationTypeValues = uPackBatchOperationTypeValuesType{ 26 | // 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. 27 | Promote: "promote", 28 | // Move package versions to the feed's Recycle Bin. Not supported in the Recycle Bin. 29 | Delete: "delete", 30 | // Permanently delete package versions. Only supported in the Recycle Bin. 31 | PermanentDelete: "permanentDelete", 32 | // Restore deleted package versions to the feed. Only supported in the Recycle Bin. 33 | RestoreToFeed: "restoreToFeed", 34 | } 35 | 36 | // Describes intent when calling the API GetPackageMetadata. 37 | type UPackGetPackageMetadataIntent string 38 | 39 | type uPackGetPackageMetadataIntentValuesType struct { 40 | FetchMetadataOnly UPackGetPackageMetadataIntent 41 | Download UPackGetPackageMetadataIntent 42 | } 43 | 44 | var UPackGetPackageMetadataIntentValues = uPackGetPackageMetadataIntentValuesType{ 45 | // Default. The call intends only to retrieve the package metadata. 46 | FetchMetadataOnly: "fetchMetadataOnly", 47 | // The call is part of the download flow. 48 | Download: "download", 49 | } 50 | 51 | type UPackLimitedPackageMetadata struct { 52 | Version *string `json:"version,omitempty"` 53 | } 54 | 55 | type UPackLimitedPackageMetadataListResponse struct { 56 | Count *int `json:"count,omitempty"` 57 | Value *[]UPackLimitedPackageMetadata `json:"value,omitempty"` 58 | } 59 | 60 | type UPackPackageMetadata struct { 61 | Description *string `json:"description,omitempty"` 62 | ManifestId *string `json:"manifestId,omitempty"` 63 | SuperRootId *string `json:"superRootId,omitempty"` 64 | Version *string `json:"version,omitempty"` 65 | } 66 | 67 | type UPackPackagePushMetadata struct { 68 | Description *string `json:"description,omitempty"` 69 | ManifestId *string `json:"manifestId,omitempty"` 70 | SuperRootId *string `json:"superRootId,omitempty"` 71 | Version *string `json:"version,omitempty"` 72 | ProofNodes *[]string `json:"proofNodes,omitempty"` 73 | } 74 | 75 | // Deletion state of a Universal package. 76 | type UPackPackageVersionDeletionState struct { 77 | // UTC date the package was deleted. 78 | DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` 79 | // Name of the package. 80 | Name *string `json:"name,omitempty"` 81 | // Version of the package. 82 | Version *string `json:"version,omitempty"` 83 | } 84 | -------------------------------------------------------------------------------- /azuredevops/v6/version.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | package azuredevops 5 | 6 | import ( 7 | "strconv" 8 | "strings" 9 | ) 10 | 11 | type Version struct { 12 | Major int 13 | Minor int 14 | } 15 | 16 | func NewVersion(version string) (*Version, error) { 17 | split := strings.Split(version, ".") 18 | if len(split) > 1 { 19 | major, err := strconv.Atoi(split[0]) 20 | if err != nil { 21 | return nil, err 22 | } 23 | minor, err := strconv.Atoi(split[1]) 24 | if err != nil { 25 | return nil, err 26 | } 27 | return &Version{ 28 | Major: major, 29 | Minor: minor, 30 | }, nil 31 | } 32 | return nil, &InvalidVersionStringError{version: version} 33 | } 34 | 35 | func (version Version) CompareTo(compareToVersion Version) int { 36 | if version.Major > compareToVersion.Major { 37 | return 1 38 | } else if version.Major < compareToVersion.Major { 39 | return -1 40 | } else if version.Minor > compareToVersion.Minor { 41 | return 1 42 | } else if version.Minor < compareToVersion.Minor { 43 | return -1 44 | } 45 | return 0 46 | } 47 | 48 | func (version Version) String() string { 49 | return strconv.Itoa(version.Major) + "." + strconv.Itoa(version.Minor) 50 | } 51 | 52 | type InvalidVersionStringError struct { 53 | version string 54 | } 55 | 56 | func (e *InvalidVersionStringError) Error() string { 57 | return "The version string was invalid: " + e.version 58 | } 59 | -------------------------------------------------------------------------------- /azuredevops/v6/versionnegotiation.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | package azuredevops 5 | 6 | import "strconv" 7 | 8 | func negotiateRequestVersion(location *ApiResourceLocation, apiVersion string) (string, error) { 9 | if apiVersion == "" { 10 | // if no api-version is sent to the server, the server will decide the version. The server uses the latest 11 | // released version if the endpoint has been released, otherwise it will use the latest preview version. 12 | return apiVersion, nil 13 | } 14 | 15 | matches := apiVersionRegEx.FindStringSubmatch(apiVersion) 16 | if len(matches) == 0 && matches[0] != "" { 17 | return apiVersion, &InvalidApiVersion{apiVersion} 18 | } 19 | 20 | requestedApiVersion, err := NewVersion(matches[1]) 21 | if err != nil { 22 | return apiVersion, err 23 | } 24 | locationMinVersion, err := NewVersion(*location.MinVersion) 25 | if err != nil { 26 | return apiVersion, err 27 | } 28 | if locationMinVersion.CompareTo(*requestedApiVersion) > 0 { 29 | // Client is older than the server. The server no longer supports this 30 | // resource (deprecated). 31 | return apiVersion, nil 32 | } else { 33 | locationMaxVersion, err := NewVersion(*location.MaxVersion) 34 | if err != nil { 35 | return apiVersion, err 36 | } 37 | if locationMaxVersion.CompareTo(*requestedApiVersion) < 0 { 38 | // Client is newer than the server. Negotiate down to the latest version 39 | // on the server 40 | negotiatedVersion := string(*location.MaxVersion) 41 | if *location.ReleasedVersion < *location.MaxVersion { 42 | negotiatedVersion += "-preview" 43 | } 44 | return negotiatedVersion, nil 45 | } else { 46 | // We can send at the requested api version. Make sure the resource version 47 | // is not bigger than what the server supports 48 | negotiatedVersion := matches[1] 49 | if len(matches) > 3 && matches[3] != "" { // matches '-preview' 50 | negotiatedVersion += "-preview" 51 | if len(matches) > 5 && matches[5] != "" { // has a resource version 52 | requestedResourceVersion, _ := strconv.Atoi(matches[5]) 53 | if *location.ResourceVersion < requestedResourceVersion { 54 | negotiatedVersion += "." + strconv.Itoa(*location.ResourceVersion) 55 | } else { 56 | negotiatedVersion += "." + matches[5] 57 | } 58 | } 59 | } else { 60 | // requesting released version, ensure server supports a released version, and if not append '-preview' 61 | locationReleasedVersion, err := NewVersion(*location.ReleasedVersion) 62 | if err != nil { 63 | return apiVersion, err 64 | } 65 | if (locationReleasedVersion.Major == 0 && locationReleasedVersion.Minor == 0) || locationReleasedVersion.CompareTo(*requestedApiVersion) < 0 { 66 | negotiatedVersion += "-preview" 67 | } 68 | } 69 | return negotiatedVersion, nil 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /azuredevops/v6/versionnegotiation_test.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestNegotiateRequestVersion_NonReleasedApi(t *testing.T) { 8 | // key is requested version, value is expected negotiated version 9 | tests := make(map[string]string) 10 | tests[""] = "" 11 | tests["2.2-preview.4"] = "2.2-preview.3" 12 | tests["2.2-preview"] = "2.2-preview" 13 | tests["2.2-preview.3"] = "2.2-preview.3" 14 | tests["2.2-preview.2"] = "2.2-preview.2" 15 | tests["2.1-preview.4"] = "2.1-preview.3" 16 | tests["2.1-preview.3"] = "2.1-preview.3" 17 | tests["1.0-preview.3"] = "1.0-preview.3" 18 | tests["2.2"] = "2.2-preview" 19 | tests["1.0"] = "1.0-preview" 20 | tests["2.2-preview"] = "2.2-preview" 21 | tests["1.0-preview"] = "1.0-preview" 22 | tests["2.3-preview"] = "2.2-preview" 23 | tests["3.0-preview"] = "2.2-preview" 24 | 25 | for requested, expected := range tests { 26 | compareVersions(t, unreleasedApiResourceLocation, requested, expected) 27 | } 28 | } 29 | 30 | func TestNegotiateRequestVersion_ReleasedApi(t *testing.T) { 31 | // key is requested version, value is expected negotiated version 32 | tests := make(map[string]string) 33 | tests[""] = "" 34 | tests["2.2-preview.4"] = "2.2-preview.3" 35 | tests["2.2-preview"] = "2.2-preview" 36 | tests["2.2-preview.3"] = "2.2-preview.3" 37 | tests["2.2-preview.2"] = "2.2-preview.2" 38 | tests["2.1-preview.4"] = "2.1-preview.3" 39 | tests["2.1-preview.3"] = "2.1-preview.3" 40 | tests["1.0-preview.3"] = "1.0-preview.3" 41 | tests["2.2-preview"] = "2.2-preview" 42 | tests["1.0-preview"] = "1.0-preview" 43 | tests["2.3-preview"] = "2.2-preview" 44 | tests["3.0-preview"] = "2.2-preview" 45 | tests["3.0"] = "2.2-preview" 46 | tests["2.3"] = "2.2-preview" 47 | tests["2.2"] = "2.2-preview" 48 | tests["2.1"] = "2.1" 49 | tests["2.0"] = "2.0" 50 | tests["1.0"] = "1.0" 51 | 52 | for requested, expected := range tests { 53 | compareVersions(t, releasedApiResourceLocation, requested, expected) 54 | } 55 | } 56 | 57 | func compareVersions(t *testing.T, apiResourceLocation *ApiResourceLocation, requestedVersion string, expectedVersion string) { 58 | negotiatedVersion, err := negotiateRequestVersion(apiResourceLocation, requestedVersion) 59 | if err != nil { 60 | t.Errorf("Unexpected error: %v", err) 61 | } 62 | if negotiatedVersion != expectedVersion { 63 | t.Errorf("Negotiated version did not match expected. Requested: %v Expected: %v Actual: %v", requestedVersion, expectedVersion, negotiatedVersion) 64 | } 65 | } 66 | 67 | var resourceVersionThree = 3 68 | var version00 = "0.0" 69 | var version10 = "1.0" 70 | var version20 = "2.0" 71 | var version21 = "2.1" 72 | var version22 = "2.2" 73 | 74 | var unreleasedApiResourceLocation = &ApiResourceLocation{ 75 | ResourceVersion: &resourceVersionThree, 76 | MinVersion: &version10, 77 | MaxVersion: &version22, 78 | ReleasedVersion: &version00, 79 | } 80 | 81 | var releasedApiResourceLocation = &ApiResourceLocation{ 82 | ResourceVersion: &resourceVersionThree, 83 | MinVersion: &version20, 84 | MaxVersion: &version22, 85 | ReleasedVersion: &version21, 86 | } 87 | -------------------------------------------------------------------------------- /azuredevops/v7/accounts/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package accounts 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7" 15 | "net/http" 16 | "net/url" 17 | ) 18 | 19 | var ResourceAreaId, _ = uuid.Parse("0d55247a-1c47-4462-9b1f-5e2125590ee6") 20 | 21 | type Client interface { 22 | // [Preview API] Get a list of accounts for a specific owner or a specific member. One of the following parameters is required: ownerId, memberId. 23 | GetAccounts(context.Context, GetAccountsArgs) (*[]Account, error) 24 | } 25 | 26 | type ClientImpl struct { 27 | Client azuredevops.Client 28 | } 29 | 30 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 31 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 32 | if err != nil { 33 | return nil, err 34 | } 35 | return &ClientImpl{ 36 | Client: *client, 37 | }, nil 38 | } 39 | 40 | // [Preview API] Get a list of accounts for a specific owner or a specific member. One of the following parameters is required: ownerId, memberId. 41 | func (client *ClientImpl) GetAccounts(ctx context.Context, args GetAccountsArgs) (*[]Account, error) { 42 | queryParams := url.Values{} 43 | if args.OwnerId != nil { 44 | queryParams.Add("ownerId", (*args.OwnerId).String()) 45 | } 46 | if args.MemberId != nil { 47 | queryParams.Add("memberId", (*args.MemberId).String()) 48 | } 49 | if args.Properties != nil { 50 | queryParams.Add("properties", *args.Properties) 51 | } 52 | locationId, _ := uuid.Parse("229a6a53-b428-4ffb-a835-e8f36b5b4b1e") 53 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "7.1-preview.1", nil, queryParams, nil, "", "application/json", nil) 54 | if err != nil { 55 | return nil, err 56 | } 57 | 58 | var responseValue []Account 59 | err = client.Client.UnmarshalCollectionBody(resp, &responseValue) 60 | return &responseValue, err 61 | } 62 | 63 | // Arguments for the GetAccounts function 64 | type GetAccountsArgs struct { 65 | // (optional) ID for the owner of the accounts. 66 | OwnerId *uuid.UUID 67 | // (optional) ID for a member of the accounts. 68 | MemberId *uuid.UUID 69 | // (optional) 70 | Properties *string 71 | } 72 | -------------------------------------------------------------------------------- /azuredevops/v7/client_options.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | // ClientOptionFunc can be used customize a new AzureDevops API client. 8 | type ClientOptionFunc func(*Client) 9 | 10 | // WithHTTPClient can be used to configure a custom HTTP client. 11 | func WithHTTPClient(httpClient *http.Client) ClientOptionFunc { 12 | return func(c *Client) { 13 | c.client = httpClient 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /azuredevops/v7/client_test.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | import ( 4 | "crypto/tls" 5 | "net/http" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | func TestClient_NewClient(t *testing.T) { 11 | tlsConfig := &tls.Config{} 12 | timeout := 20 * time.Millisecond 13 | 14 | conn := &Connection{ 15 | TlsConfig: tlsConfig, 16 | Timeout: &timeout, 17 | } 18 | baseURL := "localhost" 19 | client := NewClient(conn, baseURL) 20 | if client.baseUrl != baseURL { 21 | t.Errorf("Expected baseURL: %v Actual baseURL: %v", baseURL, client.baseUrl) 22 | } 23 | if actualTLSConfig := client.client.Transport.(*http.Transport).TLSClientConfig; actualTLSConfig != tlsConfig { 24 | t.Errorf("Expected tlsConfig: %v Actual tlsConfig: %v", tlsConfig, actualTLSConfig) 25 | } 26 | } 27 | 28 | func TestClient_NewClientWithOptions_WithHTTPClient(t *testing.T) { 29 | tlsConfig := &tls.Config{} 30 | httpTimeout := 20 * time.Millisecond 31 | connTimeout := 40 * time.Millisecond 32 | 33 | conn := &Connection{ 34 | TlsConfig: tlsConfig, 35 | Timeout: &connTimeout, // will be ignored in favour of httpTimeout 36 | } 37 | 38 | httpClient := &http.Client{Timeout: httpTimeout} 39 | baseURL := "localhost" 40 | 41 | client := NewClientWithOptions(conn, baseURL, WithHTTPClient(httpClient)) 42 | if client.baseUrl != baseURL { 43 | t.Errorf("Expected baseURL: %v Actual baseURL: %v", baseURL, client.baseUrl) 44 | } 45 | if actualHTTPClient := client.client; actualHTTPClient.Timeout != httpClient.Timeout { 46 | t.Errorf("Expected httpClient.Timeout: %#v Actual httpClient.Timeout: %#v", httpClient.Timeout, actualHTTPClient.Timeout) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /azuredevops/v7/clienttrace/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package clienttrace 10 | 11 | import ( 12 | "bytes" 13 | "context" 14 | "encoding/json" 15 | "github.com/google/uuid" 16 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7" 17 | "net/http" 18 | ) 19 | 20 | type Client interface { 21 | // [Preview API] 22 | PublishEvents(context.Context, PublishEventsArgs) error 23 | } 24 | 25 | type ClientImpl struct { 26 | Client azuredevops.Client 27 | } 28 | 29 | func NewClient(ctx context.Context, connection *azuredevops.Connection) Client { 30 | client := connection.GetClientByUrl(connection.BaseUrl) 31 | return &ClientImpl{ 32 | Client: *client, 33 | } 34 | } 35 | 36 | // [Preview API] 37 | func (client *ClientImpl) PublishEvents(ctx context.Context, args PublishEventsArgs) error { 38 | if args.Events == nil { 39 | return &azuredevops.ArgumentNilError{ArgumentName: "args.Events"} 40 | } 41 | body, marshalErr := json.Marshal(*args.Events) 42 | if marshalErr != nil { 43 | return marshalErr 44 | } 45 | locationId, _ := uuid.Parse("06bcc74a-1491-4eb8-a0eb-704778f9d041") 46 | _, err := client.Client.Send(ctx, http.MethodPost, locationId, "7.1-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) 47 | if err != nil { 48 | return err 49 | } 50 | 51 | return nil 52 | } 53 | 54 | // Arguments for the PublishEvents function 55 | type PublishEventsArgs struct { 56 | // (required) 57 | Events *[]ClientTraceEvent 58 | } 59 | -------------------------------------------------------------------------------- /azuredevops/v7/clienttrace/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package clienttrace 10 | 11 | type ClientTraceEvent struct { 12 | Area *string `json:"area,omitempty"` 13 | Component *string `json:"component,omitempty"` 14 | ExceptionType *string `json:"exceptionType,omitempty"` 15 | Feature *string `json:"feature,omitempty"` 16 | Level *Level `json:"level,omitempty"` 17 | Message *string `json:"message,omitempty"` 18 | Method *string `json:"method,omitempty"` 19 | Properties *map[string]interface{} `json:"properties,omitempty"` 20 | } 21 | 22 | type Level string 23 | 24 | type levelValuesType struct { 25 | Off Level 26 | Error Level 27 | Warning Level 28 | Info Level 29 | Verbose Level 30 | } 31 | 32 | var LevelValues = levelValuesType{ 33 | Off: "off", 34 | Error: "error", 35 | Warning: "warning", 36 | Info: "info", 37 | Verbose: "verbose", 38 | } 39 | -------------------------------------------------------------------------------- /azuredevops/v7/customerintelligence/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package customerintelligence 10 | 11 | import ( 12 | "bytes" 13 | "context" 14 | "encoding/json" 15 | "github.com/google/uuid" 16 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7" 17 | "net/http" 18 | ) 19 | 20 | type Client interface { 21 | // [Preview API] 22 | PublishEvents(context.Context, PublishEventsArgs) error 23 | } 24 | 25 | type ClientImpl struct { 26 | Client azuredevops.Client 27 | } 28 | 29 | func NewClient(ctx context.Context, connection *azuredevops.Connection) Client { 30 | client := connection.GetClientByUrl(connection.BaseUrl) 31 | return &ClientImpl{ 32 | Client: *client, 33 | } 34 | } 35 | 36 | // [Preview API] 37 | func (client *ClientImpl) PublishEvents(ctx context.Context, args PublishEventsArgs) error { 38 | if args.Events == nil { 39 | return &azuredevops.ArgumentNilError{ArgumentName: "args.Events"} 40 | } 41 | body, marshalErr := json.Marshal(*args.Events) 42 | if marshalErr != nil { 43 | return marshalErr 44 | } 45 | locationId, _ := uuid.Parse("b5cc35c2-ff2b-491d-a085-24b6e9f396fd") 46 | _, err := client.Client.Send(ctx, http.MethodPost, locationId, "7.1-preview.1", nil, nil, bytes.NewReader(body), "application/json", "application/json", nil) 47 | if err != nil { 48 | return err 49 | } 50 | 51 | return nil 52 | } 53 | 54 | // Arguments for the PublishEvents function 55 | type PublishEventsArgs struct { 56 | // (required) 57 | Events *[]CustomerIntelligenceEvent 58 | } 59 | -------------------------------------------------------------------------------- /azuredevops/v7/customerintelligence/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package customerintelligence 10 | 11 | type CustomerIntelligenceEvent struct { 12 | Area *string `json:"area,omitempty"` 13 | Feature *string `json:"feature,omitempty"` 14 | Properties *map[string]interface{} `json:"properties,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /azuredevops/v7/distributedtaskcommon/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package distributedtaskcommon 10 | 11 | type AuthorizationHeader struct { 12 | Name *string `json:"name,omitempty"` 13 | Value *string `json:"value,omitempty"` 14 | } 15 | 16 | // Represents binding of data source for the service endpoint request. 17 | type DataSourceBindingBase struct { 18 | // Pagination format supported by this data source(ContinuationToken/SkipTop). 19 | CallbackContextTemplate *string `json:"callbackContextTemplate,omitempty"` 20 | // Subsequent calls needed? 21 | CallbackRequiredTemplate *string `json:"callbackRequiredTemplate,omitempty"` 22 | // Gets or sets the name of the data source. 23 | DataSourceName *string `json:"dataSourceName,omitempty"` 24 | // Gets or sets the endpoint Id. 25 | EndpointId *string `json:"endpointId,omitempty"` 26 | // Gets or sets the url of the service endpoint. 27 | EndpointUrl *string `json:"endpointUrl,omitempty"` 28 | // Gets or sets the authorization headers. 29 | Headers *[]AuthorizationHeader `json:"headers,omitempty"` 30 | // Defines the initial value of the query params 31 | InitialContextTemplate *string `json:"initialContextTemplate,omitempty"` 32 | // Gets or sets the parameters for the data source. 33 | Parameters *map[string]string `json:"parameters,omitempty"` 34 | // Gets or sets http request body 35 | RequestContent *string `json:"requestContent,omitempty"` 36 | // Gets or sets http request verb 37 | RequestVerb *string `json:"requestVerb,omitempty"` 38 | // Gets or sets the result selector. 39 | ResultSelector *string `json:"resultSelector,omitempty"` 40 | // Gets or sets the result template. 41 | ResultTemplate *string `json:"resultTemplate,omitempty"` 42 | // Gets or sets the target of the data source. 43 | Target *string `json:"target,omitempty"` 44 | } 45 | 46 | type ProcessParameters struct { 47 | DataSourceBindings *[]DataSourceBindingBase `json:"dataSourceBindings,omitempty"` 48 | Inputs *[]TaskInputDefinitionBase `json:"inputs,omitempty"` 49 | SourceDefinitions *[]TaskSourceDefinitionBase `json:"sourceDefinitions,omitempty"` 50 | } 51 | 52 | type TaskInputDefinitionBase struct { 53 | Aliases *[]string `json:"aliases,omitempty"` 54 | DefaultValue *string `json:"defaultValue,omitempty"` 55 | GroupName *string `json:"groupName,omitempty"` 56 | HelpMarkDown *string `json:"helpMarkDown,omitempty"` 57 | Label *string `json:"label,omitempty"` 58 | Name *string `json:"name,omitempty"` 59 | Options *map[string]string `json:"options,omitempty"` 60 | Properties *map[string]string `json:"properties,omitempty"` 61 | Required *bool `json:"required,omitempty"` 62 | Type *string `json:"type,omitempty"` 63 | Validation *TaskInputValidation `json:"validation,omitempty"` 64 | VisibleRule *string `json:"visibleRule,omitempty"` 65 | } 66 | 67 | type TaskInputValidation struct { 68 | // Conditional expression 69 | Expression *string `json:"expression,omitempty"` 70 | // Message explaining how user can correct if validation fails 71 | Message *string `json:"message,omitempty"` 72 | } 73 | 74 | type TaskSourceDefinitionBase struct { 75 | AuthKey *string `json:"authKey,omitempty"` 76 | Endpoint *string `json:"endpoint,omitempty"` 77 | KeySelector *string `json:"keySelector,omitempty"` 78 | Selector *string `json:"selector,omitempty"` 79 | Target *string `json:"target,omitempty"` 80 | } 81 | -------------------------------------------------------------------------------- /azuredevops/v7/errors.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | type ArgumentNilError struct { 4 | ArgumentName string 5 | } 6 | 7 | func (e ArgumentNilError) Error() string { 8 | return "Argument " + e.ArgumentName + " can not be nil" 9 | } 10 | 11 | type ArgumentNilOrEmptyError struct { 12 | ArgumentName string 13 | } 14 | 15 | func (e ArgumentNilOrEmptyError) Error() string { 16 | return "Argument " + e.ArgumentName + " can not be nil or empty" 17 | } 18 | -------------------------------------------------------------------------------- /azuredevops/v7/featureavailability/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package featureavailability 10 | 11 | type FeatureFlag struct { 12 | Description *string `json:"description,omitempty"` 13 | EffectiveState *string `json:"effectiveState,omitempty"` 14 | ExplicitState *string `json:"explicitState,omitempty"` 15 | Name *string `json:"name,omitempty"` 16 | Uri *string `json:"uri,omitempty"` 17 | } 18 | 19 | // This is passed to the FeatureFlagController to edit the status of a feature flag 20 | type FeatureFlagPatch struct { 21 | State *string `json:"state,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /azuredevops/v7/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/microsoft/azure-devops-go-api/azuredevops/v7 2 | 3 | go 1.12 4 | 5 | require github.com/google/uuid v1.1.1 6 | -------------------------------------------------------------------------------- /azuredevops/v7/go.sum: -------------------------------------------------------------------------------- 1 | github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= 2 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 3 | -------------------------------------------------------------------------------- /azuredevops/v7/models_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | package azuredevops 5 | 6 | import ( 7 | "encoding/json" 8 | "github.com/google/uuid" 9 | "testing" 10 | "time" 11 | ) 12 | 13 | func TestModels_Unmarshal_Time(t *testing.T) { 14 | 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\"}") 15 | testModel := TestModel{} 16 | 17 | testModel.Time1 = &Time{} 18 | testModel.Time1.Time = time.Now() // this ensures we test the value is set back to default when issue #17 is hit. 19 | 20 | err := json.Unmarshal(text, &testModel) 21 | if err != nil { 22 | t.Errorf("Error occurred during deserialization: %v", err) 23 | } 24 | if (testModel.Time1.Time != time.Time{}) { 25 | t.Errorf("Expecting deserialized time to equal default time. Actual time: %v", testModel.Time1) 26 | } 27 | 28 | parsedTime, err := time.Parse(time.RFC3339Nano, "2019-09-01T00:07:26Z") 29 | if err != nil { 30 | t.Errorf(err.Error()) 31 | } 32 | if testModel.Time2.Time != parsedTime { 33 | t.Errorf("Expected time: %v Actual time: %v", parsedTime, testModel.Time2.Time) 34 | } 35 | 36 | // Test workaround for issue #59 https://github.com/microsoft/azure-devops-go-api/issues/59 37 | parsedTime59, err := time.Parse("2006-01-02T15:04:05.999999999", "2020-05-16T20:55:32.0116793") 38 | if testModel.Time3.Time != parsedTime59 { 39 | t.Errorf("Expected time: %v Actual time: %v", parsedTime59, testModel.Time3.Time) 40 | } 41 | } 42 | 43 | func TestModels_Marshal_Unmarshal_Time(t *testing.T) { 44 | testModel1 := TestModel{} 45 | testModel1.Time1 = &Time{} 46 | testModel1.Time1.Time = time.Now() 47 | b, err := json.Marshal(testModel1) 48 | if err != nil { 49 | t.Errorf(err.Error()) 50 | } 51 | 52 | testModel2 := TestModel{} 53 | err = json.Unmarshal(b, &testModel2) 54 | if err != nil { 55 | t.Errorf(err.Error()) 56 | } 57 | 58 | if testModel1.Time1 != testModel1.Time1 { 59 | t.Errorf("Expected time: %v Actual time: %v", testModel1.Time1, testModel1.Time2) 60 | } 61 | 62 | if testModel1.Time1.Time != testModel1.Time1.Time { 63 | t.Errorf("Expected time: %v Actual time: %v", testModel1.Time1.Time, testModel1.Time2.Time) 64 | } 65 | } 66 | 67 | func TestModels_Time_AsQueryParameter(t *testing.T) { 68 | tt := &Time{ 69 | // NOTE: set nsec to 0 to avoid precision loss 70 | Time: time.Date(2006, 1, 2, 3, 4, 5, 0, time.UTC), 71 | } 72 | queryParameterValue := tt.AsQueryParameter() 73 | parsedTime, err := time.Parse(time.RFC3339Nano, queryParameterValue) 74 | if err != nil { 75 | t.Errorf("invalid query parameter %s value for time: %s", tt.Time, queryParameterValue) 76 | } 77 | if !tt.Time.Equal(parsedTime) { 78 | t.Errorf("should convert back to original value: %s %s", tt.Time, parsedTime) 79 | } 80 | } 81 | 82 | type TestModel struct { 83 | Id *uuid.UUID `json:"id,omitempty"` 84 | Time1 *Time `json:"time1,omitempty"` 85 | Time2 *Time `json:"time2,omitempty"` 86 | Time3 *Time `json:"time3,omitempty"` 87 | Int *uint64 `json:"int,omitempty"` 88 | String *string `json:"string,omitempty"` 89 | } 90 | -------------------------------------------------------------------------------- /azuredevops/v7/operations/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package operations 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7" 15 | "net/http" 16 | "net/url" 17 | ) 18 | 19 | type Client interface { 20 | // [Preview API] Gets an operation from the operationId using the given pluginId. 21 | GetOperation(context.Context, GetOperationArgs) (*Operation, error) 22 | } 23 | 24 | type ClientImpl struct { 25 | Client azuredevops.Client 26 | } 27 | 28 | func NewClient(ctx context.Context, connection *azuredevops.Connection) Client { 29 | client := connection.GetClientByUrl(connection.BaseUrl) 30 | return &ClientImpl{ 31 | Client: *client, 32 | } 33 | } 34 | 35 | // [Preview API] Gets an operation from the operationId using the given pluginId. 36 | func (client *ClientImpl) GetOperation(ctx context.Context, args GetOperationArgs) (*Operation, error) { 37 | routeValues := make(map[string]string) 38 | if args.OperationId == nil { 39 | return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.OperationId"} 40 | } 41 | routeValues["operationId"] = (*args.OperationId).String() 42 | 43 | queryParams := url.Values{} 44 | if args.PluginId != nil { 45 | queryParams.Add("pluginId", (*args.PluginId).String()) 46 | } 47 | locationId, _ := uuid.Parse("9a1b74b4-2ca8-4a9f-8470-c2f2e6fdc949") 48 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "7.1-preview.1", routeValues, queryParams, nil, "", "application/json", nil) 49 | if err != nil { 50 | return nil, err 51 | } 52 | 53 | var responseValue Operation 54 | err = client.Client.UnmarshalBody(resp, &responseValue) 55 | return &responseValue, err 56 | } 57 | 58 | // Arguments for the GetOperation function 59 | type GetOperationArgs struct { 60 | // (required) The ID for the operation. 61 | OperationId *uuid.UUID 62 | // (optional) The ID for the plugin. 63 | PluginId *uuid.UUID 64 | } 65 | -------------------------------------------------------------------------------- /azuredevops/v7/operations/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package operations 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | ) 14 | 15 | // Contains information about the progress or result of an async operation. 16 | type Operation struct { 17 | // Unique identifier for the operation. 18 | Id *uuid.UUID `json:"id,omitempty"` 19 | // Unique identifier for the plugin. 20 | PluginId *uuid.UUID `json:"pluginId,omitempty"` 21 | // The current status of the operation. 22 | Status *OperationStatus `json:"status,omitempty"` 23 | // URL to get the full operation object. 24 | Url *string `json:"url,omitempty"` 25 | // Links to other related objects. 26 | Links interface{} `json:"_links,omitempty"` 27 | // Detailed messaged about the status of an operation. 28 | DetailedMessage *string `json:"detailedMessage,omitempty"` 29 | // Result message for an operation. 30 | ResultMessage *string `json:"resultMessage,omitempty"` 31 | // URL to the operation result. 32 | ResultUrl *OperationResultReference `json:"resultUrl,omitempty"` 33 | } 34 | 35 | // Reference for an async operation. 36 | type OperationReference struct { 37 | // Unique identifier for the operation. 38 | Id *uuid.UUID `json:"id,omitempty"` 39 | // Unique identifier for the plugin. 40 | PluginId *uuid.UUID `json:"pluginId,omitempty"` 41 | // The current status of the operation. 42 | Status *OperationStatus `json:"status,omitempty"` 43 | // URL to get the full operation object. 44 | Url *string `json:"url,omitempty"` 45 | } 46 | 47 | type OperationResultReference struct { 48 | // URL to the operation result. 49 | ResultUrl *string `json:"resultUrl,omitempty"` 50 | } 51 | 52 | // The status of an operation. 53 | type OperationStatus string 54 | 55 | type operationStatusValuesType struct { 56 | NotSet OperationStatus 57 | Queued OperationStatus 58 | InProgress OperationStatus 59 | Cancelled OperationStatus 60 | Succeeded OperationStatus 61 | Failed OperationStatus 62 | } 63 | 64 | var OperationStatusValues = operationStatusValuesType{ 65 | // The operation does not have a status set. 66 | NotSet: "notSet", 67 | // The operation has been queued. 68 | Queued: "queued", 69 | // The operation is in progress. 70 | InProgress: "inProgress", 71 | // The operation was cancelled by the user. 72 | Cancelled: "cancelled", 73 | // The operation completed successfully. 74 | Succeeded: "succeeded", 75 | // The operation completed with a failure. 76 | Failed: "failed", 77 | } 78 | -------------------------------------------------------------------------------- /azuredevops/v7/pipelinepermissions/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package pipelinepermissions 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7/pipelineschecks" 15 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7/webapi" 16 | ) 17 | 18 | type Permission struct { 19 | Authorized *bool `json:"authorized,omitempty"` 20 | AuthorizedBy *webapi.IdentityRef `json:"authorizedBy,omitempty"` 21 | AuthorizedOn *azuredevops.Time `json:"authorizedOn,omitempty"` 22 | } 23 | 24 | type PipelinePermission struct { 25 | Authorized *bool `json:"authorized,omitempty"` 26 | AuthorizedBy *webapi.IdentityRef `json:"authorizedBy,omitempty"` 27 | AuthorizedOn *azuredevops.Time `json:"authorizedOn,omitempty"` 28 | Id *int `json:"id,omitempty"` 29 | } 30 | 31 | type PipelineProcessResources struct { 32 | Resources *[]PipelineResourceReference `json:"resources,omitempty"` 33 | } 34 | 35 | type PipelineResourceReference struct { 36 | Authorized *bool `json:"authorized,omitempty"` 37 | AuthorizedBy *uuid.UUID `json:"authorizedBy,omitempty"` 38 | AuthorizedOn *azuredevops.Time `json:"authorizedOn,omitempty"` 39 | DefinitionId *int `json:"definitionId,omitempty"` 40 | Id *string `json:"id,omitempty"` 41 | Type *string `json:"type,omitempty"` 42 | } 43 | 44 | type ResourcePipelinePermissions struct { 45 | AllPipelines *Permission `json:"allPipelines,omitempty"` 46 | Pipelines *[]PipelinePermission `json:"pipelines,omitempty"` 47 | Resource *pipelineschecks.Resource `json:"resource,omitempty"` 48 | } 49 | -------------------------------------------------------------------------------- /azuredevops/v7/pipelinestaskcheck/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package pipelinestaskcheck 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | ) 14 | 15 | // Config to facilitate task check 16 | type TaskCheckConfig struct { 17 | DefinitionRef *TaskCheckDefinitionReference `json:"definitionRef,omitempty"` 18 | DisplayName *string `json:"displayName,omitempty"` 19 | Inputs *map[string]string `json:"inputs,omitempty"` 20 | LinkedVariableGroup *string `json:"linkedVariableGroup,omitempty"` 21 | RetryInterval *int `json:"retryInterval,omitempty"` 22 | } 23 | 24 | type TaskCheckDefinitionReference struct { 25 | Id *uuid.UUID `json:"id,omitempty"` 26 | Name *string `json:"name,omitempty"` 27 | Version *string `json:"version,omitempty"` 28 | } 29 | -------------------------------------------------------------------------------- /azuredevops/v7/profile/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package profile 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7" 15 | "net/http" 16 | "net/url" 17 | "strconv" 18 | ) 19 | 20 | var ResourceAreaId, _ = uuid.Parse("8ccfef3d-2b87-4e99-8ccb-66e343d2daa8") 21 | 22 | type Client interface { 23 | // [Preview API] Gets a user profile. 24 | GetProfile(context.Context, GetProfileArgs) (*Profile, error) 25 | } 26 | 27 | type ClientImpl struct { 28 | Client azuredevops.Client 29 | } 30 | 31 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 32 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 33 | if err != nil { 34 | return nil, err 35 | } 36 | return &ClientImpl{ 37 | Client: *client, 38 | }, nil 39 | } 40 | 41 | // [Preview API] Gets a user profile. 42 | func (client *ClientImpl) GetProfile(ctx context.Context, args GetProfileArgs) (*Profile, error) { 43 | routeValues := make(map[string]string) 44 | if args.Id == nil || *args.Id == "" { 45 | return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Id"} 46 | } 47 | routeValues["id"] = *args.Id 48 | 49 | queryParams := url.Values{} 50 | if args.Details != nil { 51 | queryParams.Add("details", strconv.FormatBool(*args.Details)) 52 | } 53 | if args.WithAttributes != nil { 54 | queryParams.Add("withAttributes", strconv.FormatBool(*args.WithAttributes)) 55 | } 56 | if args.Partition != nil { 57 | queryParams.Add("partition", *args.Partition) 58 | } 59 | if args.CoreAttributes != nil { 60 | queryParams.Add("coreAttributes", *args.CoreAttributes) 61 | } 62 | if args.ForceRefresh != nil { 63 | queryParams.Add("forceRefresh", strconv.FormatBool(*args.ForceRefresh)) 64 | } 65 | locationId, _ := uuid.Parse("f83735dc-483f-4238-a291-d45f6080a9af") 66 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "7.1-preview.3", routeValues, queryParams, nil, "", "application/json", nil) 67 | if err != nil { 68 | return nil, err 69 | } 70 | 71 | var responseValue Profile 72 | err = client.Client.UnmarshalBody(resp, &responseValue) 73 | return &responseValue, err 74 | } 75 | 76 | // Arguments for the GetProfile function 77 | type GetProfileArgs struct { 78 | // (required) The ID of the target user profile within the same organization, or 'me' to get the profile of the current authenticated user. 79 | Id *string 80 | // (optional) Return public profile information such as display name, email address, country, etc. If false, the withAttributes parameter is ignored. 81 | Details *bool 82 | // (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. 83 | WithAttributes *bool 84 | // (optional) The partition (named group) of attributes to return. 85 | Partition *string 86 | // (optional) A comma-delimited list of core profile attributes to return. Valid values are Email, Avatar, DisplayName, and ContactWithOffers. 87 | CoreAttributes *string 88 | // (optional) Not used in this version of the API. 89 | ForceRefresh *bool 90 | } 91 | -------------------------------------------------------------------------------- /azuredevops/v7/profileregions/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package profileregions 10 | 11 | import ( 12 | "context" 13 | "github.com/google/uuid" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7" 15 | "net/http" 16 | "net/url" 17 | ) 18 | 19 | var ResourceAreaId, _ = uuid.Parse("8ccfef3d-2b87-4e99-8ccb-66e343d2daa8") 20 | 21 | type Client interface { 22 | // [Preview API] Lookup up country/region based on provided IPv4, null if using the remote IPv4 address. 23 | GetGeoRegion(context.Context, GetGeoRegionArgs) (*GeoRegion, error) 24 | // [Preview API] 25 | GetRegions(context.Context, GetRegionsArgs) (*ProfileRegions, error) 26 | } 27 | 28 | type ClientImpl struct { 29 | Client azuredevops.Client 30 | } 31 | 32 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 33 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 34 | if err != nil { 35 | return nil, err 36 | } 37 | return &ClientImpl{ 38 | Client: *client, 39 | }, nil 40 | } 41 | 42 | // [Preview API] Lookup up country/region based on provided IPv4, null if using the remote IPv4 address. 43 | func (client *ClientImpl) GetGeoRegion(ctx context.Context, args GetGeoRegionArgs) (*GeoRegion, error) { 44 | queryParams := url.Values{} 45 | if args.Ip == nil { 46 | return nil, &azuredevops.ArgumentNilError{ArgumentName: "ip"} 47 | } 48 | queryParams.Add("ip", *args.Ip) 49 | locationId, _ := uuid.Parse("35b3ff1d-ab4c-4d1c-98bb-f6ea21d86bd9") 50 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "7.1-preview.1", nil, queryParams, nil, "", "application/json", nil) 51 | if err != nil { 52 | return nil, err 53 | } 54 | 55 | var responseValue GeoRegion 56 | err = client.Client.UnmarshalBody(resp, &responseValue) 57 | return &responseValue, err 58 | } 59 | 60 | // Arguments for the GetGeoRegion function 61 | type GetGeoRegionArgs struct { 62 | // (required) 63 | Ip *string 64 | } 65 | 66 | // [Preview API] 67 | func (client *ClientImpl) GetRegions(ctx context.Context, args GetRegionsArgs) (*ProfileRegions, error) { 68 | locationId, _ := uuid.Parse("b129ca90-999d-47bb-ab37-0dcf784ee633") 69 | resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "7.1-preview.1", nil, nil, nil, "", "application/json", nil) 70 | if err != nil { 71 | return nil, err 72 | } 73 | 74 | var responseValue ProfileRegions 75 | err = client.Client.UnmarshalBody(resp, &responseValue) 76 | return &responseValue, err 77 | } 78 | 79 | // Arguments for the GetRegions function 80 | type GetRegionsArgs struct { 81 | } 82 | -------------------------------------------------------------------------------- /azuredevops/v7/profileregions/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package profileregions 10 | 11 | type GeoRegion struct { 12 | RegionCode *string `json:"regionCode,omitempty"` 13 | } 14 | 15 | // Country/region information 16 | type ProfileRegion struct { 17 | // The two-letter code defined in ISO 3166 for the country/region. 18 | Code *string `json:"code,omitempty"` 19 | // Localized country/region name 20 | Name *string `json:"name,omitempty"` 21 | } 22 | 23 | // Container of country/region information 24 | type ProfileRegions struct { 25 | // List of country/region code with contact consent requirement type of notice 26 | NoticeContactConsentRequirementRegions *[]string `json:"noticeContactConsentRequirementRegions,omitempty"` 27 | // List of country/region code with contact consent requirement type of opt-out 28 | OptOutContactConsentRequirementRegions *[]string `json:"optOutContactConsentRequirementRegions,omitempty"` 29 | // List of country/regions 30 | Regions *[]ProfileRegion `json:"regions,omitempty"` 31 | } 32 | -------------------------------------------------------------------------------- /azuredevops/v7/provenance/client.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package provenance 10 | 11 | import ( 12 | "bytes" 13 | "context" 14 | "encoding/json" 15 | "github.com/google/uuid" 16 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7" 17 | "net/http" 18 | ) 19 | 20 | var ResourceAreaId, _ = uuid.Parse("b40c1171-807a-493a-8f3f-5c26d5e2f5aa") 21 | 22 | type Client interface { 23 | // [Preview API] Creates a session, a wrapper around a feed that can store additional metadata on the packages published to it. 24 | CreateSession(context.Context, CreateSessionArgs) (*SessionResponse, error) 25 | } 26 | 27 | type ClientImpl struct { 28 | Client azuredevops.Client 29 | } 30 | 31 | func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { 32 | client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) 33 | if err != nil { 34 | return nil, err 35 | } 36 | return &ClientImpl{ 37 | Client: *client, 38 | }, nil 39 | } 40 | 41 | // [Preview API] Creates a session, a wrapper around a feed that can store additional metadata on the packages published to it. 42 | func (client *ClientImpl) CreateSession(ctx context.Context, args CreateSessionArgs) (*SessionResponse, error) { 43 | if args.SessionRequest == nil { 44 | return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.SessionRequest"} 45 | } 46 | routeValues := make(map[string]string) 47 | if args.Project != nil && *args.Project != "" { 48 | routeValues["project"] = *args.Project 49 | } 50 | if args.Protocol == nil || *args.Protocol == "" { 51 | return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Protocol"} 52 | } 53 | routeValues["protocol"] = *args.Protocol 54 | 55 | body, marshalErr := json.Marshal(*args.SessionRequest) 56 | if marshalErr != nil { 57 | return nil, marshalErr 58 | } 59 | locationId, _ := uuid.Parse("503b4e54-ebf4-4d04-8eee-21c00823c2ac") 60 | resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "7.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) 61 | if err != nil { 62 | return nil, err 63 | } 64 | 65 | var responseValue SessionResponse 66 | err = client.Client.UnmarshalBody(resp, &responseValue) 67 | return &responseValue, err 68 | } 69 | 70 | // Arguments for the CreateSession function 71 | type CreateSessionArgs struct { 72 | // (required) The feed and metadata for the session 73 | SessionRequest *SessionRequest 74 | // (required) The protocol that the session will target 75 | Protocol *string 76 | // (optional) Project ID or project name 77 | Project *string 78 | } 79 | -------------------------------------------------------------------------------- /azuredevops/v7/provenance/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package provenance 10 | 11 | type SessionRequest struct { 12 | // Generic property bag to store data about the session 13 | Data *map[string]string `json:"data,omitempty"` 14 | // The feed name or id for the session 15 | Feed *string `json:"feed,omitempty"` 16 | // 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 17 | Source *string `json:"source,omitempty"` 18 | } 19 | 20 | type SessionResponse struct { 21 | // The unique identifier for the session 22 | SessionId *string `json:"sessionId,omitempty"` 23 | // The name for the session 24 | SessionName *string `json:"sessionName,omitempty"` 25 | } 26 | -------------------------------------------------------------------------------- /azuredevops/v7/pypiapi/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package pypiapi 10 | 11 | import ( 12 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7" 13 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7/packagingshared" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7/webapi" 15 | ) 16 | 17 | // Package version metadata for a Python package 18 | type Package struct { 19 | // Related REST links. 20 | Links interface{} `json:"_links,omitempty"` 21 | // If and when the package was deleted. 22 | DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` 23 | // Package Id. 24 | Id *string `json:"id,omitempty"` 25 | // The display name of the package. 26 | Name *string `json:"name,omitempty"` 27 | // If and when the package was permanently deleted. 28 | PermanentlyDeletedDate *azuredevops.Time `json:"permanentlyDeletedDate,omitempty"` 29 | // The history of upstream sources for this package. The first source in the list is the immediate source from which this package was saved. 30 | SourceChain *[]packagingshared.UpstreamSourceInfo `json:"sourceChain,omitempty"` 31 | // The version of the package. 32 | Version *string `json:"version,omitempty"` 33 | } 34 | 35 | type PackageVersionDetails struct { 36 | // The view to which the package version will be added 37 | Views *webapi.JsonPatchOperation `json:"views,omitempty"` 38 | } 39 | 40 | // Describes PyPi batch operation types. 41 | type PyPiBatchOperationType string 42 | 43 | type pyPiBatchOperationTypeValuesType struct { 44 | Promote PyPiBatchOperationType 45 | Delete PyPiBatchOperationType 46 | PermanentDelete PyPiBatchOperationType 47 | RestoreToFeed PyPiBatchOperationType 48 | } 49 | 50 | var PyPiBatchOperationTypeValues = pyPiBatchOperationTypeValuesType{ 51 | // 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. 52 | Promote: "promote", 53 | // Move package versions to the feed's Recycle Bin. Not supported in the Recycle Bin. 54 | Delete: "delete", 55 | // Permanently delete package versions. Only supported in the Recycle Bin. 56 | PermanentDelete: "permanentDelete", 57 | // Restore deleted package versions to the feed. Only supported in the Recycle Bin. 58 | RestoreToFeed: "restoreToFeed", 59 | } 60 | 61 | // A batch of operations to apply to package versions. 62 | type PyPiPackagesBatchRequest struct { 63 | // Data required to perform the operation. This is optional based on the type of the operation. Use BatchPromoteData if performing a promote operation. 64 | Data interface{} `json:"data,omitempty"` 65 | // Type of operation that needs to be performed on packages. 66 | Operation *PyPiBatchOperationType `json:"operation,omitempty"` 67 | // The packages onto which the operation will be performed. 68 | Packages *[]packagingshared.MinimalPackageDetails `json:"packages,omitempty"` 69 | } 70 | 71 | // Deletion state of a Python package. 72 | type PyPiPackageVersionDeletionState struct { 73 | // UTC date the package was deleted. 74 | DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` 75 | // Name of the package. 76 | Name *string `json:"name,omitempty"` 77 | // Version of the package. 78 | Version *string `json:"version,omitempty"` 79 | } 80 | 81 | type PyPiRecycleBinPackageVersionDetails struct { 82 | // Setting to false will undo earlier deletion and restore the package to feed. 83 | Deleted *bool `json:"deleted,omitempty"` 84 | } 85 | -------------------------------------------------------------------------------- /azuredevops/v7/symbolcommon/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package symbolcommon 10 | 11 | // [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. 12 | type DebugInformationLevel string 13 | 14 | type debugInformationLevelValuesType struct { 15 | None DebugInformationLevel 16 | Binary DebugInformationLevel 17 | Publics DebugInformationLevel 18 | TraceFormatPresent DebugInformationLevel 19 | TypeInfo DebugInformationLevel 20 | LineNumbers DebugInformationLevel 21 | GlobalSymbols DebugInformationLevel 22 | Private DebugInformationLevel 23 | SourceIndexed DebugInformationLevel 24 | } 25 | 26 | var DebugInformationLevelValues = debugInformationLevelValuesType{ 27 | // If set, the .pdb file contains no debug information. 28 | None: "none", 29 | // If set, the .pdb file contains debug information which is binary. 30 | Binary: "binary", 31 | // If set, the .pdb file contains public symbols. 32 | Publics: "publics", 33 | // If set, the .pdb file contains trace format. 34 | TraceFormatPresent: "traceFormatPresent", 35 | // If set, the .pdb file contains type information. 36 | TypeInfo: "typeInfo", 37 | // If set, the .pdb file contains line number information. 38 | LineNumbers: "lineNumbers", 39 | // If set, the .pdb file contains symbol information. 40 | GlobalSymbols: "globalSymbols", 41 | // If set, the .pdb file contains public symbols and has type, line number and symbol information. 42 | Private: "private", 43 | // If set, the .pdb file supports the source server. 44 | SourceIndexed: "sourceIndexed", 45 | } 46 | -------------------------------------------------------------------------------- /azuredevops/v7/system/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package system 10 | 11 | type SqlDbType string 12 | 13 | type sqlDbTypeValuesType struct { 14 | BigInt SqlDbType 15 | Binary SqlDbType 16 | Bit SqlDbType 17 | Char SqlDbType 18 | DateTime SqlDbType 19 | Decimal SqlDbType 20 | Float SqlDbType 21 | Image SqlDbType 22 | Int SqlDbType 23 | Money SqlDbType 24 | NChar SqlDbType 25 | NText SqlDbType 26 | NVarChar SqlDbType 27 | Real SqlDbType 28 | UniqueIdentifier SqlDbType 29 | SmallDateTime SqlDbType 30 | SmallInt SqlDbType 31 | SmallMoney SqlDbType 32 | Text SqlDbType 33 | Timestamp SqlDbType 34 | TinyInt SqlDbType 35 | VarBinary SqlDbType 36 | VarChar SqlDbType 37 | Variant SqlDbType 38 | Xml SqlDbType 39 | Udt SqlDbType 40 | Structured SqlDbType 41 | Date SqlDbType 42 | Time SqlDbType 43 | DateTime2 SqlDbType 44 | DateTimeOffset SqlDbType 45 | } 46 | 47 | var SqlDbTypeValues = sqlDbTypeValuesType{ 48 | BigInt: "bigInt", 49 | Binary: "binary", 50 | Bit: "bit", 51 | Char: "char", 52 | DateTime: "dateTime", 53 | Decimal: "decimal", 54 | Float: "float", 55 | Image: "image", 56 | Int: "int", 57 | Money: "money", 58 | NChar: "nChar", 59 | NText: "nText", 60 | NVarChar: "nVarChar", 61 | Real: "real", 62 | UniqueIdentifier: "uniqueIdentifier", 63 | SmallDateTime: "smallDateTime", 64 | SmallInt: "smallInt", 65 | SmallMoney: "smallMoney", 66 | Text: "text", 67 | Timestamp: "timestamp", 68 | TinyInt: "tinyInt", 69 | VarBinary: "varBinary", 70 | VarChar: "varChar", 71 | Variant: "variant", 72 | Xml: "xml", 73 | Udt: "udt", 74 | Structured: "structured", 75 | Date: "date", 76 | Time: "time", 77 | DateTime2: "dateTime2", 78 | DateTimeOffset: "dateTimeOffset", 79 | } 80 | 81 | type TraceLevel string 82 | 83 | type traceLevelValuesType struct { 84 | Off TraceLevel 85 | Error TraceLevel 86 | Warning TraceLevel 87 | Info TraceLevel 88 | Verbose TraceLevel 89 | } 90 | 91 | var TraceLevelValues = traceLevelValuesType{ 92 | Off: "off", 93 | Error: "error", 94 | Warning: "warning", 95 | Info: "info", 96 | Verbose: "verbose", 97 | } 98 | -------------------------------------------------------------------------------- /azuredevops/v7/testresults/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package testresults 10 | 11 | type Attachment struct { 12 | CompressionType *string `json:"compressionType,omitempty"` 13 | FileName *string `json:"fileName,omitempty"` 14 | Stream interface{} `json:"stream,omitempty"` 15 | } 16 | -------------------------------------------------------------------------------- /azuredevops/v7/tokenadmin/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package tokenadmin 10 | 11 | import ( 12 | "github.com/google/uuid" 13 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7" 14 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7/delegatedauthorization" 15 | ) 16 | 17 | // A paginated list of session tokens. Session tokens correspond to OAuth credentials such as personal access tokens (PATs) and other OAuth authorizations. 18 | type TokenAdminPagedSessionTokens struct { 19 | // The continuation token that can be used to retrieve the next page of session tokens, or null if there is no next page. 20 | ContinuationToken *uuid.UUID `json:"continuationToken,omitempty"` 21 | // The list of all session tokens in the current page. 22 | Value *[]delegatedauthorization.SessionToken `json:"value,omitempty"` 23 | } 24 | 25 | // A request to revoke a particular delegated authorization. 26 | type TokenAdminRevocation struct { 27 | // The authorization ID of the OAuth authorization to revoke. 28 | AuthorizationId *uuid.UUID `json:"authorizationId,omitempty"` 29 | } 30 | 31 | // A rule which is applied to disable any incoming delegated authorization which matches the given properties. 32 | type TokenAdminRevocationRule struct { 33 | // 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. 34 | CreatedBefore *azuredevops.Time `json:"createdBefore,omitempty"` 35 | // 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. 36 | Scopes *string `json:"scopes,omitempty"` 37 | } 38 | -------------------------------------------------------------------------------- /azuredevops/v7/upackpackaging/models.go: -------------------------------------------------------------------------------- 1 | // -------------------------------------------------------------------------------------------- 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License. 4 | // -------------------------------------------------------------------------------------------- 5 | // Generated file, DO NOT EDIT 6 | // Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 | // -------------------------------------------------------------------------------------------- 8 | 9 | package upackpackaging 10 | 11 | import ( 12 | "github.com/microsoft/azure-devops-go-api/azuredevops/v7" 13 | ) 14 | 15 | // Describes UPack batch operation types. 16 | type UPackBatchOperationType string 17 | 18 | type uPackBatchOperationTypeValuesType struct { 19 | Promote UPackBatchOperationType 20 | Delete UPackBatchOperationType 21 | PermanentDelete UPackBatchOperationType 22 | RestoreToFeed UPackBatchOperationType 23 | } 24 | 25 | var UPackBatchOperationTypeValues = uPackBatchOperationTypeValuesType{ 26 | // 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. 27 | Promote: "promote", 28 | // Move package versions to the feed's Recycle Bin. Not supported in the Recycle Bin. 29 | Delete: "delete", 30 | // Permanently delete package versions. Only supported in the Recycle Bin. 31 | PermanentDelete: "permanentDelete", 32 | // Restore deleted package versions to the feed. Only supported in the Recycle Bin. 33 | RestoreToFeed: "restoreToFeed", 34 | } 35 | 36 | // Describes intent when calling the API GetPackageMetadata. 37 | type UPackGetPackageMetadataIntent string 38 | 39 | type uPackGetPackageMetadataIntentValuesType struct { 40 | FetchMetadataOnly UPackGetPackageMetadataIntent 41 | Download UPackGetPackageMetadataIntent 42 | } 43 | 44 | var UPackGetPackageMetadataIntentValues = uPackGetPackageMetadataIntentValuesType{ 45 | // Default. The call intends only to retrieve the package metadata. 46 | FetchMetadataOnly: "fetchMetadataOnly", 47 | // The call is part of the download flow. 48 | Download: "download", 49 | } 50 | 51 | type UPackLimitedPackageMetadata struct { 52 | Description *string `json:"description,omitempty"` 53 | Version *string `json:"version,omitempty"` 54 | } 55 | 56 | type UPackLimitedPackageMetadataListResponse struct { 57 | Count *int `json:"count,omitempty"` 58 | Value *[]UPackLimitedPackageMetadata `json:"value,omitempty"` 59 | } 60 | 61 | type UPackPackageMetadata struct { 62 | Description *string `json:"description,omitempty"` 63 | ManifestId *string `json:"manifestId,omitempty"` 64 | PackageSize *uint64 `json:"packageSize,omitempty"` 65 | SuperRootId *string `json:"superRootId,omitempty"` 66 | Version *string `json:"version,omitempty"` 67 | } 68 | 69 | // Contains the parameters for adding a new Universal Package to the feed, except for name and version which are transmitted in the URL 70 | type UPackPackagePushMetadata struct { 71 | Description *string `json:"description,omitempty"` 72 | ManifestId *string `json:"manifestId,omitempty"` 73 | ProofNodes *[]string `json:"proofNodes,omitempty"` 74 | SuperRootId *string `json:"superRootId,omitempty"` 75 | } 76 | 77 | // Deletion state of a Universal package. 78 | type UPackPackageVersionDeletionState struct { 79 | // UTC date the package was deleted. 80 | DeletedDate *azuredevops.Time `json:"deletedDate,omitempty"` 81 | // Name of the package. 82 | Name *string `json:"name,omitempty"` 83 | // Version of the package. 84 | Version *string `json:"version,omitempty"` 85 | } 86 | -------------------------------------------------------------------------------- /azuredevops/v7/version.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | package azuredevops 5 | 6 | import ( 7 | "strconv" 8 | "strings" 9 | ) 10 | 11 | type Version struct { 12 | Major int 13 | Minor int 14 | } 15 | 16 | func NewVersion(version string) (*Version, error) { 17 | split := strings.Split(version, ".") 18 | if len(split) > 1 { 19 | major, err := strconv.Atoi(split[0]) 20 | if err != nil { 21 | return nil, err 22 | } 23 | minor, err := strconv.Atoi(split[1]) 24 | if err != nil { 25 | return nil, err 26 | } 27 | return &Version{ 28 | Major: major, 29 | Minor: minor, 30 | }, nil 31 | } 32 | return nil, &InvalidVersionStringError{version: version} 33 | } 34 | 35 | func (version Version) CompareTo(compareToVersion Version) int { 36 | if version.Major > compareToVersion.Major { 37 | return 1 38 | } else if version.Major < compareToVersion.Major { 39 | return -1 40 | } else if version.Minor > compareToVersion.Minor { 41 | return 1 42 | } else if version.Minor < compareToVersion.Minor { 43 | return -1 44 | } 45 | return 0 46 | } 47 | 48 | func (version Version) String() string { 49 | return strconv.Itoa(version.Major) + "." + strconv.Itoa(version.Minor) 50 | } 51 | 52 | type InvalidVersionStringError struct { 53 | version string 54 | } 55 | 56 | func (e *InvalidVersionStringError) Error() string { 57 | return "The version string was invalid: " + e.version 58 | } 59 | -------------------------------------------------------------------------------- /azuredevops/v7/versionnegotiation.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | package azuredevops 5 | 6 | import "strconv" 7 | 8 | func negotiateRequestVersion(location *ApiResourceLocation, apiVersion string) (string, error) { 9 | if apiVersion == "" { 10 | // if no api-version is sent to the server, the server will decide the version. The server uses the latest 11 | // released version if the endpoint has been released, otherwise it will use the latest preview version. 12 | return apiVersion, nil 13 | } 14 | 15 | matches := apiVersionRegEx.FindStringSubmatch(apiVersion) 16 | if len(matches) == 0 && matches[0] != "" { 17 | return apiVersion, &InvalidApiVersion{apiVersion} 18 | } 19 | 20 | requestedApiVersion, err := NewVersion(matches[1]) 21 | if err != nil { 22 | return apiVersion, err 23 | } 24 | locationMinVersion, err := NewVersion(*location.MinVersion) 25 | if err != nil { 26 | return apiVersion, err 27 | } 28 | if locationMinVersion.CompareTo(*requestedApiVersion) > 0 { 29 | // Client is older than the server. The server no longer supports this 30 | // resource (deprecated). 31 | return apiVersion, nil 32 | } else { 33 | locationMaxVersion, err := NewVersion(*location.MaxVersion) 34 | if err != nil { 35 | return apiVersion, err 36 | } 37 | if locationMaxVersion.CompareTo(*requestedApiVersion) < 0 { 38 | // Client is newer than the server. Negotiate down to the latest version 39 | // on the server 40 | negotiatedVersion := string(*location.MaxVersion) 41 | if *location.ReleasedVersion < *location.MaxVersion { 42 | negotiatedVersion += "-preview" 43 | } 44 | return negotiatedVersion, nil 45 | } else { 46 | // We can send at the requested api version. Make sure the resource version 47 | // is not bigger than what the server supports 48 | negotiatedVersion := matches[1] 49 | if len(matches) > 3 && matches[3] != "" { // matches '-preview' 50 | negotiatedVersion += "-preview" 51 | if len(matches) > 5 && matches[5] != "" { // has a resource version 52 | requestedResourceVersion, _ := strconv.Atoi(matches[5]) 53 | if *location.ResourceVersion < requestedResourceVersion { 54 | negotiatedVersion += "." + strconv.Itoa(*location.ResourceVersion) 55 | } else { 56 | negotiatedVersion += "." + matches[5] 57 | } 58 | } 59 | } else { 60 | // requesting released version, ensure server supports a released version, and if not append '-preview' 61 | locationReleasedVersion, err := NewVersion(*location.ReleasedVersion) 62 | if err != nil { 63 | return apiVersion, err 64 | } 65 | if (locationReleasedVersion.Major == 0 && locationReleasedVersion.Minor == 0) || locationReleasedVersion.CompareTo(*requestedApiVersion) < 0 { 66 | negotiatedVersion += "-preview" 67 | } 68 | } 69 | return negotiatedVersion, nil 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /azuredevops/v7/versionnegotiation_test.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestNegotiateRequestVersion_NonReleasedApi(t *testing.T) { 8 | // key is requested version, value is expected negotiated version 9 | tests := make(map[string]string) 10 | tests[""] = "" 11 | tests["2.2-preview.4"] = "2.2-preview.3" 12 | tests["2.2-preview"] = "2.2-preview" 13 | tests["2.2-preview.3"] = "2.2-preview.3" 14 | tests["2.2-preview.2"] = "2.2-preview.2" 15 | tests["2.1-preview.4"] = "2.1-preview.3" 16 | tests["2.1-preview.3"] = "2.1-preview.3" 17 | tests["1.0-preview.3"] = "1.0-preview.3" 18 | tests["2.2"] = "2.2-preview" 19 | tests["1.0"] = "1.0-preview" 20 | tests["2.2-preview"] = "2.2-preview" 21 | tests["1.0-preview"] = "1.0-preview" 22 | tests["2.3-preview"] = "2.2-preview" 23 | tests["3.0-preview"] = "2.2-preview" 24 | 25 | for requested, expected := range tests { 26 | compareVersions(t, unreleasedApiResourceLocation, requested, expected) 27 | } 28 | } 29 | 30 | func TestNegotiateRequestVersion_ReleasedApi(t *testing.T) { 31 | // key is requested version, value is expected negotiated version 32 | tests := make(map[string]string) 33 | tests[""] = "" 34 | tests["2.2-preview.4"] = "2.2-preview.3" 35 | tests["2.2-preview"] = "2.2-preview" 36 | tests["2.2-preview.3"] = "2.2-preview.3" 37 | tests["2.2-preview.2"] = "2.2-preview.2" 38 | tests["2.1-preview.4"] = "2.1-preview.3" 39 | tests["2.1-preview.3"] = "2.1-preview.3" 40 | tests["1.0-preview.3"] = "1.0-preview.3" 41 | tests["2.2-preview"] = "2.2-preview" 42 | tests["1.0-preview"] = "1.0-preview" 43 | tests["2.3-preview"] = "2.2-preview" 44 | tests["3.0-preview"] = "2.2-preview" 45 | tests["3.0"] = "2.2-preview" 46 | tests["2.3"] = "2.2-preview" 47 | tests["2.2"] = "2.2-preview" 48 | tests["2.1"] = "2.1" 49 | tests["2.0"] = "2.0" 50 | tests["1.0"] = "1.0" 51 | 52 | for requested, expected := range tests { 53 | compareVersions(t, releasedApiResourceLocation, requested, expected) 54 | } 55 | } 56 | 57 | func compareVersions(t *testing.T, apiResourceLocation *ApiResourceLocation, requestedVersion string, expectedVersion string) { 58 | negotiatedVersion, err := negotiateRequestVersion(apiResourceLocation, requestedVersion) 59 | if err != nil { 60 | t.Errorf("Unexpected error: %v", err) 61 | } 62 | if negotiatedVersion != expectedVersion { 63 | t.Errorf("Negotiated version did not match expected. Requested: %v Expected: %v Actual: %v", requestedVersion, expectedVersion, negotiatedVersion) 64 | } 65 | } 66 | 67 | var resourceVersionThree = 3 68 | var version00 = "0.0" 69 | var version10 = "1.0" 70 | var version20 = "2.0" 71 | var version21 = "2.1" 72 | var version22 = "2.2" 73 | 74 | var unreleasedApiResourceLocation = &ApiResourceLocation{ 75 | ResourceVersion: &resourceVersionThree, 76 | MinVersion: &version10, 77 | MaxVersion: &version22, 78 | ReleasedVersion: &version00, 79 | } 80 | 81 | var releasedApiResourceLocation = &ApiResourceLocation{ 82 | ResourceVersion: &resourceVersionThree, 83 | MinVersion: &version20, 84 | MaxVersion: &version22, 85 | ReleasedVersion: &version21, 86 | } 87 | -------------------------------------------------------------------------------- /azuredevops/version.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | package azuredevops 5 | 6 | import ( 7 | "strconv" 8 | "strings" 9 | ) 10 | 11 | type Version struct { 12 | Major int 13 | Minor int 14 | } 15 | 16 | func NewVersion(version string) (*Version, error) { 17 | split := strings.Split(version, ".") 18 | if len(split) > 1 { 19 | major, err := strconv.Atoi(split[0]) 20 | if err != nil { 21 | return nil, err 22 | } 23 | minor, err := strconv.Atoi(split[1]) 24 | if err != nil { 25 | return nil, err 26 | } 27 | return &Version{ 28 | Major: major, 29 | Minor: minor, 30 | }, nil 31 | } 32 | return nil, &InvalidVersionStringError{version: version} 33 | } 34 | 35 | func (version Version) CompareTo(compareToVersion Version) int { 36 | if version.Major > compareToVersion.Major { 37 | return 1 38 | } else if version.Major < compareToVersion.Major { 39 | return -1 40 | } else if version.Minor > compareToVersion.Minor { 41 | return 1 42 | } else if version.Minor < compareToVersion.Minor { 43 | return -1 44 | } 45 | return 0 46 | } 47 | 48 | func (version Version) String() string { 49 | return strconv.Itoa(version.Major) + "." + strconv.Itoa(version.Minor) 50 | } 51 | 52 | type InvalidVersionStringError struct { 53 | version string 54 | } 55 | 56 | func (e *InvalidVersionStringError) Error() string { 57 | return "The version string was invalid: " + e.version 58 | } 59 | -------------------------------------------------------------------------------- /azuredevops/versionnegotiation.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | package azuredevops 5 | 6 | import "strconv" 7 | 8 | func negotiateRequestVersion(location *ApiResourceLocation, apiVersion string) (string, error) { 9 | if apiVersion == "" { 10 | // if no api-version is sent to the server, the server will decide the version. The server uses the latest 11 | // released version if the endpoint has been released, otherwise it will use the latest preview version. 12 | return apiVersion, nil 13 | } 14 | 15 | matches := apiVersionRegEx.FindStringSubmatch(apiVersion) 16 | if len(matches) == 0 && matches[0] != "" { 17 | return apiVersion, &InvalidApiVersion{apiVersion} 18 | } 19 | 20 | requestedApiVersion, err := NewVersion(matches[1]) 21 | if err != nil { 22 | return apiVersion, err 23 | } 24 | locationMinVersion, err := NewVersion(*location.MinVersion) 25 | if err != nil { 26 | return apiVersion, err 27 | } 28 | if locationMinVersion.CompareTo(*requestedApiVersion) > 0 { 29 | // Client is older than the server. The server no longer supports this 30 | // resource (deprecated). 31 | return apiVersion, nil 32 | } else { 33 | locationMaxVersion, err := NewVersion(*location.MaxVersion) 34 | if err != nil { 35 | return apiVersion, err 36 | } 37 | if locationMaxVersion.CompareTo(*requestedApiVersion) < 0 { 38 | // Client is newer than the server. Negotiate down to the latest version 39 | // on the server 40 | negotiatedVersion := string(*location.MaxVersion) 41 | if *location.ReleasedVersion < *location.MaxVersion { 42 | negotiatedVersion += "-preview" 43 | } 44 | return negotiatedVersion, nil 45 | } else { 46 | // We can send at the requested api version. Make sure the resource version 47 | // is not bigger than what the server supports 48 | negotiatedVersion := matches[1] 49 | if len(matches) > 3 && matches[3] != "" { // matches '-preview' 50 | negotiatedVersion += "-preview" 51 | if len(matches) > 5 && matches[5] != "" { // has a resource version 52 | requestedResourceVersion, _ := strconv.Atoi(matches[5]) 53 | if *location.ResourceVersion < requestedResourceVersion { 54 | negotiatedVersion += "." + strconv.Itoa(*location.ResourceVersion) 55 | } else { 56 | negotiatedVersion += "." + matches[5] 57 | } 58 | } 59 | } else { 60 | // requesting released version, ensure server supports a released version, and if not append '-preview' 61 | locationReleasedVersion, err := NewVersion(*location.ReleasedVersion) 62 | if err != nil { 63 | return apiVersion, err 64 | } 65 | if (locationReleasedVersion.Major == 0 && locationReleasedVersion.Minor == 0) || locationReleasedVersion.CompareTo(*requestedApiVersion) < 0 { 66 | negotiatedVersion += "-preview" 67 | } 68 | } 69 | return negotiatedVersion, nil 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /azuredevops/versionnegotiation_test.go: -------------------------------------------------------------------------------- 1 | package azuredevops 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestNegotiateRequestVersion_NonReleasedApi(t *testing.T) { 8 | // key is requested version, value is expected negotiated version 9 | tests := make(map[string]string) 10 | tests[""] = "" 11 | tests["2.2-preview.4"] = "2.2-preview.3" 12 | tests["2.2-preview"] = "2.2-preview" 13 | tests["2.2-preview.3"] = "2.2-preview.3" 14 | tests["2.2-preview.2"] = "2.2-preview.2" 15 | tests["2.1-preview.4"] = "2.1-preview.3" 16 | tests["2.1-preview.3"] = "2.1-preview.3" 17 | tests["1.0-preview.3"] = "1.0-preview.3" 18 | tests["2.2"] = "2.2-preview" 19 | tests["1.0"] = "1.0-preview" 20 | tests["2.2-preview"] = "2.2-preview" 21 | tests["1.0-preview"] = "1.0-preview" 22 | tests["2.3-preview"] = "2.2-preview" 23 | tests["3.0-preview"] = "2.2-preview" 24 | 25 | for requested, expected := range tests { 26 | compareVersions(t, unreleasedApiResourceLocation, requested, expected) 27 | } 28 | } 29 | 30 | func TestNegotiateRequestVersion_ReleasedApi(t *testing.T) { 31 | // key is requested version, value is expected negotiated version 32 | tests := make(map[string]string) 33 | tests[""] = "" 34 | tests["2.2-preview.4"] = "2.2-preview.3" 35 | tests["2.2-preview"] = "2.2-preview" 36 | tests["2.2-preview.3"] = "2.2-preview.3" 37 | tests["2.2-preview.2"] = "2.2-preview.2" 38 | tests["2.1-preview.4"] = "2.1-preview.3" 39 | tests["2.1-preview.3"] = "2.1-preview.3" 40 | tests["1.0-preview.3"] = "1.0-preview.3" 41 | tests["2.2-preview"] = "2.2-preview" 42 | tests["1.0-preview"] = "1.0-preview" 43 | tests["2.3-preview"] = "2.2-preview" 44 | tests["3.0-preview"] = "2.2-preview" 45 | tests["3.0"] = "2.2-preview" 46 | tests["2.3"] = "2.2-preview" 47 | tests["2.2"] = "2.2-preview" 48 | tests["2.1"] = "2.1" 49 | tests["2.0"] = "2.0" 50 | tests["1.0"] = "1.0" 51 | 52 | for requested, expected := range tests { 53 | compareVersions(t, releasedApiResourceLocation, requested, expected) 54 | } 55 | } 56 | 57 | func compareVersions(t *testing.T, apiResourceLocation *ApiResourceLocation, requestedVersion string, expectedVersion string) { 58 | negotiatedVersion, err := negotiateRequestVersion(apiResourceLocation, requestedVersion) 59 | if err != nil { 60 | t.Errorf("Unexpected error: %v", err) 61 | } 62 | if negotiatedVersion != expectedVersion { 63 | t.Errorf("Negotiated version did not match expected. Requested: %v Expected: %v Actual: %v", requestedVersion, expectedVersion, negotiatedVersion) 64 | } 65 | } 66 | 67 | var resourceVersionThree = 3 68 | var version00 = "0.0" 69 | var version10 = "1.0" 70 | var version20 = "2.0" 71 | var version21 = "2.1" 72 | var version22 = "2.2" 73 | 74 | var unreleasedApiResourceLocation = &ApiResourceLocation{ 75 | ResourceVersion: &resourceVersionThree, 76 | MinVersion: &version10, 77 | MaxVersion: &version22, 78 | ReleasedVersion: &version00, 79 | } 80 | 81 | var releasedApiResourceLocation = &ApiResourceLocation{ 82 | ResourceVersion: &resourceVersionThree, 83 | MinVersion: &version20, 84 | MaxVersion: &version22, 85 | ReleasedVersion: &version21, 86 | } 87 | --------------------------------------------------------------------------------