diff --git a/.golangci.yml b/.golangci.yml index 683c72ff4c5..3483ce9a60b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -206,7 +206,6 @@ linters: - CodeScanningAlertState - ConfigApplyOptions - ConfigSettings - - CreateOrUpdateIssueTypesOptions - CreateUpdateEnvironment - CreateWorkflowDispatchEventRequest - CustomDeploymentProtectionRuleRequest @@ -244,7 +243,6 @@ linters: - ConfigApplyOptions - CreateCheckRunOptions - CreateCheckSuiteOptions - - CreateOrUpdateIssueTypesOptions - InstallationTokenListRepoOptions - InstallationTokenOptions - LockIssueOptions diff --git a/github/github-accessors.go b/github/github-accessors.go index e192e57d774..096a63288cb 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -13054,6 +13054,38 @@ func (c *CreateIssueRequest) GetType() string { return *c.Type } +// GetColor returns the Color field if it's non-nil, zero value otherwise. +func (c *CreateIssueTypeRequest) GetColor() string { + if c == nil || c.Color == nil { + return "" + } + return *c.Color +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (c *CreateIssueTypeRequest) GetDescription() string { + if c == nil || c.Description == nil { + return "" + } + return *c.Description +} + +// GetIsEnabled returns the IsEnabled field. +func (c *CreateIssueTypeRequest) GetIsEnabled() bool { + if c == nil { + return false + } + return c.IsEnabled +} + +// GetName returns the Name field. +func (c *CreateIssueTypeRequest) GetName() string { + if c == nil { + return "" + } + return c.Name +} + // GetLabels returns the Labels slice if it's non-nil, nil otherwise. func (c *CreateJITConfigRequest) GetLabels() []string { if c == nil || c.Labels == nil { @@ -13342,46 +13374,6 @@ func (c *CreateOrgInvitationRequest) GetTeamIDs() []int64 { return c.TeamIDs } -// GetColor returns the Color field if it's non-nil, zero value otherwise. -func (c *CreateOrUpdateIssueTypesOptions) GetColor() string { - if c == nil || c.Color == nil { - return "" - } - return *c.Color -} - -// GetDescription returns the Description field if it's non-nil, zero value otherwise. -func (c *CreateOrUpdateIssueTypesOptions) GetDescription() string { - if c == nil || c.Description == nil { - return "" - } - return *c.Description -} - -// GetIsEnabled returns the IsEnabled field. -func (c *CreateOrUpdateIssueTypesOptions) GetIsEnabled() bool { - if c == nil { - return false - } - return c.IsEnabled -} - -// GetIsPrivate returns the IsPrivate field if it's non-nil, zero value otherwise. -func (c *CreateOrUpdateIssueTypesOptions) GetIsPrivate() bool { - if c == nil || c.IsPrivate == nil { - return false - } - return *c.IsPrivate -} - -// GetName returns the Name field. -func (c *CreateOrUpdateIssueTypesOptions) GetName() string { - if c == nil { - return "" - } - return c.Name -} - // GetBody returns the Body field if it's non-nil, zero value otherwise. func (c *CreateProjectV2DraftItemRequest) GetBody() string { if c == nil || c.Body == nil { @@ -46310,6 +46302,38 @@ func (u *UpdateIssueRequest) GetType() string { return *u.Type } +// GetColor returns the Color field if it's non-nil, zero value otherwise. +func (u *UpdateIssueTypeRequest) GetColor() string { + if u == nil || u.Color == nil { + return "" + } + return *u.Color +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (u *UpdateIssueTypeRequest) GetDescription() string { + if u == nil || u.Description == nil { + return "" + } + return *u.Description +} + +// GetIsEnabled returns the IsEnabled field. +func (u *UpdateIssueTypeRequest) GetIsEnabled() bool { + if u == nil { + return false + } + return u.IsEnabled +} + +// GetName returns the Name field. +func (u *UpdateIssueTypeRequest) GetName() string { + if u == nil { + return "" + } + return u.Name +} + // GetDescription returns the Description field if it's non-nil, zero value otherwise. func (u *UpdateMilestoneRequest) GetDescription() string { if u == nil || u.Description == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index e86fbcce1fc..7167f4de632 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -16412,6 +16412,44 @@ func TestCreateIssueRequest_GetType(tt *testing.T) { c.GetType() } +func TestCreateIssueTypeRequest_GetColor(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateIssueTypeRequest{Color: &zeroValue} + c.GetColor() + c = &CreateIssueTypeRequest{} + c.GetColor() + c = nil + c.GetColor() +} + +func TestCreateIssueTypeRequest_GetDescription(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateIssueTypeRequest{Description: &zeroValue} + c.GetDescription() + c = &CreateIssueTypeRequest{} + c.GetDescription() + c = nil + c.GetDescription() +} + +func TestCreateIssueTypeRequest_GetIsEnabled(tt *testing.T) { + tt.Parallel() + c := &CreateIssueTypeRequest{} + c.GetIsEnabled() + c = nil + c.GetIsEnabled() +} + +func TestCreateIssueTypeRequest_GetName(tt *testing.T) { + tt.Parallel() + c := &CreateIssueTypeRequest{} + c.GetName() + c = nil + c.GetName() +} + func TestCreateJITConfigRequest_GetLabels(tt *testing.T) { tt.Parallel() zeroValue := []string{} @@ -16787,55 +16825,6 @@ func TestCreateOrgInvitationRequest_GetTeamIDs(tt *testing.T) { c.GetTeamIDs() } -func TestCreateOrUpdateIssueTypesOptions_GetColor(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CreateOrUpdateIssueTypesOptions{Color: &zeroValue} - c.GetColor() - c = &CreateOrUpdateIssueTypesOptions{} - c.GetColor() - c = nil - c.GetColor() -} - -func TestCreateOrUpdateIssueTypesOptions_GetDescription(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CreateOrUpdateIssueTypesOptions{Description: &zeroValue} - c.GetDescription() - c = &CreateOrUpdateIssueTypesOptions{} - c.GetDescription() - c = nil - c.GetDescription() -} - -func TestCreateOrUpdateIssueTypesOptions_GetIsEnabled(tt *testing.T) { - tt.Parallel() - c := &CreateOrUpdateIssueTypesOptions{} - c.GetIsEnabled() - c = nil - c.GetIsEnabled() -} - -func TestCreateOrUpdateIssueTypesOptions_GetIsPrivate(tt *testing.T) { - tt.Parallel() - var zeroValue bool - c := &CreateOrUpdateIssueTypesOptions{IsPrivate: &zeroValue} - c.GetIsPrivate() - c = &CreateOrUpdateIssueTypesOptions{} - c.GetIsPrivate() - c = nil - c.GetIsPrivate() -} - -func TestCreateOrUpdateIssueTypesOptions_GetName(tt *testing.T) { - tt.Parallel() - c := &CreateOrUpdateIssueTypesOptions{} - c.GetName() - c = nil - c.GetName() -} - func TestCreateProjectV2DraftItemRequest_GetBody(tt *testing.T) { tt.Parallel() var zeroValue string @@ -57753,6 +57742,44 @@ func TestUpdateIssueRequest_GetType(tt *testing.T) { u.GetType() } +func TestUpdateIssueTypeRequest_GetColor(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UpdateIssueTypeRequest{Color: &zeroValue} + u.GetColor() + u = &UpdateIssueTypeRequest{} + u.GetColor() + u = nil + u.GetColor() +} + +func TestUpdateIssueTypeRequest_GetDescription(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UpdateIssueTypeRequest{Description: &zeroValue} + u.GetDescription() + u = &UpdateIssueTypeRequest{} + u.GetDescription() + u = nil + u.GetDescription() +} + +func TestUpdateIssueTypeRequest_GetIsEnabled(tt *testing.T) { + tt.Parallel() + u := &UpdateIssueTypeRequest{} + u.GetIsEnabled() + u = nil + u.GetIsEnabled() +} + +func TestUpdateIssueTypeRequest_GetName(tt *testing.T) { + tt.Parallel() + u := &UpdateIssueTypeRequest{} + u.GetName() + u = nil + u.GetName() +} + func TestUpdateMilestoneRequest_GetDescription(tt *testing.T) { tt.Parallel() var zeroValue string diff --git a/github/orgs_issue_types.go b/github/orgs_issue_types.go index 0edc7ad5036..3d2193e9d32 100644 --- a/github/orgs_issue_types.go +++ b/github/orgs_issue_types.go @@ -10,13 +10,20 @@ import ( "fmt" ) -// CreateOrUpdateIssueTypesOptions represents the parameters for creating or updating an issue type. -type CreateOrUpdateIssueTypesOptions struct { +// CreateIssueTypeRequest represents the parameters to create an issue type. +type CreateIssueTypeRequest struct { Name string `json:"name"` // Name of the issue type. (Required.) IsEnabled bool `json:"is_enabled"` // Whether or not the issue type is enabled at the organization level. (Required.) - IsPrivate *bool `json:"is_private,omitempty"` // Whether or not the issue type is restricted to issues in private repositories. (Optional.) Description *string `json:"description,omitempty"` // Description of the issue type. (Optional.) - Color *string `json:"color,omitempty"` // Color for the issue type. Can be one of "gray", "blue", green "orange", "red", "pink", "purple", "null". (Optional.) + Color *string `json:"color,omitempty"` // Color for the issue type. Can be one of "gray", "blue", "green", "yellow", "orange", "red", "pink", "purple", "null". (Optional.) +} + +// UpdateIssueTypeRequest represents the parameters to update an issue type. +type UpdateIssueTypeRequest struct { + Name string `json:"name"` // Name of the issue type. (Required.) + IsEnabled bool `json:"is_enabled"` // Whether or not the issue type is enabled at the organization level. (Required.) + Description *string `json:"description,omitempty"` // Description of the issue type. (Optional.) + Color *string `json:"color,omitempty"` // Color for the issue type. Can be one of "gray", "blue", "green", "yellow", "orange", "red", "pink", "purple", "null". (Optional.) } // ListIssueTypes lists all issue types for an organization. @@ -46,7 +53,7 @@ func (s *OrganizationsService) ListIssueTypes(ctx context.Context, org string) ( // GitHub API docs: https://docs.github.com/rest/orgs/issue-types?apiVersion=2022-11-28#create-issue-type-for-an-organization // //meta:operation POST /orgs/{org}/issue-types -func (s *OrganizationsService) CreateIssueType(ctx context.Context, org string, body *CreateOrUpdateIssueTypesOptions) (*IssueType, *Response, error) { +func (s *OrganizationsService) CreateIssueType(ctx context.Context, org string, body CreateIssueTypeRequest) (*IssueType, *Response, error) { u := fmt.Sprintf("orgs/%v/issue-types", org) req, err := s.client.NewRequest(ctx, "POST", u, body) if err != nil { @@ -62,12 +69,12 @@ func (s *OrganizationsService) CreateIssueType(ctx context.Context, org string, return issueType, resp, nil } -// UpdateIssueType updates GitHub Pages for the named repo. +// UpdateIssueType updates an issue type for an organization. // // GitHub API docs: https://docs.github.com/rest/orgs/issue-types?apiVersion=2022-11-28#update-issue-type-for-an-organization // //meta:operation PUT /orgs/{org}/issue-types/{issue_type_id} -func (s *OrganizationsService) UpdateIssueType(ctx context.Context, org string, issueTypeID int64, body *CreateOrUpdateIssueTypesOptions) (*IssueType, *Response, error) { +func (s *OrganizationsService) UpdateIssueType(ctx context.Context, org string, issueTypeID int64, body UpdateIssueTypeRequest) (*IssueType, *Response, error) { u := fmt.Sprintf("orgs/%v/issue-types/%v", org, issueTypeID) req, err := s.client.NewRequest(ctx, "PUT", u, body) if err != nil { diff --git a/github/orgs_issue_types_test.go b/github/orgs_issue_types_test.go index ef6db3d1963..4f4bd68f02c 100644 --- a/github/orgs_issue_types_test.go +++ b/github/orgs_issue_types_test.go @@ -90,12 +90,11 @@ func TestOrganizationsService_CreateIssueType(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &CreateOrUpdateIssueTypesOptions{ + input := CreateIssueTypeRequest{ Name: "Epic", Description: new("An issue type for a multi-week tracking of work"), IsEnabled: true, Color: new("green"), - IsPrivate: new(true), } mux.HandleFunc("/orgs/o/issue-types", func(w http.ResponseWriter, r *http.Request) { @@ -150,12 +149,11 @@ func TestOrganizationsService_UpdateIssueType(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &CreateOrUpdateIssueTypesOptions{ + input := UpdateIssueTypeRequest{ Name: "Epic", Description: new("An issue type for a multi-week tracking of work"), IsEnabled: true, Color: new("green"), - IsPrivate: new(true), } mux.HandleFunc("/orgs/o/issue-types/410", func(w http.ResponseWriter, r *http.Request) {