-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathenterprise_organization_properties.go
More file actions
189 lines (159 loc) · 7.81 KB
/
enterprise_organization_properties.go
File metadata and controls
189 lines (159 loc) · 7.81 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// 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"
)
// EnterpriseCustomPropertySchema represents the schema response for GetEnterpriseCustomPropertiesSchema.
type EnterpriseCustomPropertySchema struct {
// An ordered list of the custom property defined in the enterprise.
Properties []*CustomProperty `json:"properties,omitempty"`
}
// EnterpriseCustomPropertiesValues represents the custom properties values for an organization within an enterprise.
type EnterpriseCustomPropertiesValues struct {
// The Organization ID that the custom property values will be applied to.
OrganizationID *int64 `json:"organization_id,omitempty"`
// The names of organizations that the custom property values will be applied to.
OrganizationLogin *string `json:"organization_login,omitempty"`
// List of custom property names and associated values to apply to the organizations.
Properties []*CustomPropertyValue `json:"properties,omitempty"`
}
// EnterpriseCustomPropertyValuesRequest represents the request to update custom property values for organizations within an enterprise.
type EnterpriseCustomPropertyValuesRequest struct {
// The names of organizations that the custom property values will be applied to.
// OrganizationLogin specifies the organization name when updating multiple organizations.
OrganizationLogin []string `json:"organization_login"`
// List of custom property names and associated values to apply to the organizations.
Properties []*CustomPropertyValue `json:"properties"`
}
// GetOrganizationCustomPropertySchema gets all organization custom property definitions that are defined on an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/custom-properties-for-orgs#get-organization-custom-properties-schema-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/org-properties/schema
func (s *EnterpriseService) GetOrganizationCustomPropertySchema(ctx context.Context, enterprise string) (*EnterpriseCustomPropertySchema, *Response, error) {
u := fmt.Sprintf("enterprises/%v/org-properties/schema", enterprise)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var schema *EnterpriseCustomPropertySchema
resp, err := s.client.Do(ctx, req, &schema)
if err != nil {
return nil, resp, err
}
return schema, resp, nil
}
// CreateOrUpdateOrganizationCustomPropertySchema creates new or updates existing organization custom properties defined on an enterprise in a batch.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/custom-properties-for-orgs#create-or-update-organization-custom-property-definitions-on-an-enterprise
//
//meta:operation PATCH /enterprises/{enterprise}/org-properties/schema
func (s *EnterpriseService) CreateOrUpdateOrganizationCustomPropertySchema(ctx context.Context, enterprise string, schema EnterpriseCustomPropertySchema) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/org-properties/schema", enterprise)
req, err := s.client.NewRequest("PATCH", u, schema)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// GetOrganizationCustomProperty retrieves a specific organization custom property definition from an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/custom-properties-for-orgs#get-an-organization-custom-property-definition-from-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/org-properties/schema/{custom_property_name}
func (s *EnterpriseService) GetOrganizationCustomProperty(ctx context.Context, enterprise, customPropertyName string) (*CustomProperty, *Response, error) {
u := fmt.Sprintf("enterprises/%v/org-properties/schema/%v", enterprise, customPropertyName)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var property *CustomProperty
resp, err := s.client.Do(ctx, req, &property)
if err != nil {
return nil, resp, err
}
return property, resp, nil
}
// CreateOrUpdateOrganizationCustomProperty creates a new or updates an existing organization custom property definition that is defined on an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/custom-properties-for-orgs#create-or-update-an-organization-custom-property-definition-on-an-enterprise
//
//meta:operation PUT /enterprises/{enterprise}/org-properties/schema/{custom_property_name}
func (s *EnterpriseService) CreateOrUpdateOrganizationCustomProperty(ctx context.Context, enterprise, customPropertyName string, property CustomProperty) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/org-properties/schema/%v", enterprise, customPropertyName)
req, err := s.client.NewRequest("PUT", u, property)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// DeleteOrganizationCustomProperty removes an organization custom property definition that is defined on an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/custom-properties-for-orgs#remove-an-organization-custom-property-definition-from-an-enterprise
//
//meta:operation DELETE /enterprises/{enterprise}/org-properties/schema/{custom_property_name}
func (s *EnterpriseService) DeleteOrganizationCustomProperty(ctx context.Context, enterprise, customPropertyName string) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/org-properties/schema/%v", enterprise, customPropertyName)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}
resp, err := s.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}
// ListOrganizationCustomPropertyValues lists enterprise organizations with all of their custom property values.
// Returns a list of organizations and their custom property values defined in the enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/custom-properties-for-orgs#list-custom-property-values-for-organizations-in-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/org-properties/values
func (s *EnterpriseService) ListOrganizationCustomPropertyValues(ctx context.Context, enterprise string, opts *ListOptions) ([]*EnterpriseCustomPropertiesValues, *Response, error) {
u := fmt.Sprintf("enterprises/%v/org-properties/values", enterprise)
u, err := addOptions(u, opts)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var values []*EnterpriseCustomPropertiesValues
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 organizations in an enterprise.
// 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/enterprise-admin/custom-properties-for-orgs#create-or-update-custom-property-values-for-organizations-in-an-enterprise
//
//meta:operation PATCH /enterprises/{enterprise}/org-properties/values
func (s *EnterpriseService) CreateOrUpdateOrganizationCustomPropertyValues(ctx context.Context, enterprise string, values EnterpriseCustomPropertyValuesRequest) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/org-properties/values", enterprise)
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
}