-
Notifications
You must be signed in to change notification settings - Fork 59
/
packages.go
39 lines (32 loc) · 1.13 KB
/
packages.go
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
34
35
36
37
38
39
package buildkite
import (
"context"
"fmt"
)
const fileFormKey = "file"
// PackagesService handles communication with packages Buildkite API endpoints
type PackagesService struct {
client *Client
}
// Package represents a package which has been stored in a registry
type Package struct {
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
WebURL string `json:"web_url"`
Organization Organization `json:"organization"`
Registry PackageRegistry `json:"registry"`
}
func (ps *PackagesService) Get(ctx context.Context, organizationSlug, registrySlug, packageID string) (Package, *Response, error) {
url := fmt.Sprintf("v2/packages/organizations/%s/registries/%s/packages/%s", organizationSlug, registrySlug, packageID)
req, err := ps.client.NewRequest(ctx, "GET", url, nil)
if err != nil {
return Package{}, nil, fmt.Errorf("creating GET package request: %v", err)
}
var p Package
resp, err := ps.client.Do(req, &p)
if err != nil {
return Package{}, resp, fmt.Errorf("executing GET package request: %v", err)
}
return p, resp, err
}