-
Notifications
You must be signed in to change notification settings - Fork 338
Expand file tree
/
Copy pathpings.go
More file actions
33 lines (27 loc) · 1.13 KB
/
pings.go
File metadata and controls
33 lines (27 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package api
import "context"
// Ping represents a Buildkite Agent API Ping
type Ping struct {
Action string `json:"action,omitempty"`
Message string `json:"message,omitempty"`
Job *Job `json:"job,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
RequestHeaders map[string]string `json:"request_headers,omitzero"` // omit nil, keep empty map
ArtifactCreateBatchSize int `json:"artifact_create_batch_size,omitempty"`
ArtifactUpdateBatchSizeMax int `json:"artifact_update_batch_size_max,omitempty"`
}
// Pings the API and returns any work the client needs to perform
func (c *Client) Ping(ctx context.Context) (*Ping, *Response, error) {
req, err := c.newRequest(ctx, "GET", "ping", nil)
if err != nil {
return nil, nil, err
}
ping := new(Ping)
resp, err := c.doRequest(req, ping)
if err != nil {
return nil, resp, err
}
// If Buildkite told us to use Buildkite-* request headers, store those
c.setRequestHeaders(ping.RequestHeaders)
return ping, resp, err
}