Skip to content

Commit 2ef71ce

Browse files
committed
Parameterize IP allow get ip allow lists (ent and org)
Output is also formated as a tsv
1 parent 19b5421 commit 2ef71ce

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

gh-cli/get-enterprise-ip-allow-list.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
# gh cli's token needs to be able to admin enterprise - run this first if it can't
44
# gh auth refresh -h github.com -s admin:enterprise
55

6-
gh api graphql --paginate -f enterpriseName='my-enterprise' -f query='
6+
if [ $# -lt "1" ]; then
7+
echo "Usage: $0 <enterprise-slug>"
8+
exit 1
9+
fi
10+
11+
enterprise=$1
12+
13+
gh api graphql --paginate -f enterpriseName="$enterprise" -f query='
714
query getEnterpriseIpAllowList($enterpriseName: String! $endCursor: String) {
815
enterprise(slug: $enterpriseName) {
916
ownerInfo {
@@ -23,4 +30,4 @@ query getEnterpriseIpAllowList($enterpriseName: String! $endCursor: String) {
2330
}
2431
}
2532
}
26-
}'
33+
}' --jq '.data.enterprise.ownerInfo.ipAllowListEntries.nodes[] | [.id, .allowListValue, .name, .isActive, .createdAt, .updatedAt] | @tsv'

gh-cli/get-organization-ip-allow-list.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
# gh cli's token needs to be able to admin organization - run this first if it can't
44
# gh auth refresh -h github.com -s admin:org
55

6-
gh api graphql --paginate -f organizationName='my-org' -f query='
6+
if [ $# -lt "1" ]; then
7+
echo "Usage: $0 <organization>"
8+
exit 1
9+
fi
10+
11+
org=$1
12+
13+
gh api graphql --paginate -f organizationName="$org" -f query='
714
query getOrganizationIpAllowList($organizationName: String! $endCursor: String) {
815
organization(login: $organizationName) {
916
ipAllowListEntries(first: 100, after: $endCursor) {
@@ -21,4 +28,4 @@ query getOrganizationIpAllowList($organizationName: String! $endCursor: String)
2128
}
2229
}
2330
}
24-
}'
31+
}' --jq '.data.organization.ipAllowListEntries.nodes[] | [.id, .allowListValue, .name, .isActive, .createdAt, .updatedAt] | @tsv'

0 commit comments

Comments
 (0)