forked from google/go-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorgs_organization_properties.go
More file actions
60 lines (50 loc) · 2.13 KB
/
orgs_organization_properties.go
File metadata and controls
60 lines (50 loc) · 2.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
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 2025 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"
)
// OrganizationCustomPropertyValues represents the custom property values for an organization.
type OrganizationCustomPropertyValues struct {
// List of custom property names and associated values to apply to the organization.
Properties []*CustomPropertyValue `json:"properties,omitempty"`
}
// GetOrganizationCustomPropertyValues returns all custom property names and their values for an organization.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/custom-properties-for-orgs#get-all-custom-property-values-for-an-organization
//
//meta:operation GET /organizations/{org}/org-properties/values
func (s *OrganizationsService) GetOrganizationCustomPropertyValues(ctx context.Context, org string) ([]*CustomPropertyValue, *Response, error) {
u := fmt.Sprintf("organizations/%v/org-properties/values", org)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var values []*CustomPropertyValue
resp, err := s.client.Do(ctx, req, &values)
if err != nil {
return nil, resp, err
}
return values, resp, nil
}
// CreateOrUpdateOrganizationCustomPropertyValues creates or updates custom property values for an organization.
// To remove a custom property value from an organization, set the property value to null.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/custom-properties-for-orgs#create-or-update-custom-property-values-for-an-organization
//
//meta:operation PATCH /organizations/{org}/org-properties/values
func (s *OrganizationsService) CreateOrUpdateOrganizationCustomPropertyValues(ctx context.Context, org string, values OrganizationCustomPropertyValues) (*Response, error) {
u := fmt.Sprintf("organizations/%v/org-properties/values", org)
req, err := s.client.NewRequest("PATCH", u, values)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}