Files
.examples
.github
alerting
client
config
controller
core
docs
jsonpath
metrics
pattern
security
storage
test
util
vendor
github.com
TwiN
beorn7
cespare
coreos
davecgh
go-ping
golang
google
go-github
v48
github
actions.go
actions_artifacts.go
actions_runner_groups.go
actions_runners.go
actions_secrets.go
actions_workflow_jobs.go
actions_workflow_runs.go
actions_workflows.go
activity.go
activity_events.go
activity_notifications.go
activity_star.go
activity_watching.go
admin.go
admin_orgs.go
admin_stats.go
admin_users.go
apps.go
apps_hooks.go
apps_hooks_deliveries.go
apps_installation.go
apps_manifest.go
apps_marketplace.go
authorizations.go
billing.go
checks.go
code-scanning.go
dependabot.go
dependabot_alerts.go
dependabot_secrets.go
doc.go
enterprise.go
enterprise_actions_runners.go
enterprise_audit_log.go
event.go
event_types.go
gists.go
gists_comments.go
git.go
git_blobs.go
git_commits.go
git_refs.go
git_tags.go
git_trees.go
github-accessors.go
github.go
gitignore.go
interactions.go
interactions_orgs.go
interactions_repos.go
issue_import.go
issues.go
issues_assignees.go
issues_comments.go
issues_events.go
issues_labels.go
issues_milestones.go
issues_timeline.go
licenses.go
messages.go
migrations.go
migrations_source_import.go
migrations_user.go
misc.go
orgs.go
orgs_actions_allowed.go
orgs_actions_permissions.go
orgs_audit_log.go
orgs_custom_roles.go
orgs_hooks.go
orgs_hooks_deliveries.go
orgs_members.go
orgs_outside_collaborators.go
orgs_packages.go
orgs_projects.go
orgs_security_managers.go
orgs_users_blocking.go
packages.go
projects.go
pulls.go
pulls_comments.go
pulls_reviewers.go
pulls_reviews.go
pulls_threads.go
reactions.go
repos.go
repos_actions_access.go
repos_actions_allowed.go
repos_actions_permissions.go
repos_autolinks.go
repos_codeowners.go
repos_collaborators.go
repos_comments.go
repos_commits.go
repos_community_health.go
repos_contents.go
repos_deployments.go
repos_environments.go
repos_forks.go
repos_hooks.go
repos_hooks_deliveries.go
repos_invitations.go
repos_keys.go
repos_lfs.go
repos_merging.go
repos_pages.go
repos_prereceive_hooks.go
repos_projects.go
repos_releases.go
repos_stats.go
repos_statuses.go
repos_tags.go
repos_traffic.go
scim.go
search.go
secret_scanning.go
strings.go
teams.go
teams_discussion_comments.go
teams_discussions.go
teams_members.go
timestamp.go
users.go
users_administration.go
users_blocking.go
users_emails.go
users_followers.go
users_gpg_keys.go
users_keys.go
users_packages.go
users_projects.go
users_ssh_signing_keys.go
with_appengine.go
without_appengine.go
AUTHORS
LICENSE
go-querystring
uuid
gorilla
ishidawataru
kballard
lib
mattn
matttproud
miekg
prometheus
remyoudompheng
wcharczuk
golang.org
google.golang.org
gopkg.in
lukechampine.com
modernc.org
modules.txt
watchdog
web
.dockerignore
.gitattributes
.gitignore
Dockerfile
LICENSE
Makefile
README.md
config.yaml
go.mod
go.sum
main.go
gatus/vendor/github.com/google/go-github/v48/github/issues_assignees.go

96 lines
2.8 KiB
Go

// 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 github
import (
"context"
"fmt"
)
// ListAssignees fetches all available assignees (owners and collaborators) to
// which issues may be assigned.
//
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#list-assignees
func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/assignees", owner, repo)
u, err := addOptions(u, opts)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var assignees []*User
resp, err := s.client.Do(ctx, req, &assignees)
if err != nil {
return nil, resp, err
}
return assignees, resp, nil
}
// IsAssignee checks if a user is an assignee for the specified repository.
//
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#check-if-a-user-can-be-assigned
func (s *IssuesService) IsAssignee(ctx context.Context, owner, repo, user string) (bool, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return false, nil, err
}
resp, err := s.client.Do(ctx, req, nil)
assignee, err := parseBoolResponse(err)
return assignee, resp, err
}
// AddAssignees adds the provided GitHub users as assignees to the issue.
//
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#add-assignees-to-an-issue
func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) {
users := &struct {
Assignees []string `json:"assignees,omitempty"`
}{Assignees: assignees}
u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number)
req, err := s.client.NewRequest("POST", u, users)
if err != nil {
return nil, nil, err
}
issue := &Issue{}
resp, err := s.client.Do(ctx, req, issue)
if err != nil {
return nil, resp, err
}
return issue, resp, nil
}
// RemoveAssignees removes the provided GitHub users as assignees from the issue.
//
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#remove-assignees-from-an-issue
func (s *IssuesService) RemoveAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) {
users := &struct {
Assignees []string `json:"assignees,omitempty"`
}{Assignees: assignees}
u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number)
req, err := s.client.NewRequest("DELETE", u, users)
if err != nil {
return nil, nil, err
}
issue := &Issue{}
resp, err := s.client.Do(ctx, req, issue)
if err != nil {
return nil, resp, err
}
return issue, resp, nil
}