Skip to content

Commit df116e5

Browse files
feat: Add support for Issue Types API (#3525)
1 parent a03e88c commit df116e5

File tree

4 files changed

+394
-0
lines changed

4 files changed

+394
-0
lines changed

github/github-accessors.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/orgs_issue_types.go

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright 2025 The go-github AUTHORS. All rights reserved.
2+
//
3+
// Use of this source code is governed by a BSD-style
4+
// license that can be found in the LICENSE file.
5+
6+
package github
7+
8+
import (
9+
"context"
10+
"fmt"
11+
)
12+
13+
// CreateOrUpdateIssueTypesOptions represents the parameters for creating or updating an issue type.
14+
type CreateOrUpdateIssueTypesOptions struct {
15+
Name string `json:"name"` // Name of the issue type. (Required.)
16+
IsEnabled bool `json:"is_enabled"` // Whether or not the issue type is enabled at the organization level. (Required.)
17+
IsPrivate *bool `json:"is_private,omitempty"` // Whether or not the issue type is restricted to issues in private repositories. (Optional.)
18+
Description *string `json:"description,omitempty"` // Description of the issue type. (Optional.)
19+
Color *string `json:"color,omitempty"` // Color for the issue type. Can be one of "gray", "blue", green "orange", "red", "pink", "purple", "null". (Optional.)
20+
}
21+
22+
// ListIssueTypes lists all issue types for an organization.
23+
//
24+
// GitHub API docs: https://docs.github.com/rest/orgs/issue-types#list-issue-types-for-an-organization
25+
//
26+
//meta:operation GET /orgs/{org}/issue-types
27+
func (s *OrganizationsService) ListIssueTypes(ctx context.Context, org string) ([]*IssueType, *Response, error) {
28+
u := fmt.Sprintf("orgs/%v/issue-types", org)
29+
30+
req, err := s.client.NewRequest("GET", u, nil)
31+
if err != nil {
32+
return nil, nil, err
33+
}
34+
35+
var issueTypes []*IssueType
36+
resp, err := s.client.Do(ctx, req, &issueTypes)
37+
if err != nil {
38+
return nil, resp, err
39+
}
40+
41+
return issueTypes, resp, nil
42+
}
43+
44+
// CreateIssueType creates a new issue type for an organization.
45+
//
46+
// GitHub API docs: https://docs.github.com/rest/orgs/issue-types#create-issue-type-for-an-organization
47+
//
48+
//meta:operation POST /orgs/{org}/issue-types
49+
func (s *OrganizationsService) CreateIssueType(ctx context.Context, org string, opt *CreateOrUpdateIssueTypesOptions) (*IssueType, *Response, error) {
50+
u := fmt.Sprintf("orgs/%v/issue-types", org)
51+
req, err := s.client.NewRequest("POST", u, opt)
52+
if err != nil {
53+
return nil, nil, err
54+
}
55+
56+
issueType := new(IssueType)
57+
resp, err := s.client.Do(ctx, req, issueType)
58+
if err != nil {
59+
return nil, resp, err
60+
}
61+
62+
return issueType, resp, nil
63+
}
64+
65+
// UpdateIssueType updates GitHub Pages for the named repo.
66+
//
67+
// GitHub API docs: https://docs.github.com/rest/orgs/issue-types#update-issue-type-for-an-organization
68+
//
69+
//meta:operation PUT /orgs/{org}/issue-types/{issue_type_id}
70+
func (s *OrganizationsService) UpdateIssueType(ctx context.Context, org string, issueTypeID int64, opt *CreateOrUpdateIssueTypesOptions) (*IssueType, *Response, error) {
71+
u := fmt.Sprintf("orgs/%v/issue-types/%v", org, issueTypeID)
72+
req, err := s.client.NewRequest("PUT", u, opt)
73+
if err != nil {
74+
return nil, nil, err
75+
}
76+
77+
issueType := new(IssueType)
78+
resp, err := s.client.Do(ctx, req, issueType)
79+
if err != nil {
80+
return nil, resp, err
81+
}
82+
83+
return issueType, resp, nil
84+
}
85+
86+
// DeleteIssueType deletes an issue type for an organization.
87+
//
88+
// GitHub API docs: https://docs.github.com/rest/orgs/issue-types#delete-issue-type-for-an-organization
89+
//
90+
//meta:operation DELETE /orgs/{org}/issue-types/{issue_type_id}
91+
func (s *OrganizationsService) DeleteIssueType(ctx context.Context, org string, issueTypeID int64) (*Response, error) {
92+
u := fmt.Sprintf("orgs/%v/issue-types/%d", org, issueTypeID)
93+
req, err := s.client.NewRequest("DELETE", u, nil)
94+
if err != nil {
95+
return nil, err
96+
}
97+
98+
return s.client.Do(ctx, req, nil)
99+
}

0 commit comments

Comments
 (0)