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

Conversation

james2791
Copy link
Contributor

Similar to what we have for the auditEvents query, just with a example using occurredAtFrom and occurredAtTo filtering

@buildkite-docs-bot
Copy link
Contributor

Preview URL: https://2301--bk-docs-preview.netlify.app

@@ -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 :)

@@ -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

Copy link
Contributor

@mbelton-buildkite mbelton-buildkite left a comment

Choose a reason for hiding this comment

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

One last comment about indenting, but otherwise looks good :)

Comment on lines 858 to 876
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!)

@mbelton-buildkite
Copy link
Contributor

Nice! Looks good to merge when you're ready :)

@james2791 james2791 merged commit 1addf5f into main Aug 11, 2023
1 check passed
@james2791 james2791 deleted the audit-event-time branch August 11, 2023 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants