Skip to content

Instantly share code, notes, and snippets.

@cnayan
Last active April 20, 2022 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnayan/585286b302a509c6b6de972ff5ecca16 to your computer and use it in GitHub Desktop.
Save cnayan/585286b302a509c6b6de972ff5ecca16 to your computer and use it in GitHub Desktop.
Enterprise GitHub REST APIs for automation
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