Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev to master for 5.1 version #69

Merged
merged 83 commits into from
May 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
22bd034
initial checkin
tedchamb Jul 17, 2019
7e7c993
Update readme, and fix err condition when response has no body.
tedchamb Jul 18, 2019
46b152e
minor readme tweaks
tedchamb Jul 18, 2019
db737bc
more readme tweaks
tedchamb Jul 18, 2019
59e647b
add some versionnegotiation unit tests
tedchamb Jul 18, 2019
4872511
Add contexts, ability to set default timeout, fix onprem resourcearea…
tedchamb Jul 22, 2019
08e1fe7
Update readme to match code changes
tedchamb Jul 22, 2019
26b0af3
Add enum values
tedchamb Jul 22, 2019
b6ab6fe
Update method parameters with proper enum type.
tedchamb Jul 22, 2019
55f5df7
fix use of enums in route and query parameters
tedchamb Jul 22, 2019
8ef4ef3
fix use of empty interface
tedchamb Jul 23, 2019
7f0583b
Handle upload streams
tedchamb Jul 23, 2019
bdb5243
fix stream downloads
tedchamb Jul 23, 2019
e97a841
Add go.mod
tedchamb Jul 23, 2019
dbaefad
attach client cache to the connection.
tedchamb Jul 23, 2019
0f6c21f
Update client methods to take a single struct arg to allow for additi…
tedchamb Jul 24, 2019
caa3c8e
fix indentation
tedchamb Jul 24, 2019
ae52864
Merge pull request #1 from microsoft/users/tedchamb/dev
tedchamb Jul 24, 2019
1168cf9
Rename connection constructor for using a PAT
tedchamb Jul 24, 2019
47b6484
rename azureDevops directory to azureDevOps
tedchamb Jul 24, 2019
d980ca5
react to packagename change
tedchamb Jul 24, 2019
6b30d04
Merge pull request #2 from microsoft/users/tedchamb/dev
tedchamb Jul 24, 2019
2e7f6bf
Add Search, Audit, and Token admin clients
tedchamb Jul 25, 2019
9ca62c5
Merge pull request #3 from microsoft/users/tedchamb/dev
tedchamb Jul 25, 2019
8cb553c
one more spelling fix
tedchamb Jul 25, 2019
fae2dcc
Merge pull request #4 from microsoft/users/tedchamb/dev
tedchamb Jul 25, 2019
15d8b5e
Set up CI with Azure Pipelines
tedchamb Jul 25, 2019
11bfdc5
Update azure-pipelines.yml for Azure Pipelines
tedchamb Jul 25, 2019
81e2695
Update azure-pipelines.yml for Azure Pipelines
tedchamb Jul 25, 2019
5e4a631
Merge pull request #5 from microsoft/azure-pipelines
tedchamb Jul 25, 2019
a4e7769
Add badge to readme
tedchamb Jul 25, 2019
2c05934
tweak
tedchamb Jul 25, 2019
6ef7572
correct badge
tedchamb Jul 25, 2019
001c69b
Remove model duplication (#7)
tedchamb Jul 30, 2019
b743f2a
fix resource and client caching and ensure connection passed by ref. …
tedchamb Aug 1, 2019
6e7b264
Support continuation token on GetBuilds method, fix Version reference…
tedchamb Aug 5, 2019
4c5113e
go fmt (#10)
tedchamb Aug 6, 2019
1d9077d
make package names lowercase (#11)
tedchamb Aug 6, 2019
dc8314d
Update methods to support continuation token. (#12)
tedchamb Aug 10, 2019
0c46c8a
readme example was affected by continuationToken support, so adapting…
tedchamb Aug 10, 2019
7260105
fix readme comment typo (#14)
tedchamb Aug 10, 2019
d4b6892
Fix issue with oddball route templates (CreateWorkItem). Get rid of …
tedchamb Aug 13, 2019
a196ec5
Update azure-pipelines.yml for Azure Pipelines
tedchamb Aug 22, 2019
47715c5
Fix for #17, create a custom Time type, so we can add a custom conver…
tedchamb Sep 3, 2019
3207b4a
regen with updated comments (#20)
tedchamb Sep 12, 2019
e35debc
switch to interfaces for test-ability (#22)
tedchamb Oct 8, 2019
7cf205d
Add reference to Go Report Card in README.md (#23)
Oct 11, 2019
fcd30e8
fix misspelling (#24)
tedchamb Oct 11, 2019
c7c025c
Fix more misspellings (#25)
tedchamb Oct 11, 2019
b909a25
add a few missing parameters (#26)
tedchamb Oct 11, 2019
26902c1
minor comment fix (#27)
tedchamb Oct 14, 2019
273e55a
Fix for issue #30 where some collections with continuation tokens wer…
tedchamb Oct 18, 2019
40dbb3f
Update go.yml (#16)
tedchamb Nov 23, 2019
59979e6
Add actions badge
tedchamb Nov 23, 2019
ad702f5
Fix issue #38. Query param json name incorrect for string lists (#39)
tedchamb Nov 25, 2019
3cd87c5
Prevent double JSON conversion in UnmarshalCollectionJson by using GO…
tmeckel Dec 30, 2019
17093eb
Fix bug that UnmarshalCollectionBody doesn't return an error created …
tmeckel Mar 11, 2020
33b33ef
return http statusCode within WrapperError
xuzhang3 Mar 27, 2020
543de48
Merge pull request #56 from xuzhang3/addhttpstatuscode
tedchamb Mar 27, 2020
68ccf3a
Fix omitempty json tags
bvwells May 14, 2020
b945305
Merge pull request #62 from bvwells/omitempty
tedchamb May 16, 2020
eed09bd
regen after fixing the generator to handle c# Single values as float3…
tedchamb May 16, 2020
a5bd31b
Update azure-pipelines.yml for Azure Pipelines
tedchamb May 16, 2020
3a26da9
Update azure-pipelines.yml for Azure Pipelines
tedchamb May 16, 2020
fe1bb00
Update azure-pipelines.yml for Azure Pipelines
tedchamb May 16, 2020
d0f9a4b
Update azure-pipelines.yml for Azure Pipelines
tedchamb May 16, 2020
4336568
Update azure-pipelines.yml for Azure Pipelines
tedchamb May 16, 2020
085caf7
Merge branch 'dev' into users/tedchamb/float
tedchamb May 16, 2020
4497d23
Update azure-pipelines.yml for Azure Pipelines
tedchamb May 16, 2020
956f110
Update azure-pipelines.yml for Azure Pipelines
tedchamb May 16, 2020
b7b9dcf
Update azure-pipelines.yml for Azure Pipelines
tedchamb May 16, 2020
a34078d
Merge branch 'dev' into users/tedchamb/float
tedchamb May 16, 2020
30f3f91
Merge pull request #63 from microsoft/users/tedchamb/float
tedchamb May 16, 2020
4adc08a
regen after fixing the generator to handle c# char values as string i…
tedchamb May 16, 2020
2e6b76e
Merge pull request #64 from microsoft/users/tedchamb/char
tedchamb May 16, 2020
90e5f9e
workaround for issue #59, support "2006-01-02T15:04:05.999999999" tim…
tedchamb May 16, 2020
12ae5f5
Merge pull request #65 from microsoft/users/tedchamb/57
tedchamb May 16, 2020
4c6ce3c
regen after fixing generator bug where inherited fields were not adde…
tedchamb May 17, 2020
e65d3ac
Merge pull request #66 from microsoft/users/tedchamb/53
tedchamb May 17, 2020
c2944a9
regen after fixing generator to pull in fields from base classes trea…
tedchamb May 17, 2020
b4e2d50
Merge pull request #68 from microsoft/users/tedchamb/44
tedchamb May 17, 2020
5505615
Add version to UserAgent string
tedchamb May 17, 2020
5203116
Merge pull request #70 from microsoft/users/tedchamb/version
tedchamb May 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Set the default behavior (used when a rule below doesn't match)
* text=auto

# Go files
*.go text eol=lf
*.mod text eol=lf
*.sum text eol=lf

# Some Windows-specific files should always be CRLF
*.bat text eol=crlf

# Shell scripts
*.sh text eol=lf
37 changes: 37 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Go
on: [push]
jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi

- name: go build
run: go build -v ./...

- name: go fmt
run: go fmt ./...

- name: go vet
run: go vet ./...

- name: go test
run: go test ./...
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

.idea/
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,73 @@
[![Go](https://github.com/microsoft/azure-devops-go-api/workflows/Go/badge.svg)](https://github.com/microsoft/azure-devops-go-api/actions)
[![Build Status](https://dev.azure.com/mseng/vsts-cli/_apis/build/status/microsoft.azure-devops-go-api?branchName=dev)](https://dev.azure.com/mseng/vsts-cli/_build/latest?definitionId=9110&branchName=dev)
[![Go Report Card](https://goreportcard.com/badge/github.com/microsoft/azure-devops-go-api)](https://goreportcard.com/report/github.com/microsoft/azure-devops-go-api)

# Azure DevOps Go API
This repository contains Go APIs for interacting with and managing Azure DevOps.

## Get started
To use the API, establish a connection using a [personal access token](https://docs.microsoft.com/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops) and the URL to your Azure DevOps organization. Then get a client using the connection and make API calls.

```
package main

import (
"context"
"github.com/microsoft/azure-devops-go-api/azuredevops"
"github.com/microsoft/azure-devops-go-api/azuredevops/core"
"log"
)

func main() {
organizationUrl := "https://dev.azure.com/myorg" // todo: replace value with your organization url
personalAccessToken := "XXXXXXXXXXXXXXXXXXXXXXX" // todo: replace value with your PAT

// Create a connection to your organization
connection := azuredevops.NewPatConnection(organizationUrl, personalAccessToken)

ctx := context.Background()

// Create a client to interact with the Core area
coreClient, err := core.NewClient(ctx, connection)
if err != nil {
log.Fatal(err)
}

// Get first page of the list of team projects for your organization
responseValue, err := coreClient.GetProjects(ctx, core.GetProjectsArgs{})
if err != nil {
log.Fatal(err)
}

index := 0
for responseValue != nil {
// Log the page of team project names
for _, teamProjectReference := range (*responseValue).Value {
log.Printf("Name[%v] = %v", index, *teamProjectReference.Name)
index++
}

// if continuationToken has a value, then there is at least one more page of projects to get
if responseValue.ContinuationToken != "" {
// Get next page of team projects
projectArgs := core.GetProjectsArgs{
ContinuationToken: &responseValue.ContinuationToken,
}
responseValue, err = coreClient.GetProjects(ctx, projectArgs)
if err != nil {
log.Fatal(err)
}
} else {
responseValue = nil
}
}
}
```

## API documentation

This Go library provides a thin wrapper around the Azure DevOps REST APIs. See the [Azure DevOps REST API reference](https://docs.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.1) for details on calling different APIs.


# Contributing

Expand Down
48 changes: 48 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Go
# Build your Go project.
# Add steps that test, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/go

trigger:
- master
- dev

pool:
vmImage: 'ubuntu-latest'

variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code

steps:
- script: |
printenv | sort
displayName: 'Log Environment Variables'

- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
shopt -s dotglob
mv !(gopath) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'

- script: |
go version
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
go build -v ./...
workingDirectory: '$(modulePath)'
displayName: 'Get dependencies, then build'

- script: |
go test ./...
workingDirectory: '$(modulePath)'
displayName: 'Run unit tests'
71 changes: 71 additions & 0 deletions azuredevops/accounts/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// --------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// --------------------------------------------------------------------------------------------
// Generated file, DO NOT EDIT
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// --------------------------------------------------------------------------------------------

package accounts

import (
"context"
"github.com/google/uuid"
"github.com/microsoft/azure-devops-go-api/azuredevops"
"net/http"
"net/url"
)

var ResourceAreaId, _ = uuid.Parse("0d55247a-1c47-4462-9b1f-5e2125590ee6")

type Client interface {
// Get a list of accounts for a specific owner or a specific member.
GetAccounts(context.Context, GetAccountsArgs) (*[]Account, error)
}

type ClientImpl struct {
Client azuredevops.Client
}

func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) {
client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId)
if err != nil {
return nil, err
}
return &ClientImpl{
Client: *client,
}, nil
}

// Get a list of accounts for a specific owner or a specific member.
func (client *ClientImpl) GetAccounts(ctx context.Context, args GetAccountsArgs) (*[]Account, error) {
queryParams := url.Values{}
if args.OwnerId != nil {
queryParams.Add("ownerId", (*args.OwnerId).String())
}
if args.MemberId != nil {
queryParams.Add("memberId", (*args.MemberId).String())
}
if args.Properties != nil {
queryParams.Add("properties", *args.Properties)
}
locationId, _ := uuid.Parse("229a6a53-b428-4ffb-a835-e8f36b5b4b1e")
resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", nil, queryParams, nil, "", "application/json", nil)
if err != nil {
return nil, err
}

var responseValue []Account
err = client.Client.UnmarshalCollectionBody(resp, &responseValue)
return &responseValue, err
}

// Arguments for the GetAccounts function
type GetAccountsArgs struct {
// (optional) ID for the owner of the accounts.
OwnerId *uuid.UUID
// (optional) ID for a member of the accounts.
MemberId *uuid.UUID
// (optional)
Properties *string
}
124 changes: 124 additions & 0 deletions azuredevops/accounts/models.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// --------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// --------------------------------------------------------------------------------------------
// Generated file, DO NOT EDIT
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// --------------------------------------------------------------------------------------------

package accounts

import (
"github.com/google/uuid"
"github.com/microsoft/azure-devops-go-api/azuredevops"
)

type Account struct {
// Identifier for an Account
AccountId *uuid.UUID `json:"accountId,omitempty"`
// Name for an account
AccountName *string `json:"accountName,omitempty"`
// Owner of account
AccountOwner *uuid.UUID `json:"accountOwner,omitempty"`
// Current account status
AccountStatus *AccountStatus `json:"accountStatus,omitempty"`
// Type of account: Personal, Organization
AccountType *AccountType `json:"accountType,omitempty"`
// Uri for an account
AccountUri *string `json:"accountUri,omitempty"`
// Who created the account
CreatedBy *uuid.UUID `json:"createdBy,omitempty"`
// Date account was created
CreatedDate *azuredevops.Time `json:"createdDate,omitempty"`
HasMoved *bool `json:"hasMoved,omitempty"`
// Identity of last person to update the account
LastUpdatedBy *uuid.UUID `json:"lastUpdatedBy,omitempty"`
// Date account was last updated
LastUpdatedDate *azuredevops.Time `json:"lastUpdatedDate,omitempty"`
// Namespace for an account
NamespaceId *uuid.UUID `json:"namespaceId,omitempty"`
NewCollectionId *uuid.UUID `json:"newCollectionId,omitempty"`
// Organization that created the account
OrganizationName *string `json:"organizationName,omitempty"`
// Extended properties
Properties interface{} `json:"properties,omitempty"`
// Reason for current status
StatusReason *string `json:"statusReason,omitempty"`
}

type AccountCreateInfoInternal struct {
AccountName *string `json:"accountName,omitempty"`
Creator *uuid.UUID `json:"creator,omitempty"`
Organization *string `json:"organization,omitempty"`
Preferences *AccountPreferencesInternal `json:"preferences,omitempty"`
Properties interface{} `json:"properties,omitempty"`
ServiceDefinitions *[]azuredevops.KeyValuePair `json:"serviceDefinitions,omitempty"`
}

type AccountPreferencesInternal struct {
Culture interface{} `json:"culture,omitempty"`
Language interface{} `json:"language,omitempty"`
TimeZone interface{} `json:"timeZone,omitempty"`
}

type AccountStatus string

type accountStatusValuesType struct {
None AccountStatus
Enabled AccountStatus
Disabled AccountStatus
Deleted AccountStatus
Moved AccountStatus
}

var AccountStatusValues = accountStatusValuesType{
None: "none",
// This hosting account is active and assigned to a customer.
Enabled: "enabled",
// This hosting account is disabled.
Disabled: "disabled",
// This account is part of deletion batch and scheduled for deletion.
Deleted: "deleted",
// This account is not mastered locally and has physically moved.
Moved: "moved",
}

type AccountType string

type accountTypeValuesType struct {
Personal AccountType
Organization AccountType
}

var AccountTypeValues = accountTypeValuesType{
Personal: "personal",
Organization: "organization",
}

type AccountUserStatus string

type accountUserStatusValuesType struct {
None AccountUserStatus
Active AccountUserStatus
Disabled AccountUserStatus
Deleted AccountUserStatus
Pending AccountUserStatus
Expired AccountUserStatus
PendingDisabled AccountUserStatus
}

var AccountUserStatusValues = accountUserStatusValuesType{
None: "none",
// User has signed in at least once to the VSTS account
Active: "active",
// User cannot sign in; primarily used by admin to temporarily remove a user due to absence or license reallocation
Disabled: "disabled",
// User is removed from the VSTS account by the VSTS account admin
Deleted: "deleted",
// User is invited to join the VSTS account by the VSTS account admin, but has not signed up/signed in yet
Pending: "pending",
// User can sign in; primarily used when license is in expired state and we give a grace period
Expired: "expired",
// User is disabled; if reenabled, they will still be in the Pending state
PendingDisabled: "pendingDisabled",
}
Loading