forked from google/go-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepos_properties.go
60 lines (49 loc) · 1.79 KB
/
repos_properties.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2023 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import (
"context"
"fmt"
)
// GetAllCustomPropertyValues gets all custom property values that are set for a repository.
//
// GitHub API docs: https://docs.github.com/rest/repos/custom-properties#get-all-custom-property-values-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/properties/values
func (s *RepositoriesService) GetAllCustomPropertyValues(ctx context.Context, org, repo string) ([]*CustomPropertyValue, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/properties/values", org, repo)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var customPropertyValues []*CustomPropertyValue
resp, err := s.client.Do(ctx, req, &customPropertyValues)
if err != nil {
return nil, resp, err
}
return customPropertyValues, resp, nil
}
// CreateOrUpdateCustomProperties creates new or updates existing custom property values for a repository.
//
// GitHub API docs: https://docs.github.com/rest/repos/custom-properties#create-or-update-custom-property-values-for-a-repository
//
//meta:operation PATCH /repos/{owner}/{repo}/properties/values
func (s *RepositoriesService) CreateOrUpdateCustomProperties(ctx context.Context, org, repo string, customPropertyValues []*CustomPropertyValue) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/properties/values", org, repo)
params := struct {
Properties []*CustomPropertyValue `json:"properties"`
}{
Properties: customPropertyValues,
}
req, err := s.client.NewRequest("PATCH", u, params)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}