@@ -10,6 +10,20 @@ import (
1010 "fmt"
1111)
1212
13+ // OrganizationCustomRoles represents custom organization roles available in specified organization.
14+ type OrganizationCustomRoles struct {
15+ TotalCount * int `json:"total_count,omitempty"`
16+ CustomRepoRoles []* CustomOrgRoles `json:"roles,omitempty"`
17+ }
18+
19+ // CustomOrgRoles represents custom organization role available in specified organization.
20+ type CustomOrgRoles struct {
21+ ID * int64 `json:"id,omitempty"`
22+ Name * string `json:"name,omitempty"`
23+ Description * string `json:"description,omitempty"`
24+ Permissions []string `json:"permissions,omitempty"`
25+ }
26+
1327// OrganizationCustomRepoRoles represents custom repository roles available in specified organization.
1428type OrganizationCustomRepoRoles struct {
1529 TotalCount * int `json:"total_count,omitempty"`
@@ -27,6 +41,113 @@ type CustomRepoRoles struct {
2741 Permissions []string `json:"permissions,omitempty"`
2842}
2943
44+ // CreateOrUpdateOrgRoleOptions represents options required to create or update a custom organization role.
45+ type CreateOrUpdateOrgRoleOptions struct {
46+ Name * string `json:"name,omitempty"`
47+ Description * string `json:"description,omitempty"`
48+ Permissions []string `json:"permissions,omitempty"`
49+ }
50+
51+ // CreateOrUpdateCustomRepoRoleOptions represents options required to create or update a custom repository role.
52+ type CreateOrUpdateCustomRepoRoleOptions struct {
53+ Name * string `json:"name,omitempty"`
54+ Description * string `json:"description,omitempty"`
55+ BaseRole * string `json:"base_role,omitempty"`
56+ Permissions []string `json:"permissions,omitempty"`
57+ }
58+
59+ // ListRoles lists the custom roles available in this organization.
60+ // In order to see custom roles in an organization, the authenticated user must be an organization owner.
61+ //
62+ // GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#get-all-organization-roles-for-an-organization
63+ //
64+ //meta:operation GET /orgs/{org}/organization-roles
65+ func (s * OrganizationsService ) ListRoles (ctx context.Context , org string ) (* OrganizationCustomRoles , * Response , error ) {
66+ u := fmt .Sprintf ("orgs/%v/organization-roles" , org )
67+
68+ req , err := s .client .NewRequest ("GET" , u , nil )
69+ if err != nil {
70+ return nil , nil , err
71+ }
72+
73+ customRepoRoles := new (OrganizationCustomRoles )
74+ resp , err := s .client .Do (ctx , req , customRepoRoles )
75+ if err != nil {
76+ return nil , resp , err
77+ }
78+
79+ return customRepoRoles , resp , nil
80+ }
81+
82+ // CreateCustomOrgRole creates a custom role in this organization.
83+ // In order to create custom roles in an organization, the authenticated user must be an organization owner.
84+ //
85+ // GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#create-a-custom-organization-role
86+ //
87+ //meta:operation POST /orgs/{org}/organization-roles
88+ func (s * OrganizationsService ) CreateCustomOrgRole (ctx context.Context , org string , opts * CreateOrUpdateOrgRoleOptions ) (* CustomOrgRoles , * Response , error ) {
89+ u := fmt .Sprintf ("orgs/%v/organization-roles" , org )
90+
91+ req , err := s .client .NewRequest ("POST" , u , opts )
92+ if err != nil {
93+ return nil , nil , err
94+ }
95+
96+ resultingRole := new (CustomOrgRoles )
97+ resp , err := s .client .Do (ctx , req , resultingRole )
98+ if err != nil {
99+ return nil , resp , err
100+ }
101+
102+ return resultingRole , resp , err
103+ }
104+
105+ // UpdateCustomOrgRole updates a custom role in this organization.
106+ // In order to update custom roles in an organization, the authenticated user must be an organization owner.
107+ //
108+ // GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#update-a-custom-organization-role
109+ //
110+ //meta:operation PATCH /orgs/{org}/organization-roles/{role_id}
111+ func (s * OrganizationsService ) UpdateCustomOrgRole (ctx context.Context , org string , roleID int64 , opts * CreateOrUpdateOrgRoleOptions ) (* CustomOrgRoles , * Response , error ) {
112+ u := fmt .Sprintf ("orgs/%v/organization-roles/%v" , org , roleID )
113+
114+ req , err := s .client .NewRequest ("PATCH" , u , opts )
115+ if err != nil {
116+ return nil , nil , err
117+ }
118+
119+ resultingRole := new (CustomOrgRoles )
120+ resp , err := s .client .Do (ctx , req , resultingRole )
121+ if err != nil {
122+ return nil , resp , err
123+ }
124+
125+ return resultingRole , resp , err
126+ }
127+
128+ // DeleteCustomOrgRole deletes an existing custom role in this organization.
129+ // In order to delete custom roles in an organization, the authenticated user must be an organization owner.
130+ //
131+ // GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#delete-a-custom-organization-role
132+ //
133+ //meta:operation DELETE /orgs/{org}/organization-roles/{role_id}
134+ func (s * OrganizationsService ) DeleteCustomOrgRole (ctx context.Context , org string , roleID int64 ) (* Response , error ) {
135+ u := fmt .Sprintf ("orgs/%v/organization-roles/%v" , org , roleID )
136+
137+ req , err := s .client .NewRequest ("DELETE" , u , nil )
138+ if err != nil {
139+ return nil , err
140+ }
141+
142+ resultingRole := new (CustomOrgRoles )
143+ resp , err := s .client .Do (ctx , req , resultingRole )
144+ if err != nil {
145+ return resp , err
146+ }
147+
148+ return resp , nil
149+ }
150+
30151// ListCustomRepoRoles lists the custom repository roles available in this organization.
31152// In order to see custom repository roles in an organization, the authenticated user must be an organization owner.
32153//
@@ -50,21 +171,13 @@ func (s *OrganizationsService) ListCustomRepoRoles(ctx context.Context, org stri
50171 return customRepoRoles , resp , nil
51172}
52173
53- // CreateOrUpdateCustomRoleOptions represents options required to create or update a custom repository role.
54- type CreateOrUpdateCustomRoleOptions struct {
55- Name * string `json:"name,omitempty"`
56- Description * string `json:"description,omitempty"`
57- BaseRole * string `json:"base_role,omitempty"`
58- Permissions []string `json:"permissions,omitempty"`
59- }
60-
61174// CreateCustomRepoRole creates a custom repository role in this organization.
62175// In order to create custom repository roles in an organization, the authenticated user must be an organization owner.
63176//
64177// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/custom-roles#create-a-custom-repository-role
65178//
66179//meta:operation POST /orgs/{org}/custom-repository-roles
67- func (s * OrganizationsService ) CreateCustomRepoRole (ctx context.Context , org string , opts * CreateOrUpdateCustomRoleOptions ) (* CustomRepoRoles , * Response , error ) {
180+ func (s * OrganizationsService ) CreateCustomRepoRole (ctx context.Context , org string , opts * CreateOrUpdateCustomRepoRoleOptions ) (* CustomRepoRoles , * Response , error ) {
68181 u := fmt .Sprintf ("orgs/%v/custom-repository-roles" , org )
69182
70183 req , err := s .client .NewRequest ("POST" , u , opts )
@@ -87,7 +200,7 @@ func (s *OrganizationsService) CreateCustomRepoRole(ctx context.Context, org str
87200// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/custom-roles#update-a-custom-repository-role
88201//
89202//meta:operation PATCH /orgs/{org}/custom-repository-roles/{role_id}
90- func (s * OrganizationsService ) UpdateCustomRepoRole (ctx context.Context , org , roleID string , opts * CreateOrUpdateCustomRoleOptions ) (* CustomRepoRoles , * Response , error ) {
203+ func (s * OrganizationsService ) UpdateCustomRepoRole (ctx context.Context , org string , roleID int64 , opts * CreateOrUpdateCustomRepoRoleOptions ) (* CustomRepoRoles , * Response , error ) {
91204 u := fmt .Sprintf ("orgs/%v/custom-repository-roles/%v" , org , roleID )
92205
93206 req , err := s .client .NewRequest ("PATCH" , u , opts )
@@ -110,7 +223,7 @@ func (s *OrganizationsService) UpdateCustomRepoRole(ctx context.Context, org, ro
110223// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/custom-roles#delete-a-custom-repository-role
111224//
112225//meta:operation DELETE /orgs/{org}/custom-repository-roles/{role_id}
113- func (s * OrganizationsService ) DeleteCustomRepoRole (ctx context.Context , org , roleID string ) (* Response , error ) {
226+ func (s * OrganizationsService ) DeleteCustomRepoRole (ctx context.Context , org string , roleID int64 ) (* Response , error ) {
114227 u := fmt .Sprintf ("orgs/%v/custom-repository-roles/%v" , org , roleID )
115228
116229 req , err := s .client .NewRequest ("DELETE" , u , nil )
0 commit comments