Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def main(args):
ssl_verify=true


### GitHub Enterprise Teams
enterprise_team_name="enterprise-team1"

### GitHub API Version
# https://docs.github.com/en/rest/overview/api-versions
github_api_version=${github_api_version}
Expand Down
32 changes: 32 additions & 0 deletions create-an-enterprise-team.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-teams/enterprise-teams?apiVersion=2022-11-28#create-an-enterprise-team
# POST /enterprises/{enterprise}/teams


# If the script is passed an argument $1 use that as the name
if [ -z "$1" ]
then
enterprise_team_name=${enterprise_team_name}
else
enterprise_team_name=$1
fi

enterprise_team_description="An enterprise team called ${enterprise_team_name}"

json_file=tmp/create-an-enterprise-team.json

jq -n \
--arg name "${enterprise_team_name}" \
--arg description "${enterprise_team_description}" \
'{
name : $name,
description: $description
}' > ${json_file}

curl ${curl_custom_flags} \
-H "X-GitHub-Api-Version: ${github_api_version}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/enterprises/${enterprise}/teams" --data @${json_file}

22 changes: 22 additions & 0 deletions delete-an-enterprise-team.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-teams/enterprise-teams?apiVersion=2022-11-28#delete-an-enterprise-team
# DELETE /enterprises/{enterprise}/teams/{team_slug}


# If the script is passed an argument $1 use that as the name
if [ -z "$1" ]
then
team_slug=$enterprise_team_name
else
team_slug=$1
fi


curl ${curl_custom_flags} \
-X DELETE \
-H "X-GitHub-Api-Version: ${github_api_version}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/enterprises/${enterprise}/teams/${team_slug}"

20 changes: 20 additions & 0 deletions get-an-enterprise-team.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-teams/enterprise-teams?apiVersion=2022-11-28#get-an-enterprise-team
# GET /enterprises/{enterprise}/teams/${team_slug}


# If the script is passed an argument $1 use that as the name
if [ -z "$1" ]
then
team_slug=${enterprise_team_name}
else
team_slug=$1
fi

curl ${curl_custom_flags} \
-H "X-GitHub-Api-Version: ${github_api_version}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/enterprises/${enterprise}/teams/${team_slug}"

20 changes: 20 additions & 0 deletions list-enterprise-teams.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-teams/enterprise-teams?apiVersion=2022-11-28#list-enterprise-teams
# GET /enterprises/{enterprise}/teams


# If the script is passed an argument $1 use that as the name
if [ -z "$1" ]
then
enterprise=$enterprise
else
enterprise=$1
fi

curl ${curl_custom_flags} \
-H "X-GitHub-Api-Version: ${github_api_version}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/enterprises/${enterprise}/teams"

25 changes: 25 additions & 0 deletions update-an-enterprise-team.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-teams/enterprise-teams?apiVersion=2022-11-28#update-an-enterprise-team
# PATCH /enterprises/{enterprise}/teams/{team_slug}


team_slug=${enterprise_team_name}
new_team_name="${team_slug}-new"

json_file=tmp/update-an-enterprise-team.json

jq -n \
--arg name "${new_team_name}" \
'{
name : $name,
}' > ${json_file}


curl ${curl_custom_flags} \
-X PATCH \
-H "X-GitHub-Api-Version: ${github_api_version}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/enterprises/${enterprise}/teams/${team_slug}" --data @${json_file}