Exporting Users base on projects - azure-devops

Is there a way to export users based on project/teams? I need to create another team within another project but somehow I'm not able to add another project group to a different project

There isn't a straight forward way to do that. As a work around, you could use DevOps REST API to achieve this.
I am using DevOps PAT for Basic Auth.
Use this API to get userID in your DevOps organization: https://learn.microsoft.com/en-us/rest/api/azure/devops/memberentitlementmanagement/user-entitlements/get-user-entitlements?view=azure-devops-rest-5.1
GET https://vsaex.dev.azure.com/{organization}/_apis/userentitlements?api-version=5.1-preview.2
Create a new Team in another and use this API to get groupID for this Team: https://learn.microsoft.com/en-us/rest/api/azure/devops/graph/groups/list?view=azure-devops-rest-6.0&tabs=HTTP
GET https://vssps.dev.azure.com/{organization}/_apis/graph/groups?api-version=6.0-preview.1
With the userID and groupID collected, you could use this API to add members into this team: https://learn.microsoft.com/en-us/rest/api/azure/devops/memberentitlementmanagement/members/add?view=azure-devops-rest-5.1
PUT https://vsaex.dev.azure.com/{organization}/_apis/GroupEntitlements/{groupId}/members/{memberId}?api-version=5.1-preview.1

Related

Azure DevOps SaaS - Unable to distinct group and team name in REST API

I am trying to retrieve only the groups of an organization , example for a project in Project settings -> General -> Permissions , I would like to retrieve only the Type as "Group" . When using the below REST API, I get the Type "Team" also .
Rest API used - https://vssps.dev.azure.com/{CollectionName}/_apis/graph/groups?api-version=7.0-preview.1
How can I get the groups alone instead of getting Team names also.
Currently, here is not a directly way to realize it. For even in UI if you go to organization settings->permission you could not directly see type 'Team'.
But here is an idea for your reference. For we get rest api Groups - List(return include Teams in the org and groups in the org) and rest api Teams - Get All Teams, you could write your script to filter the Teams from the second rest api return from the first return one.
But if you do need the direct feature, we recommend that you can directly report the feature requests: https://developercommunity.visualstudio.com/report?space=22&entry=suggestion. That will allow you to directly interact with the appropriate engineering team and make it more convenient for the engineering team to collect and categorize your suggestions.

Can You Get Project Startdate from Azure DevOps REST API?

I'm trying to query the Azure Devops REST API to see when a project first came into existence and, perhaps, who created it. I'm using the link below and my results do match the documentation which, unfortunately, doesn't include create date. Is there any other ways to query AzDo REST API to get this data?
https://learn.microsoft.com/en-us/rest/api/azure/devops/core/projects/get%20project%20properties?view=azure-devops-rest-5.1
I am afraid there is no rest api to get the start date of project. The start date property is not included in the returned results of Get Project Api.
This issue has been reported to Microsoft develop team. You can vote up this thread or submit a new feature(Click Suggest a feature and choose Azure Devops).

How to setup Azure DevOps Repo Read Only Access

Objective: Allow different clients access to only read/pull from my private repo.
Overview:
Listed are the different options that I am aware of:
I could invite the clients and give them access to the Basic access level but do know what to have to pay for different users just to read/clone from the repo.
I could create a single user with Basic access level and then create git access tokens for them individually. However, I did not see a way to restrict the access tokens to be project/repo specific. Instead, the access tokens create had the same privileges as the created user.
Question: What is the best practice to provide access to an external user to only access the private Azure DevOps repo?
Note: I have seen this link and did not know if there were other options.
To make the user only have read access to all repos in one project:
You may consider making the user a reader instead of contributor or Project Administrators, so the user can have only read access to the repos in one project.
Organization Settings=>Users(General)=>Manage user=> select Project reader.
More details about project readers you can check this document.
To make the user only have read access to one special repos in one project:
We can control related permissions from Project Settings=>Repositories(Repos)=>Version Control Administrators:
Hope all above helps :)

Get changes associated with a build in Azure Devops using REST API

In Azure Devops under the "Summary" tab associated with a build, there are a list of changes (Git hashes, etc.) associated with the build. I'm trying to figure out how to get these via the rest API.
I found this REST API to get the changes between the two builds.
It works if I have the previous build id in the pipeline, however in the situation I'm interested in, I have the current build id, I need to somehow use the REST API to find the previous id.
Is there a way to do this using the REST API, or a better way to accomplish what I'm trying to do here?
As far as I can see, there's a special REST API call for that. You pass the buildId as a part of the URL and get the collection of changes (Change[]) in response.

How to get github users from city using Github REST API?

Background
I am working on an app and I need to get all the projects of all github users that live in a given city using the GitHub Rest API v3: https://developer.github.com/v3/
Research
Now I know I can get all the users with the following url:
https://api.github.com/users
And once I have a user, I can get all his repos and info from there.
Problem
The problem is that I don't know how to filter those users by city!
I have tried adding a paramter location=London but it always returns the same, probably because this is not the real parameter...
Another option would be to get all the github users from the world, and then filter them by city .... which would be totally insane.
The best option I found so far was to use this link:
https://github.com/search?q=language:javascript+location:Barcelona&type=Users
However, this link is the web version, which does not use the REST API.
Question
How do I get all the users from a given city using the Github REST API?
You are using the /users endpoint. You need to use the /search/users endpoint:
https://api.github.com/search/users?q=location%3Aiceland
Will search for users located in Iceland
Using that gets me a response with a bunch of users and after cross checking the first 3, they all have their location set to "Iceland" in their profiles.