Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 40 additions & 24 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 55 additions & 33 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions github/orgs_organization_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ type CustomOrgRoles struct {
BaseRole *string `json:"base_role,omitempty"`
}

// CreateOrUpdateOrgRoleOptions represents options required to create or update a custom organization role.
type CreateOrUpdateOrgRoleOptions struct {
// CreateOrgRoleOptions represents options required to create a custom organization role.
type CreateOrgRoleOptions struct {
Name string `json:"name"`
Permissions []string `json:"permissions"`
Description *string `json:"description,omitempty"`
BaseRole *string `json:"base_role,omitempty"`
Comment thread
munlicode marked this conversation as resolved.
Outdated
}

// UpdateOrgRoleOptions represents options required to update a custom organization role.
type UpdateOrgRoleOptions struct {
Name *string `json:"name,omitempty"`
Permissions []string `json:"permissions,omitempty"`
Description *string `json:"description,omitempty"`
Permissions []string `json:"permissions"`
BaseRole *string `json:"base_role,omitempty"`
}
Comment thread
munlicode marked this conversation as resolved.
Outdated

Expand Down Expand Up @@ -89,7 +97,7 @@ func (s *OrganizationsService) GetOrgRole(ctx context.Context, org string, roleI
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/organization-roles#create-a-custom-organization-role
//
//meta:operation POST /orgs/{org}/organization-roles
func (s *OrganizationsService) CreateCustomOrgRole(ctx context.Context, org string, opts *CreateOrUpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
func (s *OrganizationsService) CreateCustomOrgRole(ctx context.Context, org string, opts *CreateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
Comment thread
munlicode marked this conversation as resolved.
Outdated
u := fmt.Sprintf("orgs/%v/organization-roles", org)

req, err := s.client.NewRequest("POST", u, opts)
Expand All @@ -112,7 +120,7 @@ func (s *OrganizationsService) CreateCustomOrgRole(ctx context.Context, org stri
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/organization-roles#update-a-custom-organization-role
//
//meta:operation PATCH /orgs/{org}/organization-roles/{role_id}
func (s *OrganizationsService) UpdateCustomOrgRole(ctx context.Context, org string, roleID int64, opts *CreateOrUpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
func (s *OrganizationsService) UpdateCustomOrgRole(ctx context.Context, org string, roleID int64, opts *UpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
Comment thread
munlicode marked this conversation as resolved.
Outdated
u := fmt.Sprintf("orgs/%v/organization-roles/%v", org, roleID)

req, err := s.client.NewRequest("PATCH", u, opts)
Expand Down
8 changes: 4 additions & 4 deletions github/orgs_organization_roles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ func TestOrganizationsService_CreateCustomOrgRole(t *testing.T) {

ctx := t.Context()

opts := &CreateOrUpdateOrgRoleOptions{
Name: Ptr("Reader"),
Description: Ptr("A role for reading custom org roles"),
opts := &CreateOrgRoleOptions{
Name: "Reader",
Permissions: []string{"read_organization_custom_org_role"},
Description: Ptr("A role for reading custom org roles"),
}
gotRoles, _, err := client.Organizations.CreateCustomOrgRole(ctx, "o", opts)
if err != nil {
Expand Down Expand Up @@ -249,7 +249,7 @@ func TestOrganizationsService_UpdateCustomOrgRole(t *testing.T) {

ctx := t.Context()

opts := &CreateOrUpdateOrgRoleOptions{
opts := &UpdateOrgRoleOptions{
Name: Ptr("Updated Name"),
Description: Ptr("Updated Description"),
}
Expand Down
Loading