summaryrefslogtreecommitdiff
path: root/vendor/github.com/google/go-github/v43/github/users_followers.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-24 17:58:01 -0600
committermo khan <mo@mokhan.ca>2025-07-24 17:58:01 -0600
commit72296119fc9755774719f8f625ad03e0e0ec457a (patch)
treeed236ddee12a20fb55b7cfecf13f62d3a000dcb5 /vendor/github.com/google/go-github/v43/github/users_followers.go
parenta920a8cfe415858bb2777371a77018599ffed23f (diff)
parenteaa1bd3b8e12934aed06413d75e7482ac58d805a (diff)
Merge branch 'the-spice-must-flow' into 'main'
Add SpiceDB Authorization See merge request gitlab-org/software-supply-chain-security/authorization/sparkled!19
Diffstat (limited to 'vendor/github.com/google/go-github/v43/github/users_followers.go')
-rw-r--r--vendor/github.com/google/go-github/v43/github/users_followers.go122
1 files changed, 122 insertions, 0 deletions
diff --git a/vendor/github.com/google/go-github/v43/github/users_followers.go b/vendor/github.com/google/go-github/v43/github/users_followers.go
new file mode 100644
index 0000000..f26392b
--- /dev/null
+++ b/vendor/github.com/google/go-github/v43/github/users_followers.go
@@ -0,0 +1,122 @@
+// 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"
+)
+
+// ListFollowers lists the followers for a user. Passing the empty string will
+// fetch followers for the authenticated user.
+//
+// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-followers-of-the-authenticated-user
+// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-followers-of-a-user
+func (s *UsersService) ListFollowers(ctx context.Context, user string, opts *ListOptions) ([]*User, *Response, error) {
+ var u string
+ if user != "" {
+ u = fmt.Sprintf("users/%v/followers", user)
+ } else {
+ u = "user/followers"
+ }
+ 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 users []*User
+ resp, err := s.client.Do(ctx, req, &users)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return users, resp, nil
+}
+
+// ListFollowing lists the people that a user is following. Passing the empty
+// string will list people the authenticated user is following.
+//
+// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-the-people-the-authenticated-user-follows
+// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-the-people-a-user-follows
+func (s *UsersService) ListFollowing(ctx context.Context, user string, opts *ListOptions) ([]*User, *Response, error) {
+ var u string
+ if user != "" {
+ u = fmt.Sprintf("users/%v/following", user)
+ } else {
+ u = "user/following"
+ }
+ 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 users []*User
+ resp, err := s.client.Do(ctx, req, &users)
+ if err != nil {
+ return nil, resp, err
+ }
+
+ return users, resp, nil
+}
+
+// IsFollowing checks if "user" is following "target". Passing the empty
+// string for "user" will check if the authenticated user is following "target".
+//
+// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#check-if-a-person-is-followed-by-the-authenticated-user
+// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#check-if-a-user-follows-another-user
+func (s *UsersService) IsFollowing(ctx context.Context, user, target string) (bool, *Response, error) {
+ var u string
+ if user != "" {
+ u = fmt.Sprintf("users/%v/following/%v", user, target)
+ } else {
+ u = fmt.Sprintf("user/following/%v", target)
+ }
+
+ req, err := s.client.NewRequest("GET", u, nil)
+ if err != nil {
+ return false, nil, err
+ }
+
+ resp, err := s.client.Do(ctx, req, nil)
+ following, err := parseBoolResponse(err)
+ return following, resp, err
+}
+
+// Follow will cause the authenticated user to follow the specified user.
+//
+// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#follow-a-user
+func (s *UsersService) Follow(ctx context.Context, user string) (*Response, error) {
+ u := fmt.Sprintf("user/following/%v", user)
+ req, err := s.client.NewRequest("PUT", u, nil)
+ if err != nil {
+ return nil, err
+ }
+
+ return s.client.Do(ctx, req, nil)
+}
+
+// Unfollow will cause the authenticated user to unfollow the specified user.
+//
+// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#unfollow-a-user
+func (s *UsersService) Unfollow(ctx context.Context, user string) (*Response, error) {
+ u := fmt.Sprintf("user/following/%v", user)
+ req, err := s.client.NewRequest("DELETE", u, nil)
+ if err != nil {
+ return nil, err
+ }
+
+ return s.client.Do(ctx, req, nil)
+}