Skip to content

Commit 4982411

Browse files
Merge pull request #2393 from buildkite/graphql-cookbooks
Split up GraphQL cookbooks
2 parents 0dfa323 + 5273a2d commit 4982411

File tree

15 files changed

+1413
-1313
lines changed

15 files changed

+1413
-1313
lines changed

data/nav_graphql.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,23 @@
44
- name: Console and CLI tutorial
55
path: apis/graphql/graphql-tutorial
66
- name: Cookbook
7-
path: apis/graphql/graphql-cookbook
7+
children:
8+
- name: Overview
9+
path: apis/graphql/graphql-cookbook
10+
- name: Pipelines
11+
path: apis/graphql/cookbooks/pipelines
12+
- name: Builds
13+
path: apis/graphql/cookbooks/builds
14+
- name: Jobs
15+
path: apis/graphql/cookbooks/jobs
16+
- name: Agents
17+
path: apis/graphql/cookbooks/agents
18+
- name: Clusters
19+
path: apis/graphql/cookbooks/clusters
20+
- name: Organizations
21+
path: apis/graphql/cookbooks/organizations
22+
- name: Teams
23+
path: apis/graphql/cookbooks/teams
824
- name: Limits
925
path: apis/graphql/graphql-resource-limits
1026
- name: Queries

pages/apis/api_differences.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@ On this page, we've collected the known limitation where some API features are o
2020

2121
## Features only available in the GraphQL API
2222

23-
* <%= pill "AGENTS", "agents" %> [Get a list of agent token IDs (agent tokens are currently only available via GraphQL)](/docs/apis/graphql/graphql-cookbook#agents-get-a-list-of-agent-token-ids).
24-
* <%= pill "BUILDS", "builds" %> [Get all environment variables set on a build](/docs/apis/graphql/graphql-cookbook#builds-get-all-environment-variables-set-on-a-build).
25-
* <%= pill "BUILDS", "builds" %> [Increase the next build number](/docs/apis/graphql/graphql-cookbook#builds-increase-the-next-build-number).
26-
* <%= pill "BUILDS", "builds" %> [Get build info by ID] (/docs/apis/graphql/graphql-cookbook#builds-get-build-info-by-id).
27-
* <%= pill "JOBS", "jobs" %> [Get all jobs in a given queue for a given timeframe](/docs/apis/graphql/graphql-cookbook#jobs-get-all-jobs-in-a-given-queue-for-a-given-timeframe).
28-
* <%= pill "JOBS", "jobs" %> [Get all jobs in a particular concurrency group](/docs/apis/graphql/graphql-cookbook#jobs-get-all-jobs-in-a-particular-concurrency-group).
23+
* <%= pill "AGENTS", "agents" %> [Get a list of agent token IDs (agent tokens are currently only available via GraphQL)](/docs/apis/graphql/cookbooks/agents#get-a-list-of-agent-token-ids).
24+
* <%= pill "BUILDS", "builds" %> [Get all environment variables set on a build](/docs/apis/graphql/cookbooks/builds#get-all-environment-variables-set-on-a-build).
25+
* <%= pill "BUILDS", "builds" %> [Increase the next build number](/docs/apis/graphql/cookbooks/builds#increase-the-next-build-number).
26+
* <%= pill "BUILDS", "builds" %> [Get build info by ID] (/docs/apis/graphql/cookbooks/builds#get-build-info-by-id).
27+
* <%= pill "JOBS", "jobs" %> [Get all jobs in a given queue for a given timeframe](/docs/apis/graphql/cookbooks/jobs#get-all-jobs-in-a-given-queue-for-a-given-timeframe).
28+
* <%= pill "JOBS", "jobs" %> [Get all jobs in a particular concurrency group](/docs/apis/graphql/cookbooks/jobs#get-all-jobs-in-a-particular-concurrency-group).
2929
* <%= pill "JOBS", "jobs" %> list job events.
3030
* <%= pill "JOBS", "jobs" %> [Cancel a job](/docs/apis/graphql/schemas/mutation/jobtypecommandcancel).
31-
* <%= pill "ORGANIZATIONS", "organizations" %> [Remove users from an organization](/docs/apis/graphql/graphql-cookbook#organizations-delete-an-organization-member).
32-
* <%= pill "ORGANIZATIONS", "organizations" %> Manage teams - [add](/docs/apis/graphql/graphql-cookbook#teams-add-an-existing-organization-user-to-a-team) or [remove](/docs/apis/graphql/graphql-cookbook#teams-remove-a-team-member) a team member. Most of the team management features are only available for GraphQL. The REST API can only list teams and can create pipelines in teams.
31+
* <%= pill "ORGANIZATIONS", "organizations" %> [Remove users from an organization](/docs/apis/graphql/cookbooks/organizations#delete-an-organization-member).
32+
* <%= pill "ORGANIZATIONS", "organizations" %> Manage teams - [add](/docs/apis/graphql/cookbooks/teams#add-an-existing-organization-user-to-a-team) or [remove](/docs/apis/graphql/cookbooks/teams#remove-a-team-member) a team member. Most of the team management features are only available for GraphQL. The REST API can only list teams and can create pipelines in teams.
3333
* <%= pill "ORGANIZATIONS", "organizations" %> [Set up SSO](/docs/integrations/sso/sso-setup-with-graphql).
34-
* <%= pill "ORGANIZATIONS", "organizations" %> [Remove pipeline edit access from existing teams](/docs/apis/graphql/graphql-cookbook#teams-set-teams-pipeline-edit-access-to-read-only-or-build-and-read).
35-
* <%= pill "PIPELINES", "pipelines" %> [Get all the pipeline metrics from the dashboard from the API](/docs/apis/graphql/graphql-cookbook#pipelines-get-pipeline-metrics).
36-
* <%= pill "PIPELINES", "pipelines" %> [Get the last build's creation date within every pipeline](/docs/apis/graphql/graphql-cookbook#builds-get-the-creation-date-of-the-most-recent-build-in-every-pipeline).
37-
* <%= pill "PIPELINES", "pipelines" %> [Count the number of builds on a branch](/docs/apis/graphql/graphql-cookbook#builds-count-the-number-of-builds-on-a-branch).
38-
* <%= pill "PIPELINES", "pipelines" %> [Get the creation date of the most recent build in every pipeline](/docs/apis/graphql/graphql-cookbook#builds-get-the-creation-date-of-the-most-recent-build-in-every-pipeline).
34+
* <%= pill "ORGANIZATIONS", "organizations" %> [Remove pipeline edit access from existing teams](/docs/apis/graphql/cookbooks/teams#set-teams-pipeline-edit-access-to-read-only-or-build-and-read).
35+
* <%= pill "PIPELINES", "pipelines" %> [Get all the pipeline metrics from the dashboard from the API](/docs/apis/graphql/cookbooks/pipelines#get-pipeline-metrics).
36+
* <%= pill "PIPELINES", "pipelines" %> [Get the last build's creation date within every pipeline](/docs/apis/graphql/cookbooks/builds#get-the-creation-date-of-the-most-recent-build-in-every-pipeline).
37+
* <%= pill "PIPELINES", "pipelines" %> [Count the number of builds on a branch](/docs/apis/graphql/cookbooks/builds#count-the-number-of-builds-on-a-branch).
38+
* <%= pill "PIPELINES", "pipelines" %> [Get the creation date of the most recent build in every pipeline](/docs/apis/graphql/cookbooks/builds#get-the-creation-date-of-the-most-recent-build-in-every-pipeline).
3939
* <%= pill "PIPELINES", "pipelines" %> Filter results from pipeline listings.
4040
* <%= pill "PIPELINES", "pipelines" %> Create and manage pipeline schedules.
41-
* <%= pill "USERS", "users" %> [Invite a user into a specific team with a specific role and permissions set](/docs/apis/graphql/graphql-cookbook#organizations-create-a-user-add-them-to-a-team-and-set-user-permissions).
41+
* <%= pill "USERS", "users" %> [Invite a user into a specific team with a specific role and permissions set](/docs/apis/graphql/cookbooks/organizations#create-a-user-add-them-to-a-team-and-set-user-permissions).
4242

4343
## Known missing API features
4444

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Agents
2+
3+
A collection of common tasks with agents using the GraphQL API.
4+
5+
You can test out the Buildkite GraphQL API using the [Buildkite explorer](https://graphql.buildkite.com/explorer). This includes built-in documentation under the _Docs_ panel.
6+
7+
## Get a list of agent token IDs
8+
9+
Get the first five agent token IDs for an organization.
10+
11+
```graphql
12+
query token {
13+
organization(slug: "organization-slug") {
14+
id
15+
name
16+
agentTokens(first: 5) {
17+
edges {
18+
node {
19+
id
20+
description
21+
}
22+
}
23+
}
24+
}
25+
}
26+
```
27+
28+
## Search for agents in an organization
29+
30+
```graphql
31+
query SearchAgent {
32+
organization(slug:"organization-slug") {
33+
agents(first:500, search:"search-string") {
34+
edges {
35+
node {
36+
name
37+
hostname
38+
version
39+
}
40+
}
41+
}
42+
}
43+
}
44+
```
45+
46+
## Revoke an agent token
47+
48+
Revoking an agent token means no new agents can start using the token. It does not affect any connected agents.
49+
50+
First, get the token ID. You can find it in the Buildkite dashboard, in _Agents_ > _Reveal Agent Token_, or you can retrieve a list of agent token IDs using this query:
51+
52+
```graphql
53+
query GetAgentTokenID {
54+
organization(slug: "organization-slug") {
55+
agentTokens(first:50) {
56+
edges {
57+
node {
58+
id
59+
uuid
60+
description
61+
}
62+
}
63+
}
64+
}
65+
}
66+
```
67+
68+
Then, using the token ID, revoke the agent token:
69+
70+
```graphql
71+
mutation {
72+
agentTokenRevoke(input: {
73+
id: "token-id",
74+
reason: "A reason"
75+
}) {
76+
agentToken {
77+
description
78+
revokedAt
79+
revokedReason
80+
}
81+
}
82+
}
83+
```

0 commit comments

Comments
 (0)