This repository contains Go APIs for interacting with and managing Azure DevOps.
Перейти к файлу
Petr Nechvátal 3045bdf434
Merge pull request #185 from xuzhang3/f/group_deleted
Add group deleted flag
2024-10-14 10:06:28 +02:00
.github/workflows Fix pipeline path 2023-04-17 21:40:49 +02:00
azuredevops add group deleted flag. 2024-10-11 14:24:18 +08:00
.gitattributes Update client methods to take a single struct arg to allow for additional args in future with no compatability breaks. 2019-07-24 15:16:05 -04:00
.gitignore initial checkin 2019-07-17 16:17:39 -04:00
CODE_OF_CONDUCT.md Initial commit 2019-07-16 09:42:33 -07:00
LICENSE Initial commit 2019-07-16 09:42:34 -07:00
README.md Update README.md 2023-04-18 07:37:16 +02:00
SECURITY.md Microsoft mandatory file 2023-06-02 17:37:42 +00:00
SUPPORT.md changing texts as we agreed to looks better. 2024-08-23 16:11:49 +02:00
azure-pipelines.yml Update azure-pipelines.yml 2024-09-26 11:15:03 +02:00

README.md

Go Build Status Go 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"
)

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 != "" {

			continuationToken, err := strconv.Atoi(responseValue.ContinuationToken)
			if err != nil {
				log.Fatal(err)
			}

			// Get next page of team projects
			projectArgs := core.GetProjectsArgs{
				ContinuationToken: &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 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.