Skip to content

Repository files navigation

GoBuild StatusGo Report Card

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 and the URL to your Azure DevOps organization. Then get a client using the connection and make API calls.

package main
import (
"context""log""strconv""github.com/microsoft/azure-devops-go-api/azuredevops/v7""github.com/microsoft/azure-devops-go-api/azuredevops/v7/core"
)
funcmain() {
organizationUrl:="https://dev.azure.com/myorg"// todo: replace value with your organization urlpersonalAccessToken:="XXXXXXXXXXXXXXXXXXXXXXX"// todo: replace value with your PAT// Create a connection to your organizationconnection:=azuredevops.NewPatConnection(organizationUrl, personalAccessToken)
ctx:=context.Background()
// Create a client to interact with the Core areacoreClient, err:=core.NewClient(ctx, connection)
iferr!=nil {
log.Fatal(err)
}
// Get first page of the list of team projects for your organizationresponseValue, err:=coreClient.GetProjects(ctx, core.GetProjectsArgs{})
iferr!=nil {
log.Fatal(err)
}
index:=0forresponseValue!=nil {
// Log the page of team project namesfor_, 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 getifresponseValue.ContinuationToken!="" {
continuationToken, err:=strconv.Atoi(responseValue.ContinuationToken)
iferr!=nil {
log.Fatal(err)
}
// Get next page of team projectsprojectArgs:= core.GetProjectsArgs{
ContinuationToken: &continuationToken,
}
responseValue, err=coreClient.GetProjects(ctx, projectArgs)
iferr!=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 for details on calling different APIs.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

About

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

Resources

Code of conduct

Security policy

Stars

226 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages