// Copyright 2013 The go-github AUTHORS. All rights reserved.//// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package githubimport ()// IssuesService handles communication with the issue related// methods of the GitHub API.//// GitHub API docs: https://docs.github.com/rest/issues/typeIssuesServiceservice// Issue represents a GitHub issue on a repository.//// Note: As far as the GitHub API is concerned, every pull request is an issue,// but not every issue is a pull request. Some endpoints, events, and webhooks// may also return pull requests via this struct. If PullRequestLinks is nil,// this is an issue, and if PullRequestLinks is not nil, this is a pull request.// The IsPullRequest helper method can be used to check that.typeIssuestruct { ID *int64`json:"id,omitempty"` Number *int`json:"number,omitempty"` State *string`json:"state,omitempty"`// StateReason can be one of: "completed", "not_planned", "reopened". StateReason *string`json:"state_reason,omitempty"` Locked *bool`json:"locked,omitempty"` Title *string`json:"title,omitempty"` Body *string`json:"body,omitempty"` AuthorAssociation *string`json:"author_association,omitempty"` User *User`json:"user,omitempty"` Labels []*Label`json:"labels,omitempty"` Assignee *User`json:"assignee,omitempty"` Comments *int`json:"comments,omitempty"` ClosedAt *Timestamp`json:"closed_at,omitempty"` CreatedAt *Timestamp`json:"created_at,omitempty"` UpdatedAt *Timestamp`json:"updated_at,omitempty"` ClosedBy *User`json:"closed_by,omitempty"` URL *string`json:"url,omitempty"` HTMLURL *string`json:"html_url,omitempty"` CommentsURL *string`json:"comments_url,omitempty"` EventsURL *string`json:"events_url,omitempty"` LabelsURL *string`json:"labels_url,omitempty"` RepositoryURL *string`json:"repository_url,omitempty"` Milestone *Milestone`json:"milestone,omitempty"` PullRequestLinks *PullRequestLinks`json:"pull_request,omitempty"` Repository *Repository`json:"repository,omitempty"` Reactions *Reactions`json:"reactions,omitempty"` Assignees []*User`json:"assignees,omitempty"` NodeID *string`json:"node_id,omitempty"` Draft *bool`json:"draft,omitempty"`// TextMatches is only populated from search results that request text matches // See: search.go and https://docs.github.com/rest/search/#text-match-metadata TextMatches []*TextMatch`json:"text_matches,omitempty"`// ActiveLockReason is populated only when LockReason is provided while locking the issue. // Possible values are: "off-topic", "too heated", "resolved", and "spam". ActiveLockReason *string`json:"active_lock_reason,omitempty"`}func ( Issue) () string {returnStringify()}// IsPullRequest reports whether the issue is also a pull request. It uses the// method recommended by GitHub's API documentation, which is to check whether// PullRequestLinks is non-nil.func ( Issue) () bool {return .PullRequestLinks != nil}// IssueRequest represents a request to create/edit an issue.// It is separate from Issue above because otherwise Labels// and Assignee fail to serialize to the correct JSON.typeIssueRequeststruct { Title *string`json:"title,omitempty"` Body *string`json:"body,omitempty"` Labels *[]string`json:"labels,omitempty"` Assignee *string`json:"assignee,omitempty"` State *string`json:"state,omitempty"`// StateReason can be 'completed' or 'not_planned'. StateReason *string`json:"state_reason,omitempty"` Milestone *int`json:"milestone,omitempty"` Assignees *[]string`json:"assignees,omitempty"`}// IssueListOptions specifies the optional parameters to the IssuesService.List// and IssuesService.ListByOrg methods.typeIssueListOptionsstruct {// Filter specifies which issues to list. Possible values are: assigned, // created, mentioned, subscribed, all. Default is "assigned". Filter string`url:"filter,omitempty"`// State filters issues based on their state. Possible values are: open, // closed, all. Default is "open". State string`url:"state,omitempty"`// Labels filters issues based on their label. Labels []string`url:"labels,comma,omitempty"`// Sort specifies how to sort issues. Possible values are: created, updated, // and comments. Default value is "created". Sort string`url:"sort,omitempty"`// Direction in which to sort issues. Possible values are: asc, desc. // Default is "desc". Direction string`url:"direction,omitempty"`// Since filters issues by time. Since time.Time`url:"since,omitempty"`ListOptions}// PullRequestLinks object is added to the Issue object when it's an issue included// in the IssueCommentEvent webhook payload, if the webhook is fired by a comment on a PR.typePullRequestLinksstruct { URL *string`json:"url,omitempty"` HTMLURL *string`json:"html_url,omitempty"` DiffURL *string`json:"diff_url,omitempty"` PatchURL *string`json:"patch_url,omitempty"` MergedAt *Timestamp`json:"merged_at,omitempty"`}// List the issues for the authenticated user. If all is true, list issues// across all the user's visible repositories including owned, member, and// organization repositories; if false, list only owned and member// repositories.//// GitHub API docs: https://docs.github.com/rest/issues/issues#list-issues-assigned-to-the-authenticated-user// GitHub API docs: https://docs.github.com/rest/issues/issues#list-user-account-issues-assigned-to-the-authenticated-user////meta:operation GET /issues//meta:operation GET /user/issuesfunc ( *IssuesService) ( context.Context, bool, *IssueListOptions) ([]*Issue, *Response, error) {varstringif { = "issues" } else { = "user/issues" }return .listIssues(, , )}// ListByOrg fetches the issues in the specified organization for the// authenticated user.//// GitHub API docs: https://docs.github.com/rest/issues/issues#list-organization-issues-assigned-to-the-authenticated-user////meta:operation GET /orgs/{org}/issuesfunc ( *IssuesService) ( context.Context, string, *IssueListOptions) ([]*Issue, *Response, error) { := fmt.Sprintf("orgs/%v/issues", )return .listIssues(, , )}func ( *IssuesService) ( context.Context, string, *IssueListOptions) ([]*Issue, *Response, error) { , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }// TODO: remove custom Accept header when this API fully launch. .Header.Set("Accept", mediaTypeReactionsPreview)var []*Issue , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// IssueListByRepoOptions specifies the optional parameters to the// IssuesService.ListByRepo method.typeIssueListByRepoOptionsstruct {// Milestone limits issues for the specified milestone. Possible values are // a milestone number, "none" for issues with no milestone, "*" for issues // with any milestone. Milestone string`url:"milestone,omitempty"`// State filters issues based on their state. Possible values are: open, // closed, all. Default is "open". State string`url:"state,omitempty"`// Assignee filters issues based on their assignee. Possible values are a // user name, "none" for issues that are not assigned, "*" for issues with // any assigned user. Assignee string`url:"assignee,omitempty"`// Creator filters issues based on their creator. Creator string`url:"creator,omitempty"`// Mentioned filters issues to those mentioned a specific user. Mentioned string`url:"mentioned,omitempty"`// Labels filters issues based on their label. Labels []string`url:"labels,omitempty,comma"`// Sort specifies how to sort issues. Possible values are: created, updated, // and comments. Default value is "created". Sort string`url:"sort,omitempty"`// Direction in which to sort issues. Possible values are: asc, desc. // Default is "desc". Direction string`url:"direction,omitempty"`// Since filters issues by time. Since time.Time`url:"since,omitempty"`ListOptions}// ListByRepo lists the issues for the specified repository.//// GitHub API docs: https://docs.github.com/rest/issues/issues#list-repository-issues////meta:operation GET /repos/{owner}/{repo}/issuesfunc ( *IssuesService) ( context.Context, string, string, *IssueListByRepoOptions) ([]*Issue, *Response, error) { := fmt.Sprintf("repos/%v/%v/issues", , ) , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }// TODO: remove custom Accept header when this API fully launches. .Header.Set("Accept", mediaTypeReactionsPreview)var []*Issue , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// Get a single issue.//// GitHub API docs: https://docs.github.com/rest/issues/issues#get-an-issue////meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}func ( *IssuesService) ( context.Context, string, string, int) (*Issue, *Response, error) { := fmt.Sprintf("repos/%v/%v/issues/%d", , , ) , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }// TODO: remove custom Accept header when this API fully launch. .Header.Set("Accept", mediaTypeReactionsPreview) := new(Issue) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// Create a new issue on the specified repository.//// GitHub API docs: https://docs.github.com/rest/issues/issues#create-an-issue////meta:operation POST /repos/{owner}/{repo}/issuesfunc ( *IssuesService) ( context.Context, string, string, *IssueRequest) (*Issue, *Response, error) { := fmt.Sprintf("repos/%v/%v/issues", , ) , := .client.NewRequest("POST", , )if != nil {returnnil, nil, } := new(Issue) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// Edit (update) an issue.//// GitHub API docs: https://docs.github.com/rest/issues/issues#update-an-issue////meta:operation PATCH /repos/{owner}/{repo}/issues/{issue_number}func ( *IssuesService) ( context.Context, string, string, int, *IssueRequest) (*Issue, *Response, error) { := fmt.Sprintf("repos/%v/%v/issues/%d", , , ) , := .client.NewRequest("PATCH", , )if != nil {returnnil, nil, } := new(Issue) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// RemoveMilestone removes a milestone from an issue.//// This is a helper method to explicitly update an issue with a `null` milestone, thereby removing it.//// GitHub API docs: https://docs.github.com/rest/issues/issues#update-an-issue////meta:operation PATCH /repos/{owner}/{repo}/issues/{issue_number}func ( *IssuesService) ( context.Context, , string, int) (*Issue, *Response, error) { := fmt.Sprintf("repos/%v/%v/issues/%v", , , ) , := .client.NewRequest("PATCH", , &struct { *Milestone`json:"milestone"` }{})if != nil {returnnil, nil, } := new(Issue) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// LockIssueOptions specifies the optional parameters to the// IssuesService.Lock method.typeLockIssueOptionsstruct {// LockReason specifies the reason to lock this issue. // Providing a lock reason can help make it clearer to contributors why an issue // was locked. Possible values are: "off-topic", "too heated", "resolved", and "spam". LockReason string`json:"lock_reason,omitempty"`}// Lock an issue's conversation.//// GitHub API docs: https://docs.github.com/rest/issues/issues#lock-an-issue////meta:operation PUT /repos/{owner}/{repo}/issues/{issue_number}/lockfunc ( *IssuesService) ( context.Context, string, string, int, *LockIssueOptions) (*Response, error) { := fmt.Sprintf("repos/%v/%v/issues/%d/lock", , , ) , := .client.NewRequest("PUT", , )if != nil {returnnil, }return .client.Do(, , nil)}// Unlock an issue's conversation.//// GitHub API docs: https://docs.github.com/rest/issues/issues#unlock-an-issue////meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/lockfunc ( *IssuesService) ( context.Context, string, string, int) (*Response, error) { := fmt.Sprintf("repos/%v/%v/issues/%d/lock", , , ) , := .client.NewRequest("DELETE", , nil)if != nil {returnnil, }return .client.Do(, , nil)}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.