1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 package abusiveexperiencereport
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "net/http"
61 "net/url"
62 "strconv"
63 "strings"
64
65 googleapi "google.golang.org/api/googleapi"
66 internal "google.golang.org/api/internal"
67 gensupport "google.golang.org/api/internal/gensupport"
68 option "google.golang.org/api/option"
69 internaloption "google.golang.org/api/option/internaloption"
70 htransport "google.golang.org/api/transport/http"
71 )
72
73
74
75 var _ = bytes.NewBuffer
76 var _ = strconv.Itoa
77 var _ = fmt.Sprintf
78 var _ = json.NewDecoder
79 var _ = io.Copy
80 var _ = url.Parse
81 var _ = gensupport.MarshalJSON
82 var _ = googleapi.Version
83 var _ = errors.New
84 var _ = strings.Replace
85 var _ = context.Canceled
86 var _ = internaloption.WithDefaultEndpoint
87 var _ = internal.Version
88
89 const apiId = "abusiveexperiencereport:v1"
90 const apiName = "abusiveexperiencereport"
91 const apiVersion = "v1"
92 const basePath = "https://abusiveexperiencereport.googleapis.com/"
93 const basePathTemplate = "https://abusiveexperiencereport.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://abusiveexperiencereport.mtls.googleapis.com/"
95
96
97 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
98 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
99 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
100 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
101 opts = append(opts, internaloption.EnableNewAuthLibrary())
102 client, endpoint, err := htransport.NewClient(ctx, opts...)
103 if err != nil {
104 return nil, err
105 }
106 s, err := New(client)
107 if err != nil {
108 return nil, err
109 }
110 if endpoint != "" {
111 s.BasePath = endpoint
112 }
113 return s, nil
114 }
115
116
117
118
119
120
121 func New(client *http.Client) (*Service, error) {
122 if client == nil {
123 return nil, errors.New("client is nil")
124 }
125 s := &Service{client: client, BasePath: basePath}
126 s.Sites = NewSitesService(s)
127 s.ViolatingSites = NewViolatingSitesService(s)
128 return s, nil
129 }
130
131 type Service struct {
132 client *http.Client
133 BasePath string
134 UserAgent string
135
136 Sites *SitesService
137
138 ViolatingSites *ViolatingSitesService
139 }
140
141 func (s *Service) userAgent() string {
142 if s.UserAgent == "" {
143 return googleapi.UserAgent
144 }
145 return googleapi.UserAgent + " " + s.UserAgent
146 }
147
148 func NewSitesService(s *Service) *SitesService {
149 rs := &SitesService{s: s}
150 return rs
151 }
152
153 type SitesService struct {
154 s *Service
155 }
156
157 func NewViolatingSitesService(s *Service) *ViolatingSitesService {
158 rs := &ViolatingSitesService{s: s}
159 return rs
160 }
161
162 type ViolatingSitesService struct {
163 s *Service
164 }
165
166
167 type SiteSummaryResponse struct {
168
169
170
171
172
173
174 AbusiveStatus string `json:"abusiveStatus,omitempty"`
175
176
177
178 EnforcementTime string `json:"enforcementTime,omitempty"`
179
180
181
182
183
184
185
186
187
188 FilterStatus string `json:"filterStatus,omitempty"`
189
190 LastChangeTime string `json:"lastChangeTime,omitempty"`
191
192
193
194
195
196 ReportUrl string `json:"reportUrl,omitempty"`
197
198 ReviewedSite string `json:"reviewedSite,omitempty"`
199
200 UnderReview bool `json:"underReview,omitempty"`
201
202
203 googleapi.ServerResponse `json:"-"`
204
205
206
207
208
209 ForceSendFields []string `json:"-"`
210
211
212
213
214 NullFields []string `json:"-"`
215 }
216
217 func (s *SiteSummaryResponse) MarshalJSON() ([]byte, error) {
218 type NoMethod SiteSummaryResponse
219 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
220 }
221
222
223 type ViolatingSitesResponse struct {
224
225 ViolatingSites []*SiteSummaryResponse `json:"violatingSites,omitempty"`
226
227
228 googleapi.ServerResponse `json:"-"`
229
230
231
232
233
234 ForceSendFields []string `json:"-"`
235
236
237
238
239 NullFields []string `json:"-"`
240 }
241
242 func (s *ViolatingSitesResponse) MarshalJSON() ([]byte, error) {
243 type NoMethod ViolatingSitesResponse
244 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
245 }
246
247 type SitesGetCall struct {
248 s *Service
249 name string
250 urlParams_ gensupport.URLParams
251 ifNoneMatch_ string
252 ctx_ context.Context
253 header_ http.Header
254 }
255
256
257
258
259
260 func (r *SitesService) Get(name string) *SitesGetCall {
261 c := &SitesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
262 c.name = name
263 return c
264 }
265
266
267
268
269 func (c *SitesGetCall) Fields(s ...googleapi.Field) *SitesGetCall {
270 c.urlParams_.Set("fields", googleapi.CombineFields(s))
271 return c
272 }
273
274
275
276
277 func (c *SitesGetCall) IfNoneMatch(entityTag string) *SitesGetCall {
278 c.ifNoneMatch_ = entityTag
279 return c
280 }
281
282
283 func (c *SitesGetCall) Context(ctx context.Context) *SitesGetCall {
284 c.ctx_ = ctx
285 return c
286 }
287
288
289
290 func (c *SitesGetCall) Header() http.Header {
291 if c.header_ == nil {
292 c.header_ = make(http.Header)
293 }
294 return c.header_
295 }
296
297 func (c *SitesGetCall) doRequest(alt string) (*http.Response, error) {
298 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
299 if c.ifNoneMatch_ != "" {
300 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
301 }
302 var body io.Reader = nil
303 c.urlParams_.Set("alt", alt)
304 c.urlParams_.Set("prettyPrint", "false")
305 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
306 urls += "?" + c.urlParams_.Encode()
307 req, err := http.NewRequest("GET", urls, body)
308 if err != nil {
309 return nil, err
310 }
311 req.Header = reqHeaders
312 googleapi.Expand(req.URL, map[string]string{
313 "name": c.name,
314 })
315 return gensupport.SendRequest(c.ctx_, c.s.client, req)
316 }
317
318
319
320
321
322
323
324 func (c *SitesGetCall) Do(opts ...googleapi.CallOption) (*SiteSummaryResponse, error) {
325 gensupport.SetOptions(c.urlParams_, opts...)
326 res, err := c.doRequest("json")
327 if res != nil && res.StatusCode == http.StatusNotModified {
328 if res.Body != nil {
329 res.Body.Close()
330 }
331 return nil, gensupport.WrapError(&googleapi.Error{
332 Code: res.StatusCode,
333 Header: res.Header,
334 })
335 }
336 if err != nil {
337 return nil, err
338 }
339 defer googleapi.CloseBody(res)
340 if err := googleapi.CheckResponse(res); err != nil {
341 return nil, gensupport.WrapError(err)
342 }
343 ret := &SiteSummaryResponse{
344 ServerResponse: googleapi.ServerResponse{
345 Header: res.Header,
346 HTTPStatusCode: res.StatusCode,
347 },
348 }
349 target := &ret
350 if err := gensupport.DecodeResponse(target, res); err != nil {
351 return nil, err
352 }
353 return ret, nil
354 }
355
356 type ViolatingSitesListCall struct {
357 s *Service
358 urlParams_ gensupport.URLParams
359 ifNoneMatch_ string
360 ctx_ context.Context
361 header_ http.Header
362 }
363
364
365 func (r *ViolatingSitesService) List() *ViolatingSitesListCall {
366 c := &ViolatingSitesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
367 return c
368 }
369
370
371
372
373 func (c *ViolatingSitesListCall) Fields(s ...googleapi.Field) *ViolatingSitesListCall {
374 c.urlParams_.Set("fields", googleapi.CombineFields(s))
375 return c
376 }
377
378
379
380
381 func (c *ViolatingSitesListCall) IfNoneMatch(entityTag string) *ViolatingSitesListCall {
382 c.ifNoneMatch_ = entityTag
383 return c
384 }
385
386
387 func (c *ViolatingSitesListCall) Context(ctx context.Context) *ViolatingSitesListCall {
388 c.ctx_ = ctx
389 return c
390 }
391
392
393
394 func (c *ViolatingSitesListCall) Header() http.Header {
395 if c.header_ == nil {
396 c.header_ = make(http.Header)
397 }
398 return c.header_
399 }
400
401 func (c *ViolatingSitesListCall) doRequest(alt string) (*http.Response, error) {
402 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
403 if c.ifNoneMatch_ != "" {
404 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
405 }
406 var body io.Reader = nil
407 c.urlParams_.Set("alt", alt)
408 c.urlParams_.Set("prettyPrint", "false")
409 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/violatingSites")
410 urls += "?" + c.urlParams_.Encode()
411 req, err := http.NewRequest("GET", urls, body)
412 if err != nil {
413 return nil, err
414 }
415 req.Header = reqHeaders
416 return gensupport.SendRequest(c.ctx_, c.s.client, req)
417 }
418
419
420
421
422
423
424
425 func (c *ViolatingSitesListCall) Do(opts ...googleapi.CallOption) (*ViolatingSitesResponse, error) {
426 gensupport.SetOptions(c.urlParams_, opts...)
427 res, err := c.doRequest("json")
428 if res != nil && res.StatusCode == http.StatusNotModified {
429 if res.Body != nil {
430 res.Body.Close()
431 }
432 return nil, gensupport.WrapError(&googleapi.Error{
433 Code: res.StatusCode,
434 Header: res.Header,
435 })
436 }
437 if err != nil {
438 return nil, err
439 }
440 defer googleapi.CloseBody(res)
441 if err := googleapi.CheckResponse(res); err != nil {
442 return nil, gensupport.WrapError(err)
443 }
444 ret := &ViolatingSitesResponse{
445 ServerResponse: googleapi.ServerResponse{
446 Header: res.Header,
447 HTTPStatusCode: res.StatusCode,
448 },
449 }
450 target := &ret
451 if err := gensupport.DecodeResponse(target, res); err != nil {
452 return nil, err
453 }
454 return ret, nil
455 }
456
View as plain text