-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartifacts.go
More file actions
33 lines (28 loc) · 1006 Bytes
/
Copy pathartifacts.go
File metadata and controls
33 lines (28 loc) · 1006 Bytes
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 cursor
import (
"context"
"net/http"
"net/url"
)
// ListArtifactsResponse is returned by GET /v1/agents/{id}/artifacts.
type ListArtifactsResponse struct {
Items []Artifact `json:"items"`
}
// ListArtifacts lists files produced by an agent.
func (c *Client) ListArtifacts(ctx context.Context, agentID string) ([]Artifact, error) {
var response ListArtifactsResponse
if err := c.doJSON(ctx, http.MethodGet, "/v1/agents/"+url.PathEscape(agentID)+"/artifacts", nil, nil, &response); err != nil {
return nil, err
}
return response.Items, nil
}
// DownloadArtifact retrieves a temporary presigned URL for an artifact.
func (c *Client) DownloadArtifact(ctx context.Context, agentID, path string) (*ArtifactDownload, error) {
query := url.Values{}
query.Set("path", path)
var response ArtifactDownload
if err := c.doJSON(ctx, http.MethodGet, "/v1/agents/"+url.PathEscape(agentID)+"/artifacts/download", query, nil, &response); err != nil {
return nil, err
}
return &response, nil
}