Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added timeboxed Auditevents example to the GraphQL Cookbook #2301

Merged
merged 3 commits into from
Aug 11, 2023
Merged
Changes from 1 commit
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
27 changes: 27 additions & 0 deletions pages/apis/graphql/graphql_cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ query {
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thanks :)

```

Then, use the ID to delete the user:
Expand Down Expand Up @@ -851,6 +852,32 @@ Query your organization's audit events. Audit events are only available to Enter
}
```

### Get timeboxed organization audit events
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this still relates to audit events, I think it might be good to include it under the same heading. Thinking:

### Get organization audit events

Query your organization's audit events. Audit events are only available to Enterprise customers.

To get the first 500 audit events, use the following query:

```graphql
  query getOrganizationAuditEvents{
    organization(slug:"organization-slug"){
      auditEvents(first: 500){
        edges{
          node{
            type
            occurredAt
            actor{
              name
            }
            subject{
              name
              type
            }
          }
        }
      }
    }
  }
```

To get all audit events in a given period, use the `occurredAtFrom` and `occurredAtTo` filters like in the following query:

```graphql
  query getOrganizationAuditEvents{
    organization(slug:"organization-slug"){
      auditEvents(first: 500, occurredAtFrom: "2023-01-01T12:00:00.000", occurredAtTo: "2023-01-01T13:00:00.000"){
        edges{
          node{
            type
            occurredAt
            actor{
              name
            }
            subject{
              name
              type
            }
          }
        }
      }
    }
  }
```

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tweaked it to the above @mbelton-buildkite 🙂

Probably not needing that H2 anyway since its the same context, just filters


Query your organization's audit events in a timeboxed manner using the `occurredAtFrom` and `occurredAtTo` filters in an Organization's `auditEvents` field. Audit events are only available to Enterprise customers.

```graphql
query getOrganizationAuditEvents{
organization(slug:"organization-slug"){
auditEvents(first: 500, occurredAtFrom: "2023-01-01T12:00:00.000", occurredAtTo: "2023-01-01T13:00:00.000"){
edges{
node{
type
occurredAt
actor{
name
}
subject{
name
type
}
}
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs to be indented?

Suggested change
query getOrganizationAuditEvents{
organization(slug:"organization-slug"){
auditEvents(first: 500, occurredAtFrom: "2023-01-01T12:00:00.000", occurredAtTo: "2023-01-01T13:00:00.000"){
edges{
node{
type
occurredAt
actor{
name
}
subject{
name
type
}
}
}
}
}
}
query getOrganizationAuditEvents{
organization(slug:"organization-slug"){
auditEvents(first: 500, occurredAtFrom: "2023-01-01T12:00:00.000", occurredAtTo: "2023-01-01T13:00:00.000"){
edges{
node{
type
occurredAt
actor{
name
}
subject{
name
type
}
}
}
}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed that extra indentation @mbelton-buildkite 😉 (sitting on me for a bit - apologies!)

```

## Teams

A collection of common tasks with teams using the GraphQL API.
Expand Down