Skip to content

Commit 0689199

Browse files
authored
Merge pull request github#304 from github/edit-auditlog-graphql
Update Audit Log queries
2 parents c1d4f3d + 1297977 commit 0689199

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# This graphql queries for audit logs at the enterprise level
2+
3+
# Make sure that you set the request to `POST` with URL `https://api.github.com/graphql`
4+
# Set `Headers` where `Content-Type` is `application/json` and `Accept` is `application/vnd.github.audit-log-preview+json`
5+
6+
{
7+
enterprise(slug: "<enterprise-slug>") {
8+
organizations(first: 100){
9+
nodes {
10+
auditLog(last: 5) {
11+
edges {
12+
node {
13+
... on AuditEntry {
14+
# Get Audit Log Entry by 'Action'
15+
action
16+
actorLogin
17+
createdAt
18+
# User 'Action' was performed on
19+
user{
20+
name
21+
email
22+
}
23+
}
24+
}
25+
}
26+
}
27+
}
28+
}
29+
}
30+
}
31+
32+
# If you'd like to use environment variables, this is what it would look like:
33+
34+
query getAuditLog($slug: String!, $numEntries: Int!, $cursor: String){
35+
enterprise(slug: $slug) {
36+
organizations(first: 100){
37+
nodes {
38+
auditLog(last: $numEntries, before: $cursor) {
39+
edges {
40+
node {
41+
... on AuditEntry { # Get Audit Log Entry by 'Action'
42+
action
43+
actorLogin
44+
createdAt
45+
user { # User 'Action' was performed on
46+
name
47+
email
48+
}
49+
}
50+
}
51+
cursor
52+
}
53+
pageInfo {
54+
endCursor
55+
hasNextPage
56+
}
57+
totalCount
58+
}
59+
}
60+
}
61+
}
62+
}
63+
64+
# Envrionment variables:
65+
{
66+
"slug": "<enterprise-slug>",
67+
"numEntries": 5,
68+
"cursor": null
69+
}

graphql/queries/audit-log-api-example.graphql renamed to graphql/queries/org-audit-log-api-example.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ query {
4848
}
4949
}
5050
}
51-
}
51+
}

0 commit comments

Comments
 (0)