Last active
April 20, 2022 09:39
-
-
Save cnayan/585286b302a509c6b6de972ff5ecca16 to your computer and use it in GitHub Desktop.
Enterprise GitHub REST APIs for automation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Year 2022! | |
Here is how to make repos private: | |
curl -u <user_name>:<POWERFUL_PAT> -X PATCH -H "Accept: application/vnd.github.nebula-preview+json" -d "{\"visibility\":\"private\"}" https://<org_server>/api/v3/repos/{user_name}/{repo_name} | |
And this is how you move a repo to another user | |
curl -u <user_name>:<POWERFUL_PAT> -X POST -H "Accept: application/vnd.github.nebula-preview+json" -d "{\"new_owner\":\"platts\",\"team_ids\":[278,186]}" https://<org_server>/api/v3/repos/{user_name}/{repo_name}/transfer | |
Get the ID of a team by using | |
curl -u <user_name>:<POWERFUL_PAT> -H "Accept: application/vnd.github.nebula-preview+json" https://<org_server>/api/v3/orgs/platts/teams/{team_name} | |
Result: 278,186 etc. | |
POWERFUL_PAT - is a personal access token given enough privileges to do the above operations. | |
Documentation for REST APIs: https://docs.github.com/en/enterprise-server@3.2/rest/reference |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment