Coder Social home page Coder Social logo

microsoft / azure-devops-go-api Goto Github PK

View Code? Open in Web Editor NEW
181.0 10.0 72.0 3.52 MB

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

Home Page: https://docs.microsoft.com/en-us/azure/devops/integrate/index?view=azure-devops

License: MIT License

Go 100.00%

azure-devops-go-api's Introduction

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 [email protected] with any additional questions or comments.

azure-devops-go-api's People

Contributors

alancere avatar bcho avatar bvwells avatar goflores avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar nechvatalp avatar nigurr avatar silverdewbaker avatar tedchamb avatar tmeckel avatar xuzhang3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-devops-go-api's Issues

Incorrect value for azuredevops.Time in query parameter

Hi we found that in api: BuildClient.GetBuilds, the time value in parameter is incorrect:

map[definitions:[the-pipeline-id] minTime:[2020-08-03 11:11:36.300224 +0800 CST m=-10797.832509577] queryOrder:[queueTimeAscending]]

expected value should be formatted with RFC3339:

map[definitions:[the-pipeline-id] minTime:[2020-08-03T11:11:36+08:00] queryOrder:[queueTimeAscending]]

Trigger pipeline run with typed parameters?

Looking for a way to trigger a pipeline run where it has global typed parameters declared. We are thinking about moving our pipelines to this declaration style instead of using the UI driven variables section, however, we need the ability to trigger these pipelines from our automation. The CLI doesnt seem to support setting typed params so was hoping the go api did but RunPipelineParameters struct seems to only take variables.

Thoughts?

GetAllWikis 401

wikiClient, err := wiki.NewClient(ctx, connection)
response, err := wikiClient.GetAllWikis(ctx, wiki.GetAllWikisArgs{})

gives me a 401 but the other APIS GetRepositories and GetProjects work.
What am I missing here?

Run pipeline, RunParameters seem to get ignored

Hi, I'm trying to trigger a pipeline based on a special Ref and Version, but it seems that these values get ignored, the pipeline always runs on the latest master.
I'm using the following code:

var repositoryResourceParameters map[string]pipelines.RepositoryResourceParameters
if utils.IsFlagPassed(RepositoryNameFlag.Name, flags) && utils.IsFlagPassed(TargetRefNameFlag.Name, flags) && utils.IsFlagPassed(TargetVersionFlag.Name, flags) {
	repoName, err := flags.GetString(RepositoryNameFlag.Name)
	if err != nil {
		return err
	}

	targetRefName, err := flags.GetString(TargetRefNameFlag.Name)
	if err != nil {
		return err
	}

	targetVersion, err := flags.GetString(TargetVersionFlag.Name)
	if err != nil {
		return err
	}

	repositoryResourceParameters = map[string]pipelines.RepositoryResourceParameters{
		repoName: pipelines.RepositoryResourceParameters{
			RefName: to.StringPtr(targetRefName),
			Version: to.StringPtr(targetVersion),
		},
	}
}

runResult, err := pipelinesClient.RunPipeline(cmd.Context(), pipelines.RunPipelineArgs{
	Project:    &project,
	PipelineId: pipeline.Id,
	RunParameters: &pipelines.RunPipelineParameters{
		Resources: &pipelines.RunResourcesParameters{
			Repositories: &repositoryResourceParameters,
		},
	},
})

Am I doing something wrong?

[feature] Add new resource feedrecyclebin in packaging area.

Currently azure-devops-go-api doesn't support Permanent deletion of feeds from recycle bin.

I just realized that azure-devops-go-api is using a code generator. Hence just creating a feature request. It would be great if we add support for feedrecyclebin resource under the packaging area.

  • GetRecycleBinFeeds(context.Context, GetRecycleBinFeedsArgs) error
  • DeleteRecycleBinFeed(context.Context, DeleteRecycleBinFeedArgs) error
  • RestoreRecycleBinFeed(context.Context, RestoreRecycleBinFeedArgs) error

https://docs.microsoft.com/en-us/rest/api/azure/devops/artifacts/feed%20recycle%20bin?view=azure-devops-rest-6.0

Use semantic versions

It would be great if you could start using semantic versioning for the azuredevops module. (i.e. tag the repo with azuredevops/vx.x.x).

At the moment consumers have to import the module using a commit hash such as:

github.com/microsoft/azure-devops-go-api/azuredevops v0.0.0-20191230214132-3cd87c562d09

It would be great to have a strong story around versioning.

Thanks,
Ben

QueueBuild requires a non-nil Build even when sourceBuildId is specified

Just as the title says, the function Build.QueueBuild requires a non-nil Build property in the BuildArgs parameter even when a non-nil sourceBuildId is specified. I can work around it by passing a pointer to an empty struct, but it shouldn't be needed.

As a side note, I don't know where to open this issue, but the Queue API doesn't seem to work at all. I always get an error response "item with the same key already exists" and when I go to the Azure Pipelines page, the new build shows up but is in some sort of a corrupted state.

Copy work item

Hello, is there an easy way to create a copy of a work item, or should I create a new element using the CreateWorkItem method and fill in all its fields by reading from the source element?

Create Push API body has missing GitChange struct in Golang documentation

Docs: https://godoc.org/github.com/microsoft/azure-devops-go-api/azuredevops/git#GitCommitRef
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pushes?api-version=5.1
The Create Push API above has GitCommitRef as one of the structs to pass in request body.
The documentation mentions GitChange as one of the fields in GitCommitRef.
However, in the go docs, GitCommitRef takes an interface instead of GitChange.

response should include response code

When I get the response from backend service, the HTTP status code does not exist. I don't know if the resource does not exist or the service is unavailable.
As client , different HTTP status code will show different behaviors.

Generated SDK does not use interfaces, making testing difficult

Its difficult to unit test against the generated SDK code (i.e., mocking the API response for a specific API call) because the factory used to generate the clients do not return an interface; instead they return a raw client.

This makes testing hard. Can the generated code be updated to (1) create an interface and (2) return the interface from the factory to create new clients?

GetReleaseDefinition fails when using scheduled days

When using this config in Azure DevOps:
bilde

We get this error:
"json: cannot unmarshal number into Go struct field ReleaseSchedule.environments.schedules.daysToRelease of type release.ScheduleDays"

Returned from:
releaseDefinitionObject, err := releaseClient.GetReleaseDefinition(ctx,
getReleaseDefinitionArgs)
if err != nil {
log.Fatal(err)
}

Its this function that is throwing the error:

func (client *Client) UnmarshalBody(response *http.Response, v interface{}) (err error) {

And it is used by the function:

func (client *ClientImpl) GetReleaseDefinition(ctx context.Context, args GetReleaseDefinitionArgs) (*ReleaseDefinition, error) {

How to get information about the current users

I log in using accessToken

connection = azuredevops.NewPatConnection(organizationUrl, personalAccessToken)

can I get the information of the current account, namely, I need to get the UniqueName property, I could not figure out how to do this.

Error when try download artifact

Hi folks!

I could not retrieve the zip content file of an pipeline artifact. The method GetArtifactContentZip is returning the error:

TF400813: The user '' is not authorized to access this resource.

Code snippet:
`
connection := azuredevops.NewPatConnection(cfg.Azdevops.OrganizationURL, cfg.Azdevops.AccessToken)
args := build.GetArtifactContentZipArgs{
BuildId: &id,
Project: &cfg.Azdevops.Project,
ArtifactName: &artifactName,
}

artifact, err := buildClient.GetArtifactContentZip(ctx, args)
`

Using the same params I have managed retrieve the artifact information.

Release Definitions data not populating

I'm trying to retrieve the environments/variables of a release definition using this thin wrapper. When I run the GetReleaseDefinitions function I get the details I'm expecting back like name, id, revision, but it seems like most of the more detailed information is nil. I can confirm using the URL that it returns that the Environment map and variables map both have data in them but both come back as nil from the wrapper.

Generated models can be difficult to use due to unnecessary pointer types

The generated models can be difficult to use with primitive types like string, int and bool because they are consumed as pointers and can make the code more verbose.

For example, in order to use this struct with hard-coded values, I need to write my code like so:

abbreviation := "..."
description := "..."
version := 1

// note the use of variables. in Go, you cannot de-reference a constant!
project := core.ProjectInfo{
	Abbreviation: &abbreviation
	Description: &description 
	Version: &version
        ...
}

Without pointers, it can be simplified to this:

project := core.ProjectInfo{
	Abbreviation: "..."
	Description: "..." 
	Version: 1
        ...
}

Note: the current strategy probably lowers the runtime memory footprint of an application for larger types like strings, structs, maps, etc... but the efficiency gain is lost for int and bool (i believe).

policy.CreatePolicyConfiguration fails with error when trying to unmarshall response from azdo

The API call for CreatePolicyConfiguration fails with the error described below. My investigation leads me to believe that the error is occurring during the response unmarshalling phase.

API call
https://github.com/microsoft/azure-devops-go-api/blob/dev/azuredevops/policy/client.go#L26

Sample code

	createdPolicy, err := clients.PolicyClient.CreatePolicyConfiguration(clients.Ctx, policy.CreatePolicyConfigurationArgs{
		Configuration: policyConfig,
		Project:       projectID,
	})

	if err != nil) {
		return fmt.Errorf("Error creating policy in Azure DevOps: %+v", err)
	}

Error Response

Error: Error updating policy in Azure DevOps: parsing time ""2020-04-28T19:17:13.1093738"" as ""2006-01-02T15:04:05Z07:00"": cannot parse """ as "Z07:00"

Investigation
This is similar to the issue raised in #17. The fix put forward in that issue, however, is not applicable here because the time returned from the server does not equal 0001-01-01T00:00:00.

Note The policy is actually created in AzDO, which leads me to believe that the unmarshalling error is for this field specifically: https://github.com/microsoft/azure-devops-go-api/blob/dev/azuredevops/policy/models.go#L32

Support for Obtaining Job Requests By Pool

We have a use case where we need to get a list of all jobs - currently executing or queued for future execution - in a pool on a by-pool basis. We found the following route which provides this information: /distributedtask/pools/{poolId}/jobrequests. This appears to return a collection of TaskAgentJobRequest, which is defined in azuredevops/taskagent.models.go.

Does this API have support for this route endpoint? If not, are there plans to add support for this in the (near) future?

In the meantime, if this endpoint does not exist in the API, other than making the HTTP call directly and unmarshalling into the model ourselves, do you have any recommended path for obtaining this data?

Avoid double JSON marshalling in UnmarshalCollectionJson

UnmarshalCollectionJson uses a marshal/unmarshal strategy to return a strongly typed result from an REST API call that returns a collection like /_apis/graph/groups

value, err := json.Marshal(wrappedResponse.Value) // todo: investigate better way to do this.

With employing the GO reflect package, especially the StructOf function, this marshal/unmarshal process could be replaced by a more concise and probably more performant solution. With the help of StructOf the function can create a struct dynamically out of the required value attribute that has been passed as value (interface) type in parameter v interface{})

Proposed fix

func (client *Client) UnmarshalCollectionJson(jsonValue []byte, v interface{}) (err error) {
	t := reflect.TypeOf(v)
	if (t.Kind() == reflect.Ptr) {
	   t = t.Elem()
	} else {
	   return errors.New("value type must be a pointer")
	}
	sType := reflect.StructOf([]reflect.StructField{
		{Name: "Count", Type: reflect.TypeOf(0) },
		{Name: "Value", Type: t },
	})
	sv := reflect.New(sType)
	err = json.Unmarshal(jsonValue, sv.Interface())
	if err != nil {
	   return err
	}
	
	rv := reflect.ValueOf(v)
	rv.Elem().Set(sv.Elem().FieldByName("Value"))
	return nil
}

ContinuationToken type mismatch between GetReleasesResponseValue and GetReleasesArgs

In the release client.go file, the type for ContinuationToken differs between the GetReleasesResponseValue (which returns the continuation token as a string) and the GetReleasesArgs which takes the continuation token as an *int.

I can work around this by converting the string before continuing the calls to get more releases, but I'm not clear if this is intended behaviour or if I am making a mistake?

client.go lines 1069-1073:

type GetReleasesResponseValue struct {
	Value []Release
	// The continuation token to be used to get the next page of results.
	ContinuationToken string
}

client.go lines 1021-1045:

type GetReleasesArgs struct {
        // other properties excluded...
	// (optional) Gets the releases after the continuation token provided.
	ContinuationToken *int
}

Graph::ListGroups API call fails with a JSON unmarshaling error

The Graph API implementation for ListGroups consistently fails with a JSON unmarshaling error.

Steps to reproduce:

... initialize client
_, err := client.ListGroups(clients.ctx, graph.ListGroupsArgs{})

In my project, I need to call the API like this, which also fails:

client.ListGroups(clients.ctx, graph.ListGroupsArgs{
		ScopeDescriptor: &projectDescriptor,
		ContinuationToken: continuationToken,
})

After a brief look into the code, my initial hunch is that, possibly, the unmarshal code being called is UnmarshalBody, where it may need to be UnmarshalCollectionBody

The response in browser looks like this

{
  "count": 10,
  "value": [
    ...
  ]
}

RunPipeline is calling 5.1 preview API?

hi,
Thank you for writing this API. I'm trying to write a terraform provider to call this API to run my pipeline. I have written my version 1 code (new Go learner) and then I realize your RunPipeline function is calling Azure devops API 5.1 preview ? while 6.0 is available?
Here is your code to show you are pointing to 5.1-preview.
resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.1", routeValues, queryParams, bytes.NewReader(body), "application/json", "application/json", nil)

I still haven't get my code working, but I'm not sure whether I should continue to develop my code which bases on 5.1 preview API calling.

I'm currently stuck at Pipeline calling and not able to find RefName.
It basically located pipeline base on PipelineID but not able to take RefName as parameter and always refer to basic master branch instead of other branches.
I have tried both "refs/heads/xxxbranchName" and "xxxbranchName", not effect.

since it's using 5.1 preview API, I can't find document from Microsoft to details explain what API look like.

Can you upgrade the RunPipeline to API 6.0 at least?

Many thanks.

Create Pipeline

Hi

I'm trying to create a pipeline (well strictly speaking, clone a pipeline for backup purposes).
I can 'get' the a pipeline easily enough, has all my build steps, variables etc etc.. and I want to try and recreate the pipeline elsewhere. All of this is for backup/restore purposes.

My problem is the pipelines.CreatePipeline() function. The CreatePipelineArgs doesn't seem to have much in it. There is an InputParameter parameter, which in turn has a CreatePipelineConfigurationParameters instance (which again doesn't seem to have much there). I was picturing that somewhere in the payload for the CreatePipeline I would either be populating structures that are basically identical to what I get on the GetPipeline(), or accept JSON. But I'm wrong.

Can someone clarify if creation of pipeline is working?

Thanks

Ken

core.GetProject api fails with error when trying to unmarshal response from azdo

We have been trying to use the GetProject api passing in project name and getting an error that looks like it can't parse the lastUpdatedTime value in the response.

function that has the bug:

func (client *Client) GetProject(ctx context.Context, args GetProjectArgs) (*TeamProject, error) {

Error and struct returned:

parsing time ""0001-01-01T00:00:00"" as ""2006-01-02T15:04:05Z07:00"": cannot parse """ as "Z07:00"

&{ 0xc0002bae40 a790779a-4096-43b6-929f-1f1e47917f18 0001-01-01 00:00:00 +0000 UTC 0xc0002bae30 0xc0003305a0 0xc0002bae60 0xc0002bae50 0xc0002baf80 map[collection:map[href:https://dev.azure.com/csedevops/_apis/projectCollections/85fb3d5a-9f21-420f-8de3-fc80bf29054b] self:map[href:https://dev.azure.com/csedevops/_apis/projects/a790779a-4096-43b6-929f-1f1e47917f18] web:map[href:https://dev.azure.com/csedevops/tf_test]] 0xc00008e0e0 0xc0001d8380}

Example code that reproduces the error:

func getProject(ctx context.Context, clients *AggregatedClient) {
	t := true
	f := false
	p := "tf_test"

	args := core.GetProjectArgs{
		ProjectId:           &p,
		IncludeCapabilities: &t,
		IncludeHistory:      &f,
	}

	fmt.Println(args)

	project, err := clients.CoreClient.GetProject(ctx, args)

	if err != nil {
		fmt.Println(err)
	}

	fmt.Println(project)
}

Implement Handling of Retry-After Header

The client does not handle rate limiting correctly and should honor the Retry-After header:

https://docs.microsoft.com/en-us/azure/devops/integrate/concepts/rate-limits?view=azure-devops#recommendations

We recommend that you at least respond to the Retry-After header. If you detect a Retry-After header in any response, wait until that amount of time has passed before sending another request. Doing so helps your client application experience fewer enforced delays. Keep in mind that the response is 200, so you don't need to apply retry logic to the request.

BUG: Unable to deserialize JSON to SecurityNamespaceDescription

Currently it's not possible to use the Security Namespaces - Query REST method, because the JSON deserializer isn't able to convert the received JSON structure into the corresponding GO struct SecurityNamespaceDescription.

An error is issued that the received SeparatorValue value can't be deserialized into an int32 (rune)

image

SeparatorValue *rune `json:"separatorValue,omitempty"`

According to the REST documentation the datatype for the separatorValue field is string and not rune (alias for int32).

image

create branch request

I can't seem to find CreateBranch functionality in this api, am I missing something? Do I instead need to conduct a git push?

Creating a new build definition with trigger

With postman I am able to create a new build definition with a trigger with the following:
""triggers": [
{
"branchFilters": [
"+refs/heads/master"
],
"pathFilters": "",
"batchChanges": true,
"maxConcurrentBuildsPerBranch": 1,
"triggerType": "continuousIntegration"
}
]"

But with the go api. I am using the CI struct:

"type ContinuousIntegrationTrigger struct {
// Indicates whether changes should be batched while another CI build is running.
BatchChanges *bool json:"batchChanges,omitempty"
BranchFilters *[]string json:"branchFilters,omitempty"
// The maximum number of simultaneous CI builds that will run per branch.
MaxConcurrentBuildsPerBranch *int json:"maxConcurrentBuildsPerBranch,omitempty"
PathFilters *[]string json:"pathFilters,omitempty"
// The polling interval, in seconds.
PollingInterval *int json:"pollingInterval,omitempty"
// The ID of the job used to poll an external repository.
PollingJobId *uuid.UUID json:"pollingJobId,omitempty"
SettingsSourceType *int json:"settingsSourceType,omitempty"
}"

It won't create a trigger for me via the go api. I assume I am missing the triggerType from the payload because when I remove that from the postman payload it also won't work.

Is this some sort of defect that there is a missing "triggerType" field for the CI struct?

distributedtask/tasks is missing from API documentation and from taskagent.Client

Hello, I'm currently working on the microsoft/terraform-provider-azuredevops plugin and I'm looking for a way to convert the name of a task into the taskId.

Unfortunately the api, release.WorkflowTask.TaskId, requires a uuid and doesn't support using taskName in-lieu of uuid or a property taskName. I tested this with Postman to confirm. Ideally it would be great if the api supported taskName or taskId, however, the next best thing would be if distributedtask/taks was added to this library allowing us to get all of the distributed tasks and then cache them. Then we can just convert the name to the id dynamically using a map.

After looking thru the code It does not appear possible to retrieve distributed tasks with this library. The Azure DevOps portal places a call to /_apis/distributedtask/tasks to retrieve a complete list of tasks and displays them in the side bar. I was hoping to use this library to get the same data.

After some digging I also found that distributedtask/task is not listed on the documentation site. I was expecting it to be under taskagent.Client, however, I only found distributedtask/taskGroups by following this issue. Lastly also noticed the code for taskagent is autogenerated so I'm at a loss as to how to add this functionality, how does one contribute to this library?

Any suggestions? Any chance you can this to this library?

Struct GraphGroup does not export isDeleted property

While authoring acceptance tests for the Azure DevOps Terraform provider I discovered that type GraphGroup struct does not export the isDeleted property.

image

The acceptance test requires a check if a created group has been removed (deleted) by the destroy operation of Terraform. The issue is that a call to GetGroup of the Graph client the group is still returned so the acceptance test still assumes that the group was not destroyed and thus consequently fails. If the isDeleted property would be available in the struct, the implementation can check the state of the property to verify a successful destruction aside that the GetGroup method returns nil.

@nmiodice

Missing Task Agent Methods

graph::CreateUser - Unable to specify correct UserCreationContext

To create a user with graph.CreateUser we have to provide CreateUserArgs:

// Arguments for the CreateUser function
type CreateUserArgs struct {
	// (required) The subset of the full graph user used to uniquely find the graph subject in an external provider.
	CreationContext *GraphUserCreationContext
	// (optional) A comma separated list of descriptors of groups you want the graph user to join
	GroupDescriptors *[]string
}

The CreationContext decides if we create an aad, ad or msa account, but the current implementation only allows us to use the following context (which shouldn't be used):

// Do not attempt to use this type to create a new user. Use one of the subclasses instead. This type does not contain sufficient fields to create a new user.
type GraphUserCreationContext struct {
	// Optional: If provided, we will use this identifier for the storage key of the created user
	StorageKey *uuid.UUID `json:"storageKey,omitempty"`
}

Instead we should be able to provide one of the following:

type GraphUserPrincipalNameCreationContext struct {
	// Optional: If provided, we will use this identifier for the storage key of the created user
	StorageKey *uuid.UUID `json:"storageKey,omitempty"`
	// This should be the principal name or upn of the user in the source AD or AAD provider. Example: [email protected] Team Services will communicate with the source provider to fill all other fields on creation.
	PrincipalName *string `json:"principalName,omitempty"`
}

type GraphUserMailAddressCreationContext struct {
	// Optional: If provided, we will use this identifier for the storage key of the created user
	StorageKey  *uuid.UUID `json:"storageKey,omitempty"`
	MailAddress *string    `json:"mailAddress,omitempty"`
}

Authenticate using Bearer token

Hi,

We are using this library through the terraform provider for provisioning Azure DevOps resources as part of our Infrastructure as Code approach. Essentially to provision service connections and variable groups.

In this context, pipelines are run in Azure DevOps that trigger terraform templates which in turn needs to authenticate to Azure DevOps.

It would be a great security and maintainability improvement if we could use OAuth token rather than PAT to authenticate.

Regards,

Laurent Sibilla

git commit changes typing

I'm trying to update a few files in ado and following this example https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pushes/create?view=azure-devops-rest-5.1#update-a-file

I'm curious as to why the changes field isn't fully typed and is set as []interface{} instead https://github.com/microsoft/azure-devops-go-api/blob/dev/azuredevops/git/models.go#L574 despite the change type existing https://github.com/microsoft/azure-devops-go-api/blob/dev/azuredevops/git/models.go#L104?

Is this a problem with the generation or am I missing something here?

User @ Mentions

If I use the in-browser GUI editor to create or modify a DevOps wiki page, I can @ mention a user (e.g. @Jake Pearson) and it makes a link to their account and sends them an email notification. When I manually pull down the Git repo that represents the wiki, I can see the raw user ID (e.g. @<1601DE0C-4613-60D7-A201-537155816713>) instead of the @ mention in the created wiki page implying that the GUI is doing some sort of call on the backend to change a manual @ mention into that GUID.

When I use wiki.client.CreateOrUpdatePage(...) to push a string containing a user's ID (e.g. @Jake Pearson), no linking occurs. When I push the GUID, the page displays with the raw GUID instead of the nice @Jake Pearson. Is there a flag or something I need to flip in the wiki.client to make this work? Or is it simply not possible via the API?

Unable to create KeyVault backed variable group due to typing issues

When creating a KeyVault, we need to work with the following struct. I'm showing an abridged version here:

type VariableGroup struct {
	Name *string
	ProviderData *VariableGroupProviderData
	Variables *map[string]VariableValue
}

For most variable groups there is no problem. However, when creating a KeyVault backed variable group, the strict typing can become a challenge. There are 2 issues:

The lack of inheritence in Go requires the generated code to produce a VariableGroup that looks more like the following:

type VariableGroup struct {
	Name *string
	ProviderData interface{} // Maybe  pointer? Not sure...
	Variables map[string]interface{}  // Maybe  pointer? Not sure...
}

Note: We will need to be able to have this data in POST API calls as well as returned by the GET API call.

[feature] Add new taskagent resource functionality

It seems like the azure-devops-go-api doesn't support TaskAgentPoolOptions, from version 6.0 and ongoing, of the Azure DevOps REST API.

As of my understanding, the azure-devops-go-api is using an internal tool/code generator (genclient), hence I can't make a pull request and add the functionality manually. So I guess this will be a feature request.

It would be of great use, if you could add support for the new elastic pool (TaskAgentPool backed by the Elastic pool service) functionality of Azure DevOps (and all other new Task Agent resource functionality for that matter), to the taskagent, or where you consider would be most suitable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.