1
2
3
4
5
6 package github
7
8 import (
9 "context"
10 "fmt"
11 )
12
13
14
15 type AdminStats struct {
16 Issues *IssueStats `json:"issues,omitempty"`
17 Hooks *HookStats `json:"hooks,omitempty"`
18 Milestones *MilestoneStats `json:"milestones,omitempty"`
19 Orgs *OrgStats `json:"orgs,omitempty"`
20 Comments *CommentStats `json:"comments,omitempty"`
21 Pages *PageStats `json:"pages,omitempty"`
22 Users *UserStats `json:"users,omitempty"`
23 Gists *GistStats `json:"gists,omitempty"`
24 Pulls *PullStats `json:"pulls,omitempty"`
25 Repos *RepoStats `json:"repos,omitempty"`
26 }
27
28 func (s AdminStats) String() string {
29 return Stringify(s)
30 }
31
32
33 type IssueStats struct {
34 TotalIssues *int `json:"total_issues,omitempty"`
35 OpenIssues *int `json:"open_issues,omitempty"`
36 ClosedIssues *int `json:"closed_issues,omitempty"`
37 }
38
39 func (s IssueStats) String() string {
40 return Stringify(s)
41 }
42
43
44 type HookStats struct {
45 TotalHooks *int `json:"total_hooks,omitempty"`
46 ActiveHooks *int `json:"active_hooks,omitempty"`
47 InactiveHooks *int `json:"inactive_hooks,omitempty"`
48 }
49
50 func (s HookStats) String() string {
51 return Stringify(s)
52 }
53
54
55 type MilestoneStats struct {
56 TotalMilestones *int `json:"total_milestones,omitempty"`
57 OpenMilestones *int `json:"open_milestones,omitempty"`
58 ClosedMilestones *int `json:"closed_milestones,omitempty"`
59 }
60
61 func (s MilestoneStats) String() string {
62 return Stringify(s)
63 }
64
65
66
67 type OrgStats struct {
68 TotalOrgs *int `json:"total_orgs,omitempty"`
69 DisabledOrgs *int `json:"disabled_orgs,omitempty"`
70 TotalTeams *int `json:"total_teams,omitempty"`
71 TotalTeamMembers *int `json:"total_team_members,omitempty"`
72 }
73
74 func (s OrgStats) String() string {
75 return Stringify(s)
76 }
77
78
79
80 type CommentStats struct {
81 TotalCommitComments *int `json:"total_commit_comments,omitempty"`
82 TotalGistComments *int `json:"total_gist_comments,omitempty"`
83 TotalIssueComments *int `json:"total_issue_comments,omitempty"`
84 TotalPullRequestComments *int `json:"total_pull_request_comments,omitempty"`
85 }
86
87 func (s CommentStats) String() string {
88 return Stringify(s)
89 }
90
91
92 type PageStats struct {
93 TotalPages *int `json:"total_pages,omitempty"`
94 }
95
96 func (s PageStats) String() string {
97 return Stringify(s)
98 }
99
100
101 type UserStats struct {
102 TotalUsers *int `json:"total_users,omitempty"`
103 AdminUsers *int `json:"admin_users,omitempty"`
104 SuspendedUsers *int `json:"suspended_users,omitempty"`
105 }
106
107 func (s UserStats) String() string {
108 return Stringify(s)
109 }
110
111
112 type GistStats struct {
113 TotalGists *int `json:"total_gists,omitempty"`
114 PrivateGists *int `json:"private_gists,omitempty"`
115 PublicGists *int `json:"public_gists,omitempty"`
116 }
117
118 func (s GistStats) String() string {
119 return Stringify(s)
120 }
121
122
123
124 type PullStats struct {
125 TotalPulls *int `json:"total_pulls,omitempty"`
126 MergedPulls *int `json:"merged_pulls,omitempty"`
127 MergablePulls *int `json:"mergeable_pulls,omitempty"`
128 UnmergablePulls *int `json:"unmergeable_pulls,omitempty"`
129 }
130
131 func (s PullStats) String() string {
132 return Stringify(s)
133 }
134
135
136
137 type RepoStats struct {
138 TotalRepos *int `json:"total_repos,omitempty"`
139 RootRepos *int `json:"root_repos,omitempty"`
140 ForkRepos *int `json:"fork_repos,omitempty"`
141 OrgRepos *int `json:"org_repos,omitempty"`
142 TotalPushes *int `json:"total_pushes,omitempty"`
143 TotalWikis *int `json:"total_wikis,omitempty"`
144 }
145
146 func (s RepoStats) String() string {
147 return Stringify(s)
148 }
149
150
151
152
153
154
155
156
157 func (s *AdminService) GetAdminStats(ctx context.Context) (*AdminStats, *Response, error) {
158 u := fmt.Sprintf("enterprise/stats/all")
159 req, err := s.client.NewRequest("GET", u, nil)
160 if err != nil {
161 return nil, nil, err
162 }
163
164 m := new(AdminStats)
165 resp, err := s.client.Do(ctx, req, m)
166 if err != nil {
167 return nil, resp, err
168 }
169
170 return m, resp, nil
171 }
172
View as plain text