diff --git a/docs/sources/query-editor.md b/docs/sources/query-editor.md index 049a3cd9..ab2dcb0b 100644 --- a/docs/sources/query-editor.md +++ b/docs/sources/query-editor.md @@ -20,7 +20,7 @@ labels: - enterprise - cloud weight: 200 -review_date: "2026-03-11" +review_date: '2026-03-11' --- # GitHub query editor @@ -50,6 +50,7 @@ Select a query type from the **Query Type** drop-down in the query editor: - [**Releases**](#releases): List created releases for a repository. - [**Repositories**](#repositories): List repositories for a user or organization. - [**Stargazers**](#stargazers): Get a list of users who have starred a repository, including the ability to plot a total count over time. +- [**Team members**](#team-members): List members of a GitHub organization team. - [**Tags**](#tags): List created tags for a repository. - [**Vulnerabilities**](#vulnerabilities): Query security vulnerabilities detected in a repository. - [**Webhook deliveries**](#webhook-deliveries): List deliveries of an organization or repository webhook, including the response status code. @@ -57,6 +58,27 @@ Select a query type from the **Query Type** drop-down in the query editor: - [**Workflow runs**](#workflow-runs): List runs for a specific workflow, including status, conclusion, and timing information. - [**Workflow usage**](#workflow-usage): Retrieve usage statistics for a workflow, such as run counts and durations. +### Team members + +List the members of a team in a GitHub organization. This query can also be used as a dashboard variable query to keep a roster synchronized with GitHub at dashboard runtime. + +#### Query options + +| Name | Description | Required | +| --------- | -------------------------------- | -------- | +| Owner | GitHub organization login | Yes | +| Team slug | Team slug (not its display name) | Yes | + +#### Response + +| Name | Description | +| ----- | --------------------------------------------------- | +| login | GitHub username; use this as the variable value/key | +| name | Member's display name | +| url | Link to the member's GitHub profile | + +The configured GitHub token or app must be allowed to view the organization and team membership. For classic personal access tokens, the `read:org` scope is required to read organization membership. + ### Code scanning Query code scanning alerts for a repository or organization. Useful for tracking security issues detected by GitHub's code scanning tools. @@ -67,12 +89,12 @@ Code scanning requires additional permissions. Refer to [Code scanning permissio #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository. Leave empty to query alerts at the organization level. | No | -| State | Filter by alert state: `open`, `closed`, `dismissed`, or `fixed` | No | -| Ref | The Git reference to filter results. Format as `refs/heads/` or ``. For pull requests, use `refs/pull//merge`. | No | +| Name | Description | Required | +| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository. Leave empty to query alerts at the organization level. | No | +| State | Filter by alert state: `open`, `closed`, `dismissed`, or `fixed` | No | +| Ref | The Git reference to filter results. Format as `refs/heads/` or ``. For pull requests, use `refs/pull//merge`. | No | ##### Sample queries @@ -90,27 +112,27 @@ Show all code scanning alerts across the `grafana` organization: #### Response -| Name | Description | -|------|-------------| -| number | Alert number | -| created_at | When the alert was created: YYYY-MM-DD HH:MM:SS | -| updated_at | When the alert was last updated: YYYY-MM-DD HH:MM:SS | -| dismissed_at | When the alert was dismissed, if applicable: YYYY-MM-DD HH:MM:SS | -| url | URL to the alert in the GitHub web UI | -| state | Alert state: `open`, `closed`, `dismissed`, or `fixed` | -| dismissed_by | GitHub handle of the user who dismissed the alert | -| dismissed_reason | Reason the alert was dismissed | -| dismissed_comment | Comment provided when the alert was dismissed | -| rule_id | Identifier for the rule that triggered the alert | -| rule_severity | Severity level of the rule | -| rule_security_severity_level | Security severity level of the rule | -| rule_description | Short description of the rule | -| rule_full_description | Full description of the rule | -| rule_tags | Comma-separated list of tags associated with the rule | -| rule_help | Help text for the rule | -| tool_name | Name of the code scanning tool | -| tool_version | Version of the code scanning tool | -| tool_guid | GUID of the code scanning tool | +| Name | Description | +| ---------------------------- | ---------------------------------------------------------------- | +| number | Alert number | +| created_at | When the alert was created: YYYY-MM-DD HH:MM:SS | +| updated_at | When the alert was last updated: YYYY-MM-DD HH:MM:SS | +| dismissed_at | When the alert was dismissed, if applicable: YYYY-MM-DD HH:MM:SS | +| url | URL to the alert in the GitHub web UI | +| state | Alert state: `open`, `closed`, `dismissed`, or `fixed` | +| dismissed_by | GitHub handle of the user who dismissed the alert | +| dismissed_reason | Reason the alert was dismissed | +| dismissed_comment | Comment provided when the alert was dismissed | +| rule_id | Identifier for the rule that triggered the alert | +| rule_severity | Severity level of the rule | +| rule_security_severity_level | Security severity level of the rule | +| rule_description | Short description of the rule | +| rule_full_description | Full description of the rule | +| rule_tags | Comma-separated list of tags associated with the rule | +| rule_help | Help text for the rule | +| tool_name | Name of the code scanning tool | +| tool_version | Version of the code scanning tool | +| tool_guid | GUID of the code scanning tool | ### Commits @@ -118,12 +140,12 @@ Retrieve a list of commits for a branch or ref within a repository, including co #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | -| Ref (Branch/Tag) | The branch or tag to list commits against | Yes | -| Include files | Include file-level change details for each commit. For details, refer to [Response with Include files enabled](#response-with-include-files-enabled). | No | +| Name | Description | Required | +| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | +| Ref (Branch/Tag) | The branch or tag to list commits against | Yes | +| Include files | Include file-level change details for each commit. For details, refer to [Response with Include files enabled](#response-with-include-files-enabled). | No | ##### Sample queries @@ -141,16 +163,16 @@ Show all commits against a tag: #### Response -| Name | Description | -|------|-------------| -| id | Commit ID | -| author | Name of the commit author | -| author_login | GitHub handle of the commit author | -| author_email | Email address of the commit author | -| author_company | Company name of the commit author | -| committed_at | When the change was committed: YYYY-MM-DD HH:MM:SS | -| pushed_at | When the commit was pushed: YYYY-MM-DD HH:MM:SS | -| message | The commit message | +| Name | Description | +| -------------- | -------------------------------------------------- | +| id | Commit ID | +| author | Name of the commit author | +| author_login | GitHub handle of the commit author | +| author_email | Email address of the commit author | +| author_company | Company name of the commit author | +| committed_at | When the change was committed: YYYY-MM-DD HH:MM:SS | +| pushed_at | When the commit was pushed: YYYY-MM-DD HH:MM:SS | +| message | The commit message | #### Response with Include files enabled @@ -160,22 +182,22 @@ This option makes one additional API call per commit. Avoid enabling it over lar When **Include files** is enabled, the response returns one row for each changed file in each commit: -| Name | Description | -|------|-------------| -| id | Commit ID | -| author | Name of the commit author | -| author_login | GitHub handle of the commit author | -| author_email | Email address of the commit author | -| author_company | Company name of the commit author | -| committed_at | When the change was committed: YYYY-MM-DD HH:MM:SS | -| pushed_at | When the commit was pushed: YYYY-MM-DD HH:MM:SS | -| message | The commit message | -| file_path | Path of the changed file | -| file_additions | Number of lines added in this file | -| file_deletions | Number of lines deleted in this file | -| file_changes | Total number of line changes in this file | -| file_status | Change type: `added`, `modified`, `renamed`, etc. | -| previous_filename | Original path for renamed files | +| Name | Description | +| ----------------- | -------------------------------------------------- | +| id | Commit ID | +| author | Name of the commit author | +| author_login | GitHub handle of the commit author | +| author_email | Email address of the commit author | +| author_company | Company name of the commit author | +| committed_at | When the change was committed: YYYY-MM-DD HH:MM:SS | +| pushed_at | When the commit was pushed: YYYY-MM-DD HH:MM:SS | +| message | The commit message | +| file_path | Path of the changed file | +| file_additions | Number of lines added in this file | +| file_deletions | Number of lines deleted in this file | +| file_changes | Total number of line changes in this file | +| file_status | Change type: `added`, `modified`, `renamed`, etc. | +| previous_filename | Original path for renamed files | ### Commit files @@ -187,24 +209,24 @@ The GitHub API returns at most 300 files for a single commit. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | -| Commit SHA | The SHA of the target commit | Yes | +| Name | Description | Required | +| ---------- | -------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | +| Commit SHA | The SHA of the target commit | Yes | #### Response The response includes one row per changed file: -| Name | Description | -|------|-------------| -| path | Path of the changed file | -| additions | Number of lines added | -| deletions | Number of lines deleted | -| changes | Total number of line changes | -| status | Change type: `added`, `modified`, `renamed`, etc. | -| previous_filename | Original path for renamed files | +| Name | Description | +| ----------------- | ------------------------------------------------- | +| path | Path of the changed file | +| additions | Number of lines added | +| deletions | Number of lines deleted | +| changes | Total number of line changes | +| status | Change type: `added`, `modified`, `renamed`, etc. | +| previous_filename | Original path for renamed files | ### Check runs @@ -216,37 +238,37 @@ The reference can be a commit SHA, a branch formatted as `heads/`, #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | -| Ref | The commit SHA, branch, or tag to list check runs for | Yes | -| Check name | Only return check runs with this exact name | No | -| Status | Only return check runs with the given status: `queued`, `in_progress`, or `completed` | No | -| Filter | `latest` returns the most recent check run for each name, `all` returns every check run. Defaults to `latest` | No | +| Name | Description | Required | +| ---------- | ------------------------------------------------------------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | +| Ref | The commit SHA, branch, or tag to list check runs for | Yes | +| Check name | Only return check runs with this exact name | No | +| Status | Only return check runs with the given status: `queued`, `in_progress`, or `completed` | No | +| Filter | `latest` returns the most recent check run for each name, `all` returns every check run. Defaults to `latest` | No | #### Response The response includes one row per check run: -| Name | Description | -|------|-------------| -| id | Unique identifier of the check run | -| name | Name of the check run | -| head_sha | SHA of the commit the check run is associated with | -| status | Current status: `queued`, `in_progress`, or `completed` | -| conclusion | Result of a completed check run, such as `success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, or `action_required` | -| started_at | Time the check run started | -| completed_at | Time the check run completed, empty while it is still running | -| duration_seconds | How long the check run took in seconds, empty while it is still running | -| html_url | URL of the check run on GitHub | -| details_url | URL of the external site with the full check run details | -| app_name | Name of the GitHub App that created the check run | -| app_slug | Slug of the GitHub App that created the check run | -| check_suite_id | Identifier of the check suite the check run belongs to | -| output_title | Title of the check run output | -| output_summary | Summary of the check run output | -| annotations_count | Number of annotations attached to the check run | +| Name | Description | +| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------- | +| id | Unique identifier of the check run | +| name | Name of the check run | +| head_sha | SHA of the commit the check run is associated with | +| status | Current status: `queued`, `in_progress`, or `completed` | +| conclusion | Result of a completed check run, such as `success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, or `action_required` | +| started_at | Time the check run started | +| completed_at | Time the check run completed, empty while it is still running | +| duration_seconds | How long the check run took in seconds, empty while it is still running | +| html_url | URL of the check run on GitHub | +| details_url | URL of the external site with the full check run details | +| app_name | Name of the GitHub App that created the check run | +| app_slug | Slug of the GitHub App that created the check run | +| check_suite_id | Identifier of the check suite the check run belongs to | +| output_title | Title of the check run output | +| output_summary | Summary of the check run output | +| annotations_count | Number of annotations attached to the check run | ### Contributors @@ -258,11 +280,11 @@ This query returns a maximum of 200 results. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | -| Query | Filter for contributors by name or GitHub handle | No | +| Name | Description | Required | +| ---------- | -------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | +| Query | Filter for contributors by name or GitHub handle | No | ##### Sample queries @@ -279,13 +301,13 @@ Search for contributors with `bob` in their name or handle: #### Response -| Name | Description | -|------|-------------| -| name | Display name of the contributor | -| login | GitHub handle of the contributor | -| email | Email address of the contributor | -| company | Company name of the contributor | -| url | URL to the contributor's GitHub profile | +| Name | Description | +| ------- | --------------------------------------- | +| name | Display name of the contributor | +| login | GitHub handle of the contributor | +| email | Email address of the contributor | +| company | Company name of the contributor | +| url | URL to the contributor's GitHub profile | ### Deployments @@ -293,14 +315,14 @@ List deployments for a repository, including environment, ref, and task informat #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | GitHub user or organization that owns the repository | Yes | -| Repository | Name of the repository | Yes | -| SHA | Filter deployments by the SHA recorded at creation time | No | -| Ref | Filter by ref name (branch, tag, or SHA) | No | -| Task | Filter by task name (for example, `deploy` or `deploy:migrations`) | No | -| Environment | Filter by environment name (for example, `production`, `staging`, or `qa`) | No | +| Name | Description | Required | +| ----------- | -------------------------------------------------------------------------- | -------- | +| Owner | GitHub user or organization that owns the repository | Yes | +| Repository | Name of the repository | Yes | +| SHA | Filter deployments by the SHA recorded at creation time | No | +| Ref | Filter by ref name (branch, tag, or SHA) | No | +| Task | Filter by task name (for example, `deploy` or `deploy:migrations`) | No | +| Environment | Filter by environment name (for example, `production`, `staging`, or `qa`) | No | ##### Sample queries @@ -323,19 +345,19 @@ Show all deployments for a specific branch: #### Response -| Name | Description | -|------|-------------| -| id | Unique identifier for the deployment | -| sha | SHA of the commit that was deployed | -| ref | Ref (branch, tag, or SHA) that was deployed | -| task | Task name (for example, `deploy` or `deploy:migrations`) | -| environment | Environment name (for example, `production` or `staging`) | -| description | Description of the deployment | -| creator | GitHub handle of the user who created the deployment | -| created_at | When the deployment was created: YYYY-MM-DD HH:MM:SS | -| updated_at | When the deployment was last updated: YYYY-MM-DD HH:MM:SS | -| url | API URL for the deployment | -| statuses_url | API URL for the deployment statuses | +| Name | Description | +| ------------ | --------------------------------------------------------- | +| id | Unique identifier for the deployment | +| sha | SHA of the commit that was deployed | +| ref | Ref (branch, tag, or SHA) that was deployed | +| task | Task name (for example, `deploy` or `deploy:migrations`) | +| environment | Environment name (for example, `production` or `staging`) | +| description | Description of the deployment | +| creator | GitHub handle of the user who created the deployment | +| created_at | When the deployment was created: YYYY-MM-DD HH:MM:SS | +| updated_at | When the deployment was last updated: YYYY-MM-DD HH:MM:SS | +| url | API URL for the deployment | +| statuses_url | API URL for the deployment statuses | ### Issues @@ -347,12 +369,12 @@ This query returns a maximum of 1000 results. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | A GitHub user or organization | Yes | -| Repository | The name of a repository | No | -| Query | Use GitHub's [query syntax](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests) to filter results | No | -| Time field | The time field to filter the responses on: `CreatedAt`, `ClosedAt`, or `UpdatedAt` | Yes | +| Name | Description | Required | +| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | +| Owner | A GitHub user or organization | Yes | +| Repository | The name of a repository | No | +| Query | Use GitHub's [query syntax](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests) to filter results | No | +| Time field | The time field to filter the responses on: `CreatedAt`, `ClosedAt`, or `UpdatedAt` | Yes | ##### Sample queries @@ -383,21 +405,21 @@ Show issues created in the last 7 days using the `$__toDay` macro: #### Response -| Name | Description | -|------|-------------| -| title | Issue title | -| author | GitHub handle of the author | -| author_company | Company name of the commit author | -| repo | Issue repository | -| number | Issue number | -| state | Issue state: `open` or `closed` | -| closed | `true` or `false` | -| created_at | When the issue was created: YYYY-MM-DD HH:MM:SS | -| closed_at | When the issue was closed: YYYY-MM-DD HH:MM:SS | -| updated_at | When the issue was last updated: YYYY-MM-DD HH:MM:SS | -| labels | Array of labels, for example: `["type/bug", "needs more info"]` | -| assignees | Array of assignees, for example: `["user1", "user2"]` | -| milestone | Milestone title associated with the issue, if applicable | +| Name | Description | +| -------------- | --------------------------------------------------------------- | +| title | Issue title | +| author | GitHub handle of the author | +| author_company | Company name of the commit author | +| repo | Issue repository | +| number | Issue number | +| state | Issue state: `open` or `closed` | +| closed | `true` or `false` | +| created_at | When the issue was created: YYYY-MM-DD HH:MM:SS | +| closed_at | When the issue was closed: YYYY-MM-DD HH:MM:SS | +| updated_at | When the issue was last updated: YYYY-MM-DD HH:MM:SS | +| labels | Array of labels, for example: `["type/bug", "needs more info"]` | +| assignees | Array of assignees, for example: `["user1", "user2"]` | +| milestone | Milestone title associated with the issue, if applicable | ### Labels @@ -405,11 +427,11 @@ Get all labels defined in a repository, useful for categorizing issues and pull #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | -| Query | Filter on text in name and description for labels | No | +| Name | Description | Required | +| ---------- | -------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | +| Query | Filter on text in name and description for labels | No | ##### Sample queries @@ -420,11 +442,11 @@ Show all labels for the `grafana/grafana` repository: #### Response -| Name | Description | -|------|-------------| -| name | Label name | -| color | Hexadecimal number | -| description | Label description | +| Name | Description | +| ----------- | ------------------ | +| name | Label name | +| color | Hexadecimal number | +| description | Label description | ### Milestones @@ -432,11 +454,11 @@ Retrieve milestones for a repository, which can be used to group issues and pull #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | -| Query | Filter on text in the milestone title | No | +| Name | Description | Required | +| ---------- | -------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | +| Query | Filter on text in the milestone title | No | ##### Sample queries @@ -448,15 +470,15 @@ Show all milestones for the `grafana/grafana` repository for v11 of Grafana: #### Response -| Name | Description | -|------|-------------| -| title | Milestone title | -| author | GitHub handle of the user who created the milestone | -| closed | Whether the milestone is closed: `true` or `false` | -| state | One of `OPEN` or `CLOSED` | +| Name | Description | +| ---------- | --------------------------------------------------- | +| title | Milestone title | +| author | GitHub handle of the user who created the milestone | +| closed | Whether the milestone is closed: `true` or `false` | +| state | One of `OPEN` or `CLOSED` | | created_at | When the milestone was created: YYYY-MM-DD HH:MM:SS | -| closed_at | When the milestone was closed: YYYY-MM-DD HH:MM:SS | -| due_at | When the milestone is due by: YYYY-MM-DD HH:MM:SS | +| closed_at | When the milestone was closed: YYYY-MM-DD HH:MM:SS | +| due_at | When the milestone is due by: YYYY-MM-DD HH:MM:SS | {{< admonition type="note" >}} Milestone titles can be anything and are therefore parsed as a string. This means sorting by title may appear incorrect if you have numeric milestones, for example: `12.0.0`. [Transformations](https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/transform-data/) can be used to change the data type in this scenario. @@ -472,12 +494,12 @@ This query doesn't support querying npm, RubyGems, or NuGet packages. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | -| Package type | One of: `MAVEN`, `DOCKER`, `DEBIAN`, or `PYPI` | Yes | -| Names | Filter for packages using a comma-separated list of names | No | +| Name | Description | Required | +| ------------ | --------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | +| Package type | One of: `MAVEN`, `DOCKER`, `DEBIAN`, or `PYPI` | Yes | +| Names | Filter for packages using a comma-separated list of names | No | ##### Sample queries @@ -487,14 +509,14 @@ Show all packages uploaded to the `grafana` organization: #### Response -| Name | Description | -|------|-------------| -| name | Package name | -| platform | Platform or registry where the package is published | -| version | Package version | -| type | Package type (for example, `MAVEN`, `DOCKER`, `DEBIAN`, `PYPI`) | -| prerelease | Whether the package version is a prerelease: `true` or `false` | -| downloads | Number of downloads for the package version | +| Name | Description | +| ---------- | --------------------------------------------------------------- | +| name | Package name | +| platform | Platform or registry where the package is published | +| version | Package version | +| type | Package type (for example, `MAVEN`, `DOCKER`, `DEBIAN`, `PYPI`) | +| prerelease | Whether the package version is a prerelease: `true` or `false` | +| downloads | Number of downloads for the package version | ### Projects @@ -506,13 +528,13 @@ This query returns a maximum of 200 results. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Project Owner | One of `Organization` or `User` | Yes | -| Organization | Organization for the project (shown when Organization is selected) | Yes | -| User | User for the project (shown when User is selected) | Yes | -| Project Number | Enter a specific project number to query for associated items | No | -| Filter | Add key-value filters based on the fields for project items (shown if Project Number is specified) | No | +| Name | Description | Required | +| -------------- | -------------------------------------------------------------------------------------------------- | -------- | +| Project Owner | One of `Organization` or `User` | Yes | +| Organization | Organization for the project (shown when Organization is selected) | Yes | +| User | User for the project (shown when User is selected) | Yes | +| Project Number | Enter a specific project number to query for associated items | No | +| Filter | Add key-value filters based on the fields for project items (shown if Project Number is specified) | No | ##### Sample queries @@ -534,17 +556,17 @@ The response format depends on whether a project number is specified. ##### Without a project number -| Name | Description | -|------|-------------| -| number | The project number | -| title | Title of the project | -| url | URL for the project | -| closed | Whether the project has been closed: `true` or `false` | -| public | Whether the project is public: `true` or `false` | -| closed_at | When the project was closed: YYYY-MM-DD HH:MM:SS | -| updated_at | When the project was last updated | -| created_at | When the project was created | -| short_description | The description of the project | +| Name | Description | +| ----------------- | ------------------------------------------------------ | +| number | The project number | +| title | Title of the project | +| url | URL for the project | +| closed | Whether the project has been closed: `true` or `false` | +| public | Whether the project is public: `true` or `false` | +| closed_at | When the project was closed: YYYY-MM-DD HH:MM:SS | +| updated_at | When the project was last updated | +| created_at | When the project was created | +| short_description | The description of the project | ##### With a project number @@ -552,23 +574,23 @@ The response format depends on whether a project number is specified. GitHub Projects allow for customization of default fields and custom fields to be added. Therefore, the response can vary significantly between projects. {{< /admonition >}} -| Name | Description | -|------|-------------| -| name | Name of the project item (issue or pull request) | -| id | Unique identifier for the project item | -| type | Type of the item (such as `ISSUE`, `PULL_REQUEST`) | -| status | Status of the item (such as "In development", "Shipped") -- this can be configured on the project | -| labels | Comma-separated list of labels assigned to the item | -| assignees | Comma-separated list of users assigned to the item | -| reviewers | Comma-separated list of reviewers (for pull requests) | -| repository | Name of the repository the item belongs to | -| milestone | Milestone associated with the item | -| priority | Priority value or label | -| archived | Whether the item is archived: `true` or `false` | -| created_at | When the item was created: YYYY-MM-DD HH:MM:SS | -| updated_at | When the item was last updated: YYYY-MM-DD HH:MM:SS | -| closed_at | When the item was closed, if applicable: YYYY-MM-DD HH:MM:SS | -| (custom fields) | Any custom defined fields are also returned alongside their values | +| Name | Description | +| --------------- | ------------------------------------------------------------------------------------------------- | +| name | Name of the project item (issue or pull request) | +| id | Unique identifier for the project item | +| type | Type of the item (such as `ISSUE`, `PULL_REQUEST`) | +| status | Status of the item (such as "In development", "Shipped") -- this can be configured on the project | +| labels | Comma-separated list of labels assigned to the item | +| assignees | Comma-separated list of users assigned to the item | +| reviewers | Comma-separated list of reviewers (for pull requests) | +| repository | Name of the repository the item belongs to | +| milestone | Milestone associated with the item | +| priority | Priority value or label | +| archived | Whether the item is archived: `true` or `false` | +| created_at | When the item was created: YYYY-MM-DD HH:MM:SS | +| updated_at | When the item was last updated: YYYY-MM-DD HH:MM:SS | +| closed_at | When the item was closed, if applicable: YYYY-MM-DD HH:MM:SS | +| (custom fields) | Any custom defined fields are also returned alongside their values | ### Pull requests @@ -576,12 +598,12 @@ List pull requests for a repository, using the GitHub query syntax to filter the #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | A GitHub user or organization | Yes | -| Repository | The name of a repository | No | -| Query | Use GitHub's [query syntax](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests) to filter results | No | -| Time field | The time field to filter the responses on: `CreatedAt`, `ClosedAt`, `MergedAt`, `UpdatedAt`, or `None` | Yes | +| Name | Description | Required | +| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | +| Owner | A GitHub user or organization | Yes | +| Repository | The name of a repository | No | +| Query | Use GitHub's [query syntax](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests) to filter results | No | +| Time field | The time field to filter the responses on: `CreatedAt`, `ClosedAt`, `MergedAt`, `UpdatedAt`, or `None` | Yes | ##### Sample queries @@ -615,34 +637,34 @@ Show open pull requests with a specific label: #### Response -| Name | Description | -|------|-------------| -| number | Pull request number | -| title | Pull request title | -| url | URL to the pull request | -| additions | Total number of lines of code added or altered in the pull request | -| deletions | Total number of lines of code removed or altered in the pull request | -| repository | Repository for the pull request | -| state | Can be `OPEN`, `CLOSED`, or `MERGED` | -| author_name | Name of the GitHub user who created the pull request | -| author_login | GitHub handle of the GitHub user who created the pull request | -| author_email | Email address of the GitHub user who created the pull request | -| author_company | Company name of the GitHub user who created the pull request | -| closed | Whether the pull request is closed: `true` or `false` | -| is_draft | Whether the pull request is in draft: `true` or `false` | -| locked | Whether the pull request has been locked: `true` or `false` | -| merged | Whether the pull request has been merged | -| mergeable | Whether the pull request can be automatically merged: `MERGEABLE`, `CONFLICTING`, or `UNKNOWN` | -| closed_at | When the pull request was closed: YYYY-MM-DD HH:MM:SS | -| merged_at | When the pull request was merged: YYYY-MM-DD HH:MM:SS | -| merged_by_name | Name of the GitHub user who merged the pull request | -| merged_by_login | GitHub handle of the GitHub user who merged the pull request | -| merged_by_email | Email address of the GitHub user who merged the pull request | -| merged_by_company | Company name of the GitHub user who merged the pull request | -| updated_at | When the pull request was last updated: YYYY-MM-DD HH:MM:SS | -| created_at | When the pull request was created: YYYY-MM-DD HH:MM:SS | -| open_time | Duration in seconds the pull request has been open | -| labels | Array of labels assigned to the pull request, for example: `["bug", "priority/high"]` | +| Name | Description | +| ----------------- | ---------------------------------------------------------------------------------------------- | +| number | Pull request number | +| title | Pull request title | +| url | URL to the pull request | +| additions | Total number of lines of code added or altered in the pull request | +| deletions | Total number of lines of code removed or altered in the pull request | +| repository | Repository for the pull request | +| state | Can be `OPEN`, `CLOSED`, or `MERGED` | +| author_name | Name of the GitHub user who created the pull request | +| author_login | GitHub handle of the GitHub user who created the pull request | +| author_email | Email address of the GitHub user who created the pull request | +| author_company | Company name of the GitHub user who created the pull request | +| closed | Whether the pull request is closed: `true` or `false` | +| is_draft | Whether the pull request is in draft: `true` or `false` | +| locked | Whether the pull request has been locked: `true` or `false` | +| merged | Whether the pull request has been merged | +| mergeable | Whether the pull request can be automatically merged: `MERGEABLE`, `CONFLICTING`, or `UNKNOWN` | +| closed_at | When the pull request was closed: YYYY-MM-DD HH:MM:SS | +| merged_at | When the pull request was merged: YYYY-MM-DD HH:MM:SS | +| merged_by_name | Name of the GitHub user who merged the pull request | +| merged_by_login | GitHub handle of the GitHub user who merged the pull request | +| merged_by_email | Email address of the GitHub user who merged the pull request | +| merged_by_company | Company name of the GitHub user who merged the pull request | +| updated_at | When the pull request was last updated: YYYY-MM-DD HH:MM:SS | +| created_at | When the pull request was created: YYYY-MM-DD HH:MM:SS | +| open_time | Duration in seconds the pull request has been open | +| labels | Array of labels assigned to the pull request, for example: `["bug", "priority/high"]` | ### Pull request files @@ -650,24 +672,24 @@ List all files changed in a specific pull request. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | -| Pull Request Number | The number of the pull request | Yes | +| Name | Description | Required | +| ------------------- | -------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | +| Pull Request Number | The number of the pull request | Yes | #### Response The response includes one row per changed file: -| Name | Description | -|------|-------------| -| path | Path of the changed file | -| additions | Number of lines added | -| deletions | Number of lines deleted | -| changes | Total number of line changes | -| status | Change type: `added`, `modified`, `renamed`, etc. | -| previous_filename | Original path for renamed files | +| Name | Description | +| ----------------- | ------------------------------------------------- | +| path | Path of the changed file | +| additions | Number of lines added | +| deletions | Number of lines deleted | +| changes | Total number of line changes | +| status | Change type: `added`, `modified`, `renamed`, etc. | +| previous_filename | Original path for renamed files | ### Pull requests for branches @@ -706,12 +728,12 @@ List reviews for pull requests in a repository. This query returns one row per r #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | A GitHub user or organization | Yes | -| Repository | The name of a repository | No | -| Query | Use GitHub's [query syntax](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests) to filter results | No | -| Time field | The time field to filter the responses on: `CreatedAt`, `ClosedAt`, `MergedAt`, `UpdatedAt`, or `None` | Yes | +| Name | Description | Required | +| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------- | +| Owner | A GitHub user or organization | Yes | +| Repository | The name of a repository | No | +| Query | Use GitHub's [query syntax](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests) to filter results | No | +| Time field | The time field to filter the responses on: `CreatedAt`, `ClosedAt`, `MergedAt`, `UpdatedAt`, or `None` | Yes | ##### Sample queries @@ -731,26 +753,26 @@ Show reviews for open pull requests (useful for tracking pending review workload #### Response -| Name | Description | -|------|-------------| -| pull_request_number | Pull request number | -| pull_request_title | Pull request title | -| pull_request_state | Pull request state: `OPEN`, `CLOSED`, or `MERGED` | -| pull_request_url | URL to the pull request | -| pull_request_author_name | Name of the pull request author | -| pull_request_author_login | GitHub handle of the pull request author | -| pull_request_author_email | Email of the pull request author | -| pull_request_author_company | Company of the pull request author | -| repository | Repository name with owner (for example, `grafana/grafana`) | -| review_author_name | Name of the reviewer | -| review_author_login | GitHub handle of the reviewer | -| review_author_email | Email of the reviewer | -| review_author_company | Company of the reviewer | -| review_url | URL to the review | -| review_state | Review state: `APPROVED`, `CHANGES_REQUESTED`, `COMMENTED`, `DISMISSED`, or `PENDING` | -| review_comment_count | Number of comments in the review | -| review_updated_at | When the review was last updated: YYYY-MM-DD HH:MM:SS | -| review_created_at | When the review was created: YYYY-MM-DD HH:MM:SS | +| Name | Description | +| --------------------------- | ------------------------------------------------------------------------------------- | +| pull_request_number | Pull request number | +| pull_request_title | Pull request title | +| pull_request_state | Pull request state: `OPEN`, `CLOSED`, or `MERGED` | +| pull_request_url | URL to the pull request | +| pull_request_author_name | Name of the pull request author | +| pull_request_author_login | GitHub handle of the pull request author | +| pull_request_author_email | Email of the pull request author | +| pull_request_author_company | Company of the pull request author | +| repository | Repository name with owner (for example, `grafana/grafana`) | +| review_author_name | Name of the reviewer | +| review_author_login | GitHub handle of the reviewer | +| review_author_email | Email of the reviewer | +| review_author_company | Company of the reviewer | +| review_url | URL to the review | +| review_state | Review state: `APPROVED`, `CHANGES_REQUESTED`, `COMMENTED`, `DISMISSED`, or `PENDING` | +| review_comment_count | Number of comments in the review | +| review_updated_at | When the review was last updated: YYYY-MM-DD HH:MM:SS | +| review_created_at | When the review was created: YYYY-MM-DD HH:MM:SS | ### Releases @@ -758,10 +780,10 @@ List created releases for a repository. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | +| Name | Description | Required | +| ---------- | -------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | ##### Sample queries @@ -772,16 +794,16 @@ Show all releases for the `grafana/grafana` repository: #### Response -| Name | Description | -|------|-------------| -| name | Name of release | -| created_by | Name of the GitHub user who created the release | -| is_draft | Whether the release is a draft release: `true` or `false` | -| is_prerelease | Whether the release is a pre-release: `true` or `false` | -| tag | Tag name associated with the release | -| url | URL for the tag associated with the release | -| created_at | When the release was created: YYYY-MM-DD HH:MM:SS | -| published_at | When the release was published: YYYY-MM-DD HH:MM:SS | +| Name | Description | +| ------------- | --------------------------------------------------------- | +| name | Name of release | +| created_by | Name of the GitHub user who created the release | +| is_draft | Whether the release is a draft release: `true` or `false` | +| is_prerelease | Whether the release is a pre-release: `true` or `false` | +| tag | Tag name associated with the release | +| url | URL for the tag associated with the release | +| created_at | When the release was created: YYYY-MM-DD HH:MM:SS | +| published_at | When the release was published: YYYY-MM-DD HH:MM:SS | ### Repositories @@ -793,10 +815,10 @@ This query returns a maximum of 1000 results. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | A GitHub user or organization | Yes | -| Repository | Filter on the name of the repository | No | +| Name | Description | Required | +| ---------- | ------------------------------------ | -------- | +| Owner | A GitHub user or organization | Yes | +| Repository | Filter on the name of the repository | No | ##### Sample queries @@ -806,17 +828,17 @@ Show all repositories for the `grafana` organization: #### Response -| Name | Description | -|------|-------------| -| name | Name of the repository | -| owner | Organization or user who owns the repository | +| Name | Description | +| --------------- | ------------------------------------------------------------------------------------------------------- | +| name | Name of the repository | +| owner | Organization or user who owns the repository | | name_with_owner | Returns the owner and repository name in the format `/`, for example: `grafana/loki` | -| url | URL for the repository | -| forks | The number of forks for a repository | -| is_fork | Whether the repository is a fork of another repository: `true` or `false` | -| is_mirror | Whether the repository is a mirror of another repository: `true` or `false` | -| is_private | Whether the repository is private: `true` or `false` | -| created_at | When the repository was created: YYYY-MM-DD HH:MM:SS | +| url | URL for the repository | +| forks | The number of forks for a repository | +| is_fork | Whether the repository is a fork of another repository: `true` or `false` | +| is_mirror | Whether the repository is a mirror of another repository: `true` or `false` | +| is_private | Whether the repository is private: `true` or `false` | +| created_at | When the repository was created: YYYY-MM-DD HH:MM:SS | ### Stargazers @@ -824,10 +846,10 @@ Get a list of users who have starred a repository, including the ability to plot #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | +| Name | Description | Required | +| ---------- | -------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | ##### Sample queries @@ -838,16 +860,16 @@ Show all stargazers for the `grafana/grafana` repository within the current time #### Response -| Name | Description | -|------|-------------| -| starred_at | When the user starred the repository: YYYY-MM-DD HH:MM:SS | -| star_count | Current total of stars for the repository at the time of the event | -| id | `node_id` -- a unique identifier for the GitHub user which can be used in GitHub's GraphQL API | -| login | GitHub handle of the user who starred the repository | -| git_name | Name of the GitHub user who starred the repository | -| company | Company name of the GitHub user who starred the repository | -| email | Email address of the GitHub user who starred the repository | -| url | URL to the GitHub profile for the user who starred the repository | +| Name | Description | +| ---------- | ---------------------------------------------------------------------------------------------- | +| starred_at | When the user starred the repository: YYYY-MM-DD HH:MM:SS | +| star_count | Current total of stars for the repository at the time of the event | +| id | `node_id` -- a unique identifier for the GitHub user which can be used in GitHub's GraphQL API | +| login | GitHub handle of the user who starred the repository | +| git_name | Name of the GitHub user who starred the repository | +| company | Company name of the GitHub user who starred the repository | +| email | Email address of the GitHub user who starred the repository | +| url | URL to the GitHub profile for the user who starred the repository | ### Branches @@ -855,11 +877,11 @@ List branches for a repository. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | -| Filter | Filter branches by name prefix (e.g. `release/` matches all `release/*` branches). Leave empty to list all branches. | No | +| Name | Description | Required | +| ---------- | -------------------------------------------------------------------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | +| Filter | Filter branches by name prefix (e.g. `release/` matches all `release/*` branches). Leave empty to list all branches. | No | ##### Sample queries @@ -876,13 +898,13 @@ Show only release branches: #### Response -| Name | Description | -|------|-------------| -| name | Name of the branch | -| commit_sha | SHA of the latest commit on the branch | -| author | Name of the user who authored the latest commit | -| author_login | GitHub handle of the commit author | -| commit_date | Date of the latest commit: YYYY-MM-DD HH:MM:SS | +| Name | Description | +| ------------ | ----------------------------------------------- | +| name | Name of the branch | +| commit_sha | SHA of the latest commit on the branch | +| author | Name of the user who authored the latest commit | +| author_login | GitHub handle of the commit author | +| commit_date | Date of the latest commit: YYYY-MM-DD HH:MM:SS | ### Tags @@ -890,10 +912,10 @@ List created tags for a repository. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | +| Name | Description | Required | +| ---------- | -------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | ##### Sample queries @@ -904,15 +926,15 @@ Show all tags created for the `grafana/grafana` repository within the currently #### Response -| Name | Description | -|------|-------------| -| name | Name of the tag | -| id | SHA for the tag | -| author | Name of the user who created the tag | -| author_login | GitHub handle of the user who created the tag | -| author_email | Email address of the user who created the tag | -| author_company | Company name of the user who created the tag | -| date | When the tag was created: YYYY-MM-DD HH:MM:SS | +| Name | Description | +| -------------- | --------------------------------------------- | +| name | Name of the tag | +| id | SHA for the tag | +| author | Name of the user who created the tag | +| author_login | GitHub handle of the user who created the tag | +| author_email | Email address of the user who created the tag | +| author_company | Company name of the user who created the tag | +| date | When the tag was created: YYYY-MM-DD HH:MM:SS | ### Vulnerabilities @@ -920,10 +942,10 @@ Query security vulnerabilities detected in a repository. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | The GitHub user or organization that owns the repository | Yes | -| Repository | The name of the repository | Yes | +| Name | Description | Required | +| ---------- | -------------------------------------------------------- | -------- | +| Owner | The GitHub user or organization that owns the repository | Yes | +| Repository | The name of the repository | Yes | ##### Sample queries @@ -934,22 +956,22 @@ Show all security advisories for the `grafana/grafana` repository: #### Response -| Name | Description | -|------|-------------| -| value | Custom field which allows for counting or aggregation, always returns `1` | -| created_at | When the vulnerability alert was created: YYYY-MM-DD HH:MM:SS | -| dismissed_at | When the vulnerability alert was dismissed, if applicable: YYYY-MM-DD HH:MM:SS | -| dismissReason | Reason the vulnerability alert was dismissed (for example, false positive, won't fix), if applicable | -| withdrawnAt | When the advisory was withdrawn, if applicable: YYYY-MM-DD HH:MM:SS | -| packageName | Name of the affected package | -| advisoryDescription | Description of the vulnerability or advisory | -| firstPatchedVersion | The first version of the package where the vulnerability is fixed | -| vulnerableVersionRange | The range of package versions affected by the vulnerability | -| cvssScore | CVSS (Common Vulnerability Scoring System) score for the vulnerability | -| cvssVector | CVSS vector string describing the scoring metrics | -| permalink | URL to the GitHub Security Advisory or alert | -| severity | Severity level: `LOW`, `MODERATE`, `HIGH`, or `CRITICAL` | -| state | State of the vulnerability alert: `OPEN`, `FIXED`, or `DISMISSED` | +| Name | Description | +| ---------------------- | ---------------------------------------------------------------------------------------------------- | +| value | Custom field which allows for counting or aggregation, always returns `1` | +| created_at | When the vulnerability alert was created: YYYY-MM-DD HH:MM:SS | +| dismissed_at | When the vulnerability alert was dismissed, if applicable: YYYY-MM-DD HH:MM:SS | +| dismissReason | Reason the vulnerability alert was dismissed (for example, false positive, won't fix), if applicable | +| withdrawnAt | When the advisory was withdrawn, if applicable: YYYY-MM-DD HH:MM:SS | +| packageName | Name of the affected package | +| advisoryDescription | Description of the vulnerability or advisory | +| firstPatchedVersion | The first version of the package where the vulnerability is fixed | +| vulnerableVersionRange | The range of package versions affected by the vulnerability | +| cvssScore | CVSS (Common Vulnerability Scoring System) score for the vulnerability | +| cvssVector | CVSS vector string describing the scoring metrics | +| permalink | URL to the GitHub Security Advisory or alert | +| severity | Severity level: `LOW`, `MODERATE`, `HIGH`, or `CRITICAL` | +| state | State of the vulnerability alert: `OPEN`, `FIXED`, or `DISMISSED` | ### Webhook deliveries @@ -1009,11 +1031,11 @@ List GitHub Actions workflows defined in a repository. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | GitHub user or organization that owns the repository | Yes | -| Repository | Name of the repository | Yes | -| Time field | The time field to filter the responses on: `None` (returns all workflows), `CreatedAt`, or `UpdatedAt` | Yes | +| Name | Description | Required | +| ---------- | ------------------------------------------------------------------------------------------------------ | -------- | +| Owner | GitHub user or organization that owns the repository | Yes | +| Repository | Name of the repository | Yes | +| Time field | The time field to filter the responses on: `None` (returns all workflows), `CreatedAt`, or `UpdatedAt` | Yes | ##### Sample queries @@ -1031,17 +1053,17 @@ Show all workflows created within the `grafana/grafana` repository within the cu #### Response -| Name | Description | -|------|-------------| -| id | Unique identifier for the workflow | -| name | Name of the workflow | -| path | Path to the workflow YAML file in the repository | -| state | State of the workflow: `active`, `deleted`, `disabled_fork`, `disabled_inactivity`, or `disabled_manually` | -| created_at | When the workflow was created: YYYY-MM-DD HH:MM:SS | -| updated_at | When the workflow was last updated: YYYY-MM-DD HH:MM:SS | -| url | API URL for the workflow | -| html_url | URL to the workflow file in the repository | -| badge_url | URL to the workflow status badge | +| Name | Description | +| ---------- | ---------------------------------------------------------------------------------------------------------- | +| id | Unique identifier for the workflow | +| name | Name of the workflow | +| path | Path to the workflow YAML file in the repository | +| state | State of the workflow: `active`, `deleted`, `disabled_fork`, `disabled_inactivity`, or `disabled_manually` | +| created_at | When the workflow was created: YYYY-MM-DD HH:MM:SS | +| updated_at | When the workflow was last updated: YYYY-MM-DD HH:MM:SS | +| url | API URL for the workflow | +| html_url | URL to the workflow file in the repository | +| badge_url | URL to the workflow status badge | ### Workflow runs @@ -1049,12 +1071,12 @@ List runs for a specific workflow, including status, conclusion, and timing info #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | GitHub user or organization that owns the repository | Yes | -| Repository | Name of the repository | Yes | -| Workflow | The workflow ID or file name. Use `id` or the filename from `path` from [Workflows](#workflows) queries. | Yes | -| Branch | The head branch to filter on | No | +| Name | Description | Required | +| ---------- | -------------------------------------------------------------------------------------------------------- | -------- | +| Owner | GitHub user or organization that owns the repository | Yes | +| Repository | Name of the repository | Yes | +| Workflow | The workflow ID or file name. Use `id` or the filename from `path` from [Workflows](#workflows) queries. | Yes | +| Branch | The head branch to filter on | No | ##### Sample queries @@ -1073,22 +1095,22 @@ Show workflow runs for a specific branch (useful for monitoring release branch C #### Response -| Name | Description | -|------|-------------| -| id | Unique identifier for the workflow run | -| name | Name of the workflow or workflow job | -| head_branch | Name of the branch the workflow run was triggered on | -| head_sha | Commit SHA that triggered the workflow run | -| created_at | When the workflow run was created: YYYY-MM-DD HH:MM:SS | -| updated_at | When the workflow run was last updated: YYYY-MM-DD HH:MM:SS | -| run_started_at | When the workflow run started executing: YYYY-MM-DD HH:MM:SS | -| html_url | URL to the workflow run in the GitHub web UI | -| url | API URL for the workflow run | -| status | Current status: `queued`, `in_progress`, `completed`, `waiting`, `requested`, or `pending` | -| conclusion | Final conclusion: `success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, or `action_required` | -| event | Event that triggered the workflow run (for example, `push` or `pull_request`). Refer to [Events that trigger workflows](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows). | -| workflow_id | Unique identifier for the workflow definition | -| run_number | The run number for this workflow run in the repository | +| Name | Description | +| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| id | Unique identifier for the workflow run | +| name | Name of the workflow or workflow job | +| head_branch | Name of the branch the workflow run was triggered on | +| head_sha | Commit SHA that triggered the workflow run | +| created_at | When the workflow run was created: YYYY-MM-DD HH:MM:SS | +| updated_at | When the workflow run was last updated: YYYY-MM-DD HH:MM:SS | +| run_started_at | When the workflow run started executing: YYYY-MM-DD HH:MM:SS | +| html_url | URL to the workflow run in the GitHub web UI | +| url | API URL for the workflow run | +| status | Current status: `queued`, `in_progress`, `completed`, `waiting`, `requested`, or `pending` | +| conclusion | Final conclusion: `success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, or `action_required` | +| event | Event that triggered the workflow run (for example, `push` or `pull_request`). Refer to [Events that trigger workflows](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows). | +| workflow_id | Unique identifier for the workflow definition | +| run_number | The run number for this workflow run in the repository | ### Workflow usage @@ -1096,11 +1118,11 @@ Retrieve usage statistics for a workflow, such as run counts and durations. #### Query options -| Name | Description | Required | -|------|-------------|----------| -| Owner | GitHub user or organization that owns the repository | Yes | -| Repository | Name of the repository | Yes | -| Workflow | The workflow ID or file name. Use `id` or the filename from `path` from [Workflows](#workflows) queries. | Yes | +| Name | Description | Required | +| ---------- | -------------------------------------------------------------------------------------------------------- | -------- | +| Owner | GitHub user or organization that owns the repository | Yes | +| Repository | Name of the repository | Yes | +| Workflow | The workflow ID or file name. Use `id` or the filename from `path` from [Workflows](#workflows) queries. | Yes | ##### Sample queries @@ -1112,24 +1134,24 @@ Show usage statistics for the `Levitate` detect breaking changes workflow in the #### Response -| Name | Description | -|------|-------------| -| name | Name of the workflow (or workflow job) | -| unique triggering actors | Number of unique users or actors who triggered runs of this workflow | -| runs | Total number of workflow runs in the selected period | -| current billing cycle cost (approx.) | Approximate cost for the current billing cycle (if applicable) | -| skipped | Number (and percentage) of runs that were skipped | -| successes | Number (and percentage) of successful runs | -| failures | Number (and percentage) of failed runs | -| cancelled | Number (and percentage) of cancelled runs | -| total run duration (approx.) | Total duration of all runs (formatted as hours, minutes, seconds) | -| longest run duration (approx.) | Duration of the longest single run | -| average run duration (approx.) | Average duration of all runs | -| p95 run duration (approx.) | 95th percentile run duration | -| runs on Sunday | Number of runs started on Sunday | -| runs on Monday | Number of runs started on Monday | -| runs on Tuesday | Number of runs started on Tuesday | -| runs on Wednesday | Number of runs started on Wednesday | -| runs on Thursday | Number of runs started on Thursday | -| runs on Friday | Number of runs started on Friday | -| runs on Saturday | Number of runs started on Saturday | +| Name | Description | +| ------------------------------------ | -------------------------------------------------------------------- | +| name | Name of the workflow (or workflow job) | +| unique triggering actors | Number of unique users or actors who triggered runs of this workflow | +| runs | Total number of workflow runs in the selected period | +| current billing cycle cost (approx.) | Approximate cost for the current billing cycle (if applicable) | +| skipped | Number (and percentage) of runs that were skipped | +| successes | Number (and percentage) of successful runs | +| failures | Number (and percentage) of failed runs | +| cancelled | Number (and percentage) of cancelled runs | +| total run duration (approx.) | Total duration of all runs (formatted as hours, minutes, seconds) | +| longest run duration (approx.) | Duration of the longest single run | +| average run duration (approx.) | Average duration of all runs | +| p95 run duration (approx.) | 95th percentile run duration | +| runs on Sunday | Number of runs started on Sunday | +| runs on Monday | Number of runs started on Monday | +| runs on Tuesday | Number of runs started on Tuesday | +| runs on Wednesday | Number of runs started on Wednesday | +| runs on Thursday | Number of runs started on Thursday | +| runs on Friday | Number of runs started on Friday | +| runs on Saturday | Number of runs started on Saturday | diff --git a/pkg/github/datasource.go b/pkg/github/datasource.go index 32329a68..403cbfe0 100644 --- a/pkg/github/datasource.go +++ b/pkg/github/datasource.go @@ -291,6 +291,15 @@ func (d *Datasource) HandleOrganizationsQuery(ctx context.Context, query *models return Organizations(orgs), nil } +// HandleTeamMembersQuery lists members of the requested organization team. +func (d *Datasource) HandleTeamMembersQuery(ctx context.Context, query *models.TeamMembersQuery, req backend.DataQuery) (dfutil.Framer, error) { + members, err := GetAllTeamMembers(ctx, d.client, query.Owner, query.Options.TeamSlug) + if err != nil { + return nil, err + } + return TeamMembers(members), nil +} + // CheckHealth is the health check for GitHub func (d *Datasource) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) { _, err := GetAllRepositories(ctx, d.client, models.ListRepositoriesOptions{ diff --git a/pkg/github/query_handler.go b/pkg/github/query_handler.go index fa2728b6..f33eb4fc 100644 --- a/pkg/github/query_handler.go +++ b/pkg/github/query_handler.go @@ -67,6 +67,7 @@ func GetQueryHandlers(s *QueryHandler) *datasource.QueryTypeMux { register(models.QueryTypeCodeScanning, s.HandleCodeScanning) register(models.QueryTypeDeployments, s.HandleDeployments) register(models.QueryTypeOrganizations, s.HandleOrganizations) + register(models.QueryTypeTeamMembers, s.HandleTeamMembers) register(models.QueryTypeCommitFiles, s.HandleCommitFiles) register(models.QueryTypePullRequestFiles, s.HandlePullRequestFiles) register(models.QueryTypeCheckRuns, s.HandleCheckRuns) diff --git a/pkg/github/team_members.go b/pkg/github/team_members.go new file mode 100644 index 00000000..7092a187 --- /dev/null +++ b/pkg/github/team_members.go @@ -0,0 +1,65 @@ +package github + +import ( + "context" + + "github.com/grafana/github-datasource/pkg/models" + "github.com/grafana/grafana-plugin-sdk-go/data" + "github.com/shurcooL/githubv4" +) + +// TeamMember is a member of a GitHub organization team. +type TeamMember struct { + Login string + Name string + URL string `graphql:"url"` +} + +// TeamMembers is a list of members from a GitHub organization team. +type TeamMembers []TeamMember + +// Frames converts the team members to a Grafana data frame. +func (members TeamMembers) Frames() data.Frames { + frame := data.NewFrame("team_members", + data.NewField("login", nil, []string{}), + data.NewField("name", nil, []string{}), + data.NewField("url", nil, []string{}), + ) + for _, member := range members { + frame.AppendRow(member.Login, member.Name, member.URL) + } + return data.Frames{frame} +} + +type QueryListTeamMembers struct { + Organization struct { + Team struct { + Members struct { + Nodes []TeamMember + PageInfo models.PageInfo + } `graphql:"members(first: 100, after: $cursor)"` + } `graphql:"team(slug: $teamSlug)"` + } `graphql:"organization(login: $organization)"` +} + +// GetAllTeamMembers retrieves every visible member of an organization team. +func GetAllTeamMembers(ctx context.Context, client models.Client, organization, teamSlug string) (TeamMembers, error) { + members := TeamMembers{} + variables := map[string]interface{}{ + "organization": githubv4.String(organization), + "teamSlug": githubv4.String(teamSlug), + "cursor": (*githubv4.String)(nil), + } + for { + q := &QueryListTeamMembers{} + if err := client.Query(ctx, q, variables); err != nil { + return nil, err + } + members = append(members, q.Organization.Team.Members.Nodes...) + if !q.Organization.Team.Members.PageInfo.HasNextPage { + break + } + variables["cursor"] = q.Organization.Team.Members.PageInfo.EndCursor + } + return members, nil +} diff --git a/pkg/github/team_members_handler.go b/pkg/github/team_members_handler.go new file mode 100644 index 00000000..5316b3d1 --- /dev/null +++ b/pkg/github/team_members_handler.go @@ -0,0 +1,22 @@ +package github + +import ( + "context" + + "github.com/grafana/github-datasource/pkg/dfutil" + "github.com/grafana/github-datasource/pkg/models" + "github.com/grafana/grafana-plugin-sdk-go/backend" +) + +func (s *QueryHandler) handleTeamMembersQuery(ctx context.Context, q backend.DataQuery) backend.DataResponse { + query := &models.TeamMembersQuery{} + if err := UnmarshalQuery(q.JSON, query); err != nil { + return *err + } + return dfutil.FrameResponseWithError(s.Datasource.HandleTeamMembersQuery(ctx, query, q)) +} + +// HandleTeamMembers handles queries for GitHub organization team members. +func (s *QueryHandler) HandleTeamMembers(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) { + return &backend.QueryDataResponse{Responses: processQueries(ctx, req, s.handleTeamMembersQuery)}, nil +} diff --git a/pkg/github/team_members_test.go b/pkg/github/team_members_test.go new file mode 100644 index 00000000..0e335fdf --- /dev/null +++ b/pkg/github/team_members_test.go @@ -0,0 +1,25 @@ +package github + +import ( + "testing" +) + +func TestTeamMembersFrames(t *testing.T) { + frames := TeamMembers{{Login: "octocat", Name: "The Octocat", URL: "https://github.com/octocat"}}.Frames() + if len(frames) != 1 { + t.Fatalf("expected one frame, got %d", len(frames)) + } + frame := frames[0] + if frame.Name != "team_members" { + t.Errorf("unexpected frame name %q", frame.Name) + } + if got := frame.Fields[0].At(0); got != "octocat" { + t.Errorf("unexpected login %v", got) + } + if got := frame.Fields[1].At(0); got != "The Octocat" { + t.Errorf("unexpected name %v", got) + } + if got := frame.Fields[2].At(0); got != "https://github.com/octocat" { + t.Errorf("unexpected URL %v", got) + } +} diff --git a/pkg/models/query.go b/pkg/models/query.go index ecaf9d6f..74ec4df4 100644 --- a/pkg/models/query.go +++ b/pkg/models/query.go @@ -25,6 +25,8 @@ const ( QueryTypeRepositories QueryType = "Repositories" // QueryTypeOrganizations is used when querying for GitHub organizations QueryTypeOrganizations QueryType = "Organizations" + // QueryTypeTeamMembers is used when querying organization team members + QueryTypeTeamMembers QueryType = "Team_Members" // QueryTypeGraphQL is used when sending an ad-hoc graphql query QueryTypeGraphQL QueryType = "GraphQL" // QueryTypePackages is used when querying for NPM / Docker / etc packages @@ -182,6 +184,14 @@ type DeploymentsQuery struct { type OrganizationsQuery struct { } +// TeamMembersQuery is used when querying members of a GitHub organization team. +type TeamMembersQuery struct { + Query + Options struct { + TeamSlug string `json:"teamSlug"` + } `json:"options"` +} + // CommitFilesQuery is used when querying for files changed in a GitHub commit type CommitFilesQuery struct { Query diff --git a/pkg/plugin/datasource.go b/pkg/plugin/datasource.go index 433b3c97..d5320b56 100644 --- a/pkg/plugin/datasource.go +++ b/pkg/plugin/datasource.go @@ -34,6 +34,7 @@ type Datasource interface { HandleWorkflowRunsQuery(context.Context, *models.WorkflowRunsQuery, backend.DataQuery) (dfutil.Framer, error) HandleDeploymentsQuery(context.Context, *models.DeploymentsQuery, backend.DataQuery) (dfutil.Framer, error) HandleOrganizationsQuery(context.Context, *models.OrganizationsQuery, backend.DataQuery) (dfutil.Framer, error) + HandleTeamMembersQuery(context.Context, *models.TeamMembersQuery, backend.DataQuery) (dfutil.Framer, error) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) } diff --git a/pkg/plugin/datasource_caching.go b/pkg/plugin/datasource_caching.go index 0d826bc2..ba753821 100644 --- a/pkg/plugin/datasource_caching.go +++ b/pkg/plugin/datasource_caching.go @@ -292,6 +292,16 @@ func (c *CachedDatasource) HandleOrganizationsQuery(ctx context.Context, q *mode return c.saveCache(req, f, err) } +// HandleTeamMembersQuery is the cache wrapper for team-member queries. +func (c *CachedDatasource) HandleTeamMembersQuery(ctx context.Context, q *models.TeamMembersQuery, req backend.DataQuery) (dfutil.Framer, error) { + if value, err := c.getCache(req); err == nil { + return value, err + } + + f, err := c.datasource.HandleTeamMembersQuery(ctx, q, req) + return c.saveCache(req, f, err) +} + // HandleCommitFilesQuery is the cache wrapper for the commit files query handler func (c *CachedDatasource) HandleCommitFilesQuery(ctx context.Context, q *models.CommitFilesQuery, req backend.DataQuery) (dfutil.Framer, error) { if value, err := c.getCache(req); err == nil { diff --git a/src/constants.ts b/src/constants.ts index 19ecb368..ce646363 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,4 +1,4 @@ -import { QueryType } from './types/query' +import { QueryType } from './types/query'; export const QueryTypes = [ 'Check_Runs', @@ -17,6 +17,7 @@ export const QueryTypes = [ 'Labels', 'Repositories', 'Organizations', + 'Team_Members', 'GraphQL', 'Milestones', 'Packages', @@ -31,8 +32,7 @@ export const QueryTypes = [ 'Webhook_Deliveries', ] as const; - -export const DefaultQueryType: QueryType = "Issues"; +export const DefaultQueryType: QueryType = 'Issues'; export enum PackageType { NPM = 'NPM', diff --git a/src/types/query.ts b/src/types/query.ts index 16998b28..9437a097 100644 --- a/src/types/query.ts +++ b/src/types/query.ts @@ -109,6 +109,11 @@ type RepositoriesQuery = BaseQuery<'Repositories', {}> type OrganizationsQuery = BaseQuery<'Organizations', {}> //#endregion +//#region Team_Members Query +export type TeamMembersOptions = Options & { teamSlug?: string }; +type Team_MembersQuery = BaseQuery<'Team_Members', TeamMembersOptions>; +//#endregion + //#region GraphQL Query type GraphQLQuery = BaseQuery<'GraphQL', {}> //#endregion @@ -219,6 +224,7 @@ export type GitHubQuery = LabelsQuery | RepositoriesQuery | OrganizationsQuery | + Team_MembersQuery | GraphQLQuery | MilestonesQuery | PackagesQuery | diff --git a/src/validation.ts b/src/validation.ts index 1c32149c..c5e5f3c4 100644 --- a/src/validation.ts +++ b/src/validation.ts @@ -8,6 +8,9 @@ export const isValid = (query: GitHubQuery): boolean => { return false; } } + if (query.queryType === "Team_Members" && (isEmpty(query.owner) || isEmpty(query.options?.teamSlug))) { + return false; + } if ( query.queryType === "Commits" || query.queryType === 'Commit_Files' || diff --git a/src/views/QueryEditor.tsx b/src/views/QueryEditor.tsx index d7bb80cc..74f3fdd9 100644 --- a/src/views/QueryEditor.tsx +++ b/src/views/QueryEditor.tsx @@ -28,6 +28,7 @@ import { QueryEditorCheckRuns } from './QueryEditorCheckRuns'; import { QueryEditorDeployments } from './QueryEditorDeployments'; import { QueryEditorBranches } from './QueryEditorBranches'; import { QueryEditorWebhookDeliveries } from './QueryEditorWebhookDeliveries'; +import { QueryEditorTeamMembers } from './QueryEditorTeamMembers'; import { DefaultQueryType, QueryTypes } from '../constants'; @@ -44,6 +45,11 @@ const queryEditors: Record <> }, ['GraphQL']: { component: () => <> }, ['Organizations']: { component: () => <> }, + ['Team_Members']: { + component: (props: Props, onChange: (val: any) => void) => ( + + ), + }, ['ProjectItems']: { component: () => <> }, ['Tags']: { component: () => <> }, ['Branches']: { @@ -205,7 +211,7 @@ const QueryEditor = (props: Props) => { /> - {hasRepo(props.query.queryType) && ( + {hasOwner(props.query.queryType) && ( { @@ -238,7 +244,12 @@ const QueryEditor = (props: Props) => { ); }; -const nonRepoTypes = ['Projects', 'ProjectItems']; +const nonRepoTypes = ['Projects', 'ProjectItems', 'Team_Members']; +const nonOwnerTypes = ['Projects', 'ProjectItems']; + +function hasOwner(qt?: string) { + return !nonOwnerTypes.includes(qt as QueryType); +} function hasRepo(qt?: string) { return !nonRepoTypes.includes(qt as QueryType); diff --git a/src/views/QueryEditorTeamMembers.tsx b/src/views/QueryEditorTeamMembers.tsx new file mode 100644 index 00000000..5c9654c5 --- /dev/null +++ b/src/views/QueryEditorTeamMembers.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import { Input } from '@grafana/ui'; +import { EditorField, EditorRow } from '@grafana/plugin-ui'; +import type { TeamMembersOptions } from '../types/query'; +import { LeftColumnWidth, RightColumnWidth } from './QueryEditor'; + +interface Props extends TeamMembersOptions { + onChange: (value: TeamMembersOptions) => void; +} + +export const QueryEditorTeamMembers = ({ teamSlug = '', onChange }: Props) => ( + + + onChange({ teamSlug: event.currentTarget.value })} + onBlur={(event) => onChange({ teamSlug: event.currentTarget.value.trim() })} + width={RightColumnWidth} + /> + + +);