"Fossies" - the Fresh Open Source Software Archive

Member "cri-o-1.25.1/vendor/github.com/google/go-github/v42/github/activity_events.go" (7 Oct 2022, 6421 Bytes) of package /linux/misc/cri-o-1.25.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Go source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Copyright 2013 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 // ListEvents drinks from the firehose of all public events across GitHub.
   14 //
   15 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events
   16 func (s *ActivityService) ListEvents(ctx context.Context, opts *ListOptions) ([]*Event, *Response, error) {
   17     u, err := addOptions("events", opts)
   18     if err != nil {
   19         return nil, nil, err
   20     }
   21 
   22     req, err := s.client.NewRequest("GET", u, nil)
   23     if err != nil {
   24         return nil, nil, err
   25     }
   26 
   27     var events []*Event
   28     resp, err := s.client.Do(ctx, req, &events)
   29     if err != nil {
   30         return nil, resp, err
   31     }
   32 
   33     return events, resp, nil
   34 }
   35 
   36 // ListRepositoryEvents lists events for a repository.
   37 //
   38 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repository-events
   39 func (s *ActivityService) ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) {
   40     u := fmt.Sprintf("repos/%v/%v/events", owner, repo)
   41     u, err := addOptions(u, opts)
   42     if err != nil {
   43         return nil, nil, err
   44     }
   45 
   46     req, err := s.client.NewRequest("GET", u, nil)
   47     if err != nil {
   48         return nil, nil, err
   49     }
   50 
   51     var events []*Event
   52     resp, err := s.client.Do(ctx, req, &events)
   53     if err != nil {
   54         return nil, resp, err
   55     }
   56 
   57     return events, resp, nil
   58 }
   59 
   60 // ListIssueEventsForRepository lists issue events for a repository.
   61 //
   62 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issue-events-for-a-repository
   63 func (s *ActivityService) ListIssueEventsForRepository(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) {
   64     u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
   65     u, err := addOptions(u, opts)
   66     if err != nil {
   67         return nil, nil, err
   68     }
   69 
   70     req, err := s.client.NewRequest("GET", u, nil)
   71     if err != nil {
   72         return nil, nil, err
   73     }
   74 
   75     var events []*IssueEvent
   76     resp, err := s.client.Do(ctx, req, &events)
   77     if err != nil {
   78         return nil, resp, err
   79     }
   80 
   81     return events, resp, nil
   82 }
   83 
   84 // ListEventsForRepoNetwork lists public events for a network of repositories.
   85 //
   86 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events-for-a-network-of-repositories
   87 func (s *ActivityService) ListEventsForRepoNetwork(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) {
   88     u := fmt.Sprintf("networks/%v/%v/events", owner, repo)
   89     u, err := addOptions(u, opts)
   90     if err != nil {
   91         return nil, nil, err
   92     }
   93 
   94     req, err := s.client.NewRequest("GET", u, nil)
   95     if err != nil {
   96         return nil, nil, err
   97     }
   98 
   99     var events []*Event
  100     resp, err := s.client.Do(ctx, req, &events)
  101     if err != nil {
  102         return nil, resp, err
  103     }
  104 
  105     return events, resp, nil
  106 }
  107 
  108 // ListEventsForOrganization lists public events for an organization.
  109 //
  110 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-organization-events
  111 func (s *ActivityService) ListEventsForOrganization(ctx context.Context, org string, opts *ListOptions) ([]*Event, *Response, error) {
  112     u := fmt.Sprintf("orgs/%v/events", org)
  113     u, err := addOptions(u, opts)
  114     if err != nil {
  115         return nil, nil, err
  116     }
  117 
  118     req, err := s.client.NewRequest("GET", u, nil)
  119     if err != nil {
  120         return nil, nil, err
  121     }
  122 
  123     var events []*Event
  124     resp, err := s.client.Do(ctx, req, &events)
  125     if err != nil {
  126         return nil, resp, err
  127     }
  128 
  129     return events, resp, nil
  130 }
  131 
  132 // ListEventsPerformedByUser lists the events performed by a user. If publicOnly is
  133 // true, only public events will be returned.
  134 //
  135 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-events-for-the-authenticated-user
  136 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events-for-a-user
  137 func (s *ActivityService) ListEventsPerformedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) {
  138     var u string
  139     if publicOnly {
  140         u = fmt.Sprintf("users/%v/events/public", user)
  141     } else {
  142         u = fmt.Sprintf("users/%v/events", user)
  143     }
  144     u, err := addOptions(u, opts)
  145     if err != nil {
  146         return nil, nil, err
  147     }
  148 
  149     req, err := s.client.NewRequest("GET", u, nil)
  150     if err != nil {
  151         return nil, nil, err
  152     }
  153 
  154     var events []*Event
  155     resp, err := s.client.Do(ctx, req, &events)
  156     if err != nil {
  157         return nil, resp, err
  158     }
  159 
  160     return events, resp, nil
  161 }
  162 
  163 // ListEventsReceivedByUser lists the events received by a user. If publicOnly is
  164 // true, only public events will be returned.
  165 //
  166 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-events-received-by-the-authenticated-user
  167 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events-received-by-a-user
  168 func (s *ActivityService) ListEventsReceivedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) {
  169     var u string
  170     if publicOnly {
  171         u = fmt.Sprintf("users/%v/received_events/public", user)
  172     } else {
  173         u = fmt.Sprintf("users/%v/received_events", user)
  174     }
  175     u, err := addOptions(u, opts)
  176     if err != nil {
  177         return nil, nil, err
  178     }
  179 
  180     req, err := s.client.NewRequest("GET", u, nil)
  181     if err != nil {
  182         return nil, nil, err
  183     }
  184 
  185     var events []*Event
  186     resp, err := s.client.Do(ctx, req, &events)
  187     if err != nil {
  188         return nil, resp, err
  189     }
  190 
  191     return events, resp, nil
  192 }
  193 
  194 // ListUserEventsForOrganization provides the user’s organization dashboard. You
  195 // must be authenticated as the user to view this.
  196 //
  197 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-organization-events-for-the-authenticated-user
  198 func (s *ActivityService) ListUserEventsForOrganization(ctx context.Context, org, user string, opts *ListOptions) ([]*Event, *Response, error) {
  199     u := fmt.Sprintf("users/%v/events/orgs/%v", user, org)
  200     u, err := addOptions(u, opts)
  201     if err != nil {
  202         return nil, nil, err
  203     }
  204 
  205     req, err := s.client.NewRequest("GET", u, nil)
  206     if err != nil {
  207         return nil, nil, err
  208     }
  209 
  210     var events []*Event
  211     resp, err := s.client.Do(ctx, req, &events)
  212     if err != nil {
  213         return nil, resp, err
  214     }
  215 
  216     return events, resp, nil
  217 }