diff --git a/github/github-accessors.go b/github/github-accessors.go index 7d4a0782869..5c6a3a0d7ca 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -4222,6 +4222,30 @@ func (c *CreateCodespaceOptions) GetWorkingDirectory() string { return *c.WorkingDirectory } +// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. +func (c *CreateCustomRepoRoleOptions) GetBaseRole() string { + if c == nil || c.BaseRole == nil { + return "" + } + return *c.BaseRole +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (c *CreateCustomRepoRoleOptions) GetDescription() string { + if c == nil || c.Description == nil { + return "" + } + return *c.Description +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (c *CreateCustomRepoRoleOptions) GetName() string { + if c == nil || c.Name == nil { + return "" + } + return *c.Name +} + // GetAllowsPublicRepositories returns the AllowsPublicRepositories field if it's non-nil, zero value otherwise. func (c *CreateEnterpriseRunnerGroupRequest) GetAllowsPublicRepositories() bool { if c == nil || c.AllowsPublicRepositories == nil { @@ -4350,16 +4374,8 @@ func (c *CreateOrgInvitationOptions) GetRole() string { return *c.Role } -// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. -func (c *CreateOrUpdateCustomRepoRoleOptions) GetBaseRole() string { - if c == nil || c.BaseRole == nil { - return "" - } - return *c.BaseRole -} - // GetDescription returns the Description field if it's non-nil, zero value otherwise. -func (c *CreateOrUpdateCustomRepoRoleOptions) GetDescription() string { +func (c *CreateOrgRoleOptions) GetDescription() string { if c == nil || c.Description == nil { return "" } @@ -4367,23 +4383,7 @@ func (c *CreateOrUpdateCustomRepoRoleOptions) GetDescription() string { } // GetName returns the Name field if it's non-nil, zero value otherwise. -func (c *CreateOrUpdateCustomRepoRoleOptions) GetName() string { - if c == nil || c.Name == nil { - return "" - } - return *c.Name -} - -// GetDescription returns the Description field if it's non-nil, zero value otherwise. -func (c *CreateOrUpdateOrgRoleOptions) GetDescription() string { - if c == nil || c.Description == nil { - return "" - } - return *c.Description -} - -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (c *CreateOrUpdateOrgRoleOptions) GetName() string { +func (c *CreateOrgRoleOptions) GetName() string { if c == nil || c.Name == nil { return "" } @@ -23974,6 +23974,30 @@ func (u *UpdateCheckRunOptions) GetStatus() string { return *u.Status } +// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. +func (u *UpdateCustomRepoRoleOptions) GetBaseRole() string { + if u == nil || u.BaseRole == nil { + return "" + } + return *u.BaseRole +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (u *UpdateCustomRepoRoleOptions) GetDescription() string { + if u == nil || u.Description == nil { + return "" + } + return *u.Description +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (u *UpdateCustomRepoRoleOptions) GetName() string { + if u == nil || u.Name == nil { + return "" + } + return *u.Name +} + // GetQuerySuite returns the QuerySuite field if it's non-nil, zero value otherwise. func (u *UpdateDefaultSetupConfigurationOptions) GetQuerySuite() string { if u == nil || u.QuerySuite == nil { @@ -24030,6 +24054,22 @@ func (u *UpdateEnterpriseRunnerGroupRequest) GetVisibility() string { return *u.Visibility } +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (u *UpdateOrgRoleOptions) GetDescription() string { + if u == nil || u.Description == nil { + return "" + } + return *u.Description +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (u *UpdateOrgRoleOptions) GetName() string { + if u == nil || u.Name == nil { + return "" + } + return *u.Name +} + // GetAllowsPublicRepositories returns the AllowsPublicRepositories field if it's non-nil, zero value otherwise. func (u *UpdateRunnerGroupRequest) GetAllowsPublicRepositories() bool { if u == nil || u.AllowsPublicRepositories == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index a401ecc1693..676371d8a3f 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -4957,6 +4957,36 @@ func TestCreateCodespaceOptions_GetWorkingDirectory(tt *testing.T) { c.GetWorkingDirectory() } +func TestCreateCustomRepoRoleOptions_GetBaseRole(tt *testing.T) { + var zeroValue string + c := &CreateCustomRepoRoleOptions{BaseRole: &zeroValue} + c.GetBaseRole() + c = &CreateCustomRepoRoleOptions{} + c.GetBaseRole() + c = nil + c.GetBaseRole() +} + +func TestCreateCustomRepoRoleOptions_GetDescription(tt *testing.T) { + var zeroValue string + c := &CreateCustomRepoRoleOptions{Description: &zeroValue} + c.GetDescription() + c = &CreateCustomRepoRoleOptions{} + c.GetDescription() + c = nil + c.GetDescription() +} + +func TestCreateCustomRepoRoleOptions_GetName(tt *testing.T) { + var zeroValue string + c := &CreateCustomRepoRoleOptions{Name: &zeroValue} + c.GetName() + c = &CreateCustomRepoRoleOptions{} + c.GetName() + c = nil + c.GetName() +} + func TestCreateEnterpriseRunnerGroupRequest_GetAllowsPublicRepositories(tt *testing.T) { var zeroValue bool c := &CreateEnterpriseRunnerGroupRequest{AllowsPublicRepositories: &zeroValue} @@ -5105,51 +5135,21 @@ func TestCreateOrgInvitationOptions_GetRole(tt *testing.T) { c.GetRole() } -func TestCreateOrUpdateCustomRepoRoleOptions_GetBaseRole(tt *testing.T) { - var zeroValue string - c := &CreateOrUpdateCustomRepoRoleOptions{BaseRole: &zeroValue} - c.GetBaseRole() - c = &CreateOrUpdateCustomRepoRoleOptions{} - c.GetBaseRole() - c = nil - c.GetBaseRole() -} - -func TestCreateOrUpdateCustomRepoRoleOptions_GetDescription(tt *testing.T) { - var zeroValue string - c := &CreateOrUpdateCustomRepoRoleOptions{Description: &zeroValue} - c.GetDescription() - c = &CreateOrUpdateCustomRepoRoleOptions{} - c.GetDescription() - c = nil - c.GetDescription() -} - -func TestCreateOrUpdateCustomRepoRoleOptions_GetName(tt *testing.T) { +func TestCreateOrgRoleOptions_GetDescription(tt *testing.T) { var zeroValue string - c := &CreateOrUpdateCustomRepoRoleOptions{Name: &zeroValue} - c.GetName() - c = &CreateOrUpdateCustomRepoRoleOptions{} - c.GetName() - c = nil - c.GetName() -} - -func TestCreateOrUpdateOrgRoleOptions_GetDescription(tt *testing.T) { - var zeroValue string - c := &CreateOrUpdateOrgRoleOptions{Description: &zeroValue} + c := &CreateOrgRoleOptions{Description: &zeroValue} c.GetDescription() - c = &CreateOrUpdateOrgRoleOptions{} + c = &CreateOrgRoleOptions{} c.GetDescription() c = nil c.GetDescription() } -func TestCreateOrUpdateOrgRoleOptions_GetName(tt *testing.T) { +func TestCreateOrgRoleOptions_GetName(tt *testing.T) { var zeroValue string - c := &CreateOrUpdateOrgRoleOptions{Name: &zeroValue} + c := &CreateOrgRoleOptions{Name: &zeroValue} c.GetName() - c = &CreateOrUpdateOrgRoleOptions{} + c = &CreateOrgRoleOptions{} c.GetName() c = nil c.GetName() @@ -27838,6 +27838,36 @@ func TestUpdateCheckRunOptions_GetStatus(tt *testing.T) { u.GetStatus() } +func TestUpdateCustomRepoRoleOptions_GetBaseRole(tt *testing.T) { + var zeroValue string + u := &UpdateCustomRepoRoleOptions{BaseRole: &zeroValue} + u.GetBaseRole() + u = &UpdateCustomRepoRoleOptions{} + u.GetBaseRole() + u = nil + u.GetBaseRole() +} + +func TestUpdateCustomRepoRoleOptions_GetDescription(tt *testing.T) { + var zeroValue string + u := &UpdateCustomRepoRoleOptions{Description: &zeroValue} + u.GetDescription() + u = &UpdateCustomRepoRoleOptions{} + u.GetDescription() + u = nil + u.GetDescription() +} + +func TestUpdateCustomRepoRoleOptions_GetName(tt *testing.T) { + var zeroValue string + u := &UpdateCustomRepoRoleOptions{Name: &zeroValue} + u.GetName() + u = &UpdateCustomRepoRoleOptions{} + u.GetName() + u = nil + u.GetName() +} + func TestUpdateDefaultSetupConfigurationOptions_GetQuerySuite(tt *testing.T) { var zeroValue string u := &UpdateDefaultSetupConfigurationOptions{QuerySuite: &zeroValue} @@ -27908,6 +27938,26 @@ func TestUpdateEnterpriseRunnerGroupRequest_GetVisibility(tt *testing.T) { u.GetVisibility() } +func TestUpdateOrgRoleOptions_GetDescription(tt *testing.T) { + var zeroValue string + u := &UpdateOrgRoleOptions{Description: &zeroValue} + u.GetDescription() + u = &UpdateOrgRoleOptions{} + u.GetDescription() + u = nil + u.GetDescription() +} + +func TestUpdateOrgRoleOptions_GetName(tt *testing.T) { + var zeroValue string + u := &UpdateOrgRoleOptions{Name: &zeroValue} + u.GetName() + u = &UpdateOrgRoleOptions{} + u.GetName() + u = nil + u.GetName() +} + func TestUpdateRunnerGroupRequest_GetAllowsPublicRepositories(tt *testing.T) { var zeroValue bool u := &UpdateRunnerGroupRequest{AllowsPublicRepositories: &zeroValue} diff --git a/github/orgs_custom_roles.go b/github/orgs_custom_roles.go index dcbd79efa77..47093d6dca3 100644 --- a/github/orgs_custom_roles.go +++ b/github/orgs_custom_roles.go @@ -49,15 +49,30 @@ type CustomRepoRoles struct { UpdatedAt *Timestamp `json:"updated_at,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"` + Description *string `json:"description"` + Permissions []string `json:"permissions"` +} + +// UpdateOrgRoleOptions represents options used to update a custom organization role. +type UpdateOrgRoleOptions struct { Name *string `json:"name,omitempty"` Description *string `json:"description,omitempty"` Permissions []string `json:"permissions,omitempty"` } -// CreateOrUpdateCustomRepoRoleOptions represents options required to create or update a custom repository role. -type CreateOrUpdateCustomRepoRoleOptions struct { +// CreateCustomRepoRoleOptions represents options required to create a custom repository role. +type CreateCustomRepoRoleOptions struct { + Name *string `json:"name"` + Description *string `json:"description"` + BaseRole *string `json:"base_role"` + Permissions []string `json:"permissions"` +} + +// UpdateCustomRepoRoleOptions represents options used to update a custom repository role. +type UpdateCustomRepoRoleOptions struct { Name *string `json:"name,omitempty"` Description *string `json:"description,omitempty"` BaseRole *string `json:"base_role,omitempty"` @@ -93,7 +108,7 @@ func (s *OrganizationsService) ListRoles(ctx context.Context, org string) (*Orga // GitHub API docs: https://docs.github.com/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) { u := fmt.Sprintf("orgs/%v/organization-roles", org) req, err := s.client.NewRequest("POST", u, opts) @@ -116,7 +131,7 @@ func (s *OrganizationsService) CreateCustomOrgRole(ctx context.Context, org stri // GitHub API docs: https://docs.github.com/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) { u := fmt.Sprintf("orgs/%v/organization-roles/%v", org, roleID) req, err := s.client.NewRequest("PATCH", u, opts) @@ -185,7 +200,7 @@ func (s *OrganizationsService) ListCustomRepoRoles(ctx context.Context, org stri // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/custom-roles#create-a-custom-repository-role // //meta:operation POST /orgs/{org}/custom-repository-roles -func (s *OrganizationsService) CreateCustomRepoRole(ctx context.Context, org string, opts *CreateOrUpdateCustomRepoRoleOptions) (*CustomRepoRoles, *Response, error) { +func (s *OrganizationsService) CreateCustomRepoRole(ctx context.Context, org string, opts *CreateCustomRepoRoleOptions) (*CustomRepoRoles, *Response, error) { u := fmt.Sprintf("orgs/%v/custom-repository-roles", org) req, err := s.client.NewRequest("POST", u, opts) @@ -208,7 +223,7 @@ func (s *OrganizationsService) CreateCustomRepoRole(ctx context.Context, org str // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/orgs/custom-roles#update-a-custom-repository-role // //meta:operation PATCH /orgs/{org}/custom-repository-roles/{role_id} -func (s *OrganizationsService) UpdateCustomRepoRole(ctx context.Context, org string, roleID int64, opts *CreateOrUpdateCustomRepoRoleOptions) (*CustomRepoRoles, *Response, error) { +func (s *OrganizationsService) UpdateCustomRepoRole(ctx context.Context, org string, roleID int64, opts *UpdateCustomRepoRoleOptions) (*CustomRepoRoles, *Response, error) { u := fmt.Sprintf("orgs/%v/custom-repository-roles/%v", org, roleID) req, err := s.client.NewRequest("PATCH", u, opts) diff --git a/github/orgs_custom_roles_test.go b/github/orgs_custom_roles_test.go index 338eac19fc1..72cddefabc1 100644 --- a/github/orgs_custom_roles_test.go +++ b/github/orgs_custom_roles_test.go @@ -109,7 +109,7 @@ func TestOrganizationsService_CreateCustomOrgRole(t *testing.T) { ctx := context.Background() - opts := &CreateOrUpdateOrgRoleOptions{ + opts := &CreateOrgRoleOptions{ Name: String("Reader"), Description: String("A role for reading custom org roles"), Permissions: []string{"read_organization_custom_org_role"}, @@ -151,7 +151,7 @@ func TestOrganizationsService_UpdateCustomOrgRole(t *testing.T) { ctx := context.Background() - opts := &CreateOrUpdateOrgRoleOptions{ + opts := &UpdateOrgRoleOptions{ Name: String("Updated Name"), Description: String("Updated Description"), } @@ -304,7 +304,7 @@ func TestOrganizationsService_CreateCustomRepoRole(t *testing.T) { ctx := context.Background() - opts := &CreateOrUpdateCustomRepoRoleOptions{ + opts := &CreateCustomRepoRoleOptions{ Name: String("Labeler"), Description: String("A role for issue and PR labelers"), BaseRole: String("read"), @@ -347,7 +347,7 @@ func TestOrganizationsService_UpdateCustomRepoRole(t *testing.T) { ctx := context.Background() - opts := &CreateOrUpdateCustomRepoRoleOptions{ + opts := &UpdateCustomRepoRoleOptions{ Name: String("Updated Name"), Description: String("Updated Description"), }