1
2
3
4
5
6 package github
7
8 import (
9 "context"
10 "fmt"
11 )
12
13
14
15
16
17 type BillingService service
18
19
20 type ActionBilling struct {
21 TotalMinutesUsed int `json:"total_minutes_used"`
22 TotalPaidMinutesUsed float64 `json:"total_paid_minutes_used"`
23 IncludedMinutes int `json:"included_minutes"`
24 MinutesUsedBreakdown MinutesUsedBreakdown `json:"minutes_used_breakdown"`
25 }
26
27 type MinutesUsedBreakdown struct {
28 Ubuntu int `json:"UBUNTU"`
29 MacOS int `json:"MACOS"`
30 Windows int `json:"WINDOWS"`
31 }
32
33
34 type PackageBilling struct {
35 TotalGigabytesBandwidthUsed int `json:"total_gigabytes_bandwidth_used"`
36 TotalPaidGigabytesBandwidthUsed int `json:"total_paid_gigabytes_bandwidth_used"`
37 IncludedGigabytesBandwidth int `json:"included_gigabytes_bandwidth"`
38 }
39
40
41 type StorageBilling struct {
42 DaysLeftInBillingCycle int `json:"days_left_in_billing_cycle"`
43 EstimatedPaidStorageForMonth float64 `json:"estimated_paid_storage_for_month"`
44 EstimatedStorageForMonth int `json:"estimated_storage_for_month"`
45 }
46
47
48 type ActiveCommitters struct {
49 TotalAdvancedSecurityCommitters int `json:"total_advanced_security_committers"`
50 Repositories []*RepositoryActiveCommitters `json:"repositories,omitempty"`
51 }
52
53
54 type RepositoryActiveCommitters struct {
55 Name *string `json:"name,omitempty"`
56 AdvancedSecurityCommitters *int `json:"advanced_security_committers,omitempty"`
57 AdvancedSecurityCommittersBreakdown []*AdvancedSecurityCommittersBreakdown `json:"advanced_security_committers_breakdown,omitempty"`
58 }
59
60
61 type AdvancedSecurityCommittersBreakdown struct {
62 UserLogin *string `json:"user_login,omitempty"`
63 LastPushedDate *string `json:"last_pushed_date,omitempty"`
64 }
65
66
67
68
69 func (s *BillingService) GetActionsBillingOrg(ctx context.Context, org string) (*ActionBilling, *Response, error) {
70 u := fmt.Sprintf("orgs/%v/settings/billing/actions", org)
71 req, err := s.client.NewRequest("GET", u, nil)
72 if err != nil {
73 return nil, nil, err
74 }
75
76 actionsOrgBilling := new(ActionBilling)
77 resp, err := s.client.Do(ctx, req, actionsOrgBilling)
78 if err != nil {
79 return nil, resp, err
80 }
81
82 return actionsOrgBilling, resp, nil
83 }
84
85
86
87
88 func (s *BillingService) GetPackagesBillingOrg(ctx context.Context, org string) (*PackageBilling, *Response, error) {
89 u := fmt.Sprintf("orgs/%v/settings/billing/packages", org)
90 req, err := s.client.NewRequest("GET", u, nil)
91 if err != nil {
92 return nil, nil, err
93 }
94
95 packagesOrgBilling := new(PackageBilling)
96 resp, err := s.client.Do(ctx, req, packagesOrgBilling)
97 if err != nil {
98 return nil, resp, err
99 }
100
101 return packagesOrgBilling, resp, nil
102 }
103
104
105
106
107
108 func (s *BillingService) GetStorageBillingOrg(ctx context.Context, org string) (*StorageBilling, *Response, error) {
109 u := fmt.Sprintf("orgs/%v/settings/billing/shared-storage", org)
110 req, err := s.client.NewRequest("GET", u, nil)
111 if err != nil {
112 return nil, nil, err
113 }
114
115 storageOrgBilling := new(StorageBilling)
116 resp, err := s.client.Do(ctx, req, storageOrgBilling)
117 if err != nil {
118 return nil, resp, err
119 }
120
121 return storageOrgBilling, resp, nil
122 }
123
124
125
126
127 func (s *BillingService) GetAdvancedSecurityActiveCommittersOrg(ctx context.Context, org string) (*ActiveCommitters, *Response, error) {
128 u := fmt.Sprintf("orgs/%v/settings/billing/advanced-security", org)
129 req, err := s.client.NewRequest("GET", u, nil)
130 if err != nil {
131 return nil, nil, err
132 }
133
134 activeOrgCommitters := new(ActiveCommitters)
135 resp, err := s.client.Do(ctx, req, activeOrgCommitters)
136 if err != nil {
137 return nil, resp, err
138 }
139
140 return activeOrgCommitters, resp, nil
141 }
142
143
144
145
146 func (s *BillingService) GetActionsBillingUser(ctx context.Context, user string) (*ActionBilling, *Response, error) {
147 u := fmt.Sprintf("users/%v/settings/billing/actions", user)
148 req, err := s.client.NewRequest("GET", u, nil)
149 if err != nil {
150 return nil, nil, err
151 }
152
153 actionsUserBilling := new(ActionBilling)
154 resp, err := s.client.Do(ctx, req, actionsUserBilling)
155 if err != nil {
156 return nil, resp, err
157 }
158
159 return actionsUserBilling, resp, nil
160 }
161
162
163
164
165 func (s *BillingService) GetPackagesBillingUser(ctx context.Context, user string) (*PackageBilling, *Response, error) {
166 u := fmt.Sprintf("users/%v/settings/billing/packages", user)
167 req, err := s.client.NewRequest("GET", u, nil)
168 if err != nil {
169 return nil, nil, err
170 }
171
172 packagesUserBilling := new(PackageBilling)
173 resp, err := s.client.Do(ctx, req, packagesUserBilling)
174 if err != nil {
175 return nil, resp, err
176 }
177
178 return packagesUserBilling, resp, nil
179 }
180
181
182
183
184
185 func (s *BillingService) GetStorageBillingUser(ctx context.Context, user string) (*StorageBilling, *Response, error) {
186 u := fmt.Sprintf("users/%v/settings/billing/shared-storage", user)
187 req, err := s.client.NewRequest("GET", u, nil)
188 if err != nil {
189 return nil, nil, err
190 }
191
192 storageUserBilling := new(StorageBilling)
193 resp, err := s.client.Do(ctx, req, storageUserBilling)
194 if err != nil {
195 return nil, resp, err
196 }
197
198 return storageUserBilling, resp, nil
199 }
200
View as plain text