Debian Codegraph @

adexperiencereport/v1/adexperiencereport-gen.go

raw
1 // Copyright 2026 Google LLC.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Code generated file. DO NOT EDIT.
6
7 // Package adexperiencereport provides access to the Ad Experience Report API.
8 //
9 // For product documentation, see: https://developers.google.com/ad-experience-report/
10 //
11 // # Library status
12 //
13 // These client libraries are officially supported by Google. However, this
14 // library is considered complete and is in maintenance mode. This means
15 // that we will address critical bugs and security issues but will not add
16 // any new features.
17 //
18 // When possible, we recommend using our newer
19 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
20 // that are still actively being worked and iterated on.
21 //
22 // # Creating a client
23 //
24 // Usage example:
25 //
26 // import "google.golang.org/api/adexperiencereport/v1"
27 // ...
28 // ctx := context.Background()
29 // adexperiencereportService, err := adexperiencereport.NewService(ctx)
30 //
31 // In this example, Google Application Default Credentials are used for
32 // authentication. For information on how to create and obtain Application
33 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
34 //
35 // # Other authentication options
36 //
37 // To use an API key for authentication (note: some APIs do not support API
38 // keys), use [google.golang.org/api/option.WithAPIKey]:
39 //
40 // adexperiencereportService, err := adexperiencereport.NewService(ctx, option.WithAPIKey("AIza..."))
41 //
42 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
43 // flow, use [google.golang.org/api/option.WithTokenSource]:
44 //
45 // config := &oauth2.Config{...}
46 // // ...
47 // token, err := config.Exchange(ctx, ...)
48 // adexperiencereportService, err := adexperiencereport.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
49 //
50 // See [google.golang.org/api/option.ClientOption] for details on options.
51 package adexperiencereport // import "google.golang.org/api/adexperiencereport/v1"
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "log/slog"
61 "net/http"
62 "net/url"
63 "strconv"
64 "strings"
65
66 "github.com/googleapis/gax-go/v2/internallog"
67 googleapi "google.golang.org/api/googleapi"
68 internal "google.golang.org/api/internal"
69 gensupport "google.golang.org/api/internal/gensupport"
70 option "google.golang.org/api/option"
71 internaloption "google.golang.org/api/option/internaloption"
72 htransport "google.golang.org/api/transport/http"
73 )
74
75 // Always reference these packages, just in case the auto-generated code
76 // below doesn't.
77 var _ = bytes.NewBuffer
78 var _ = strconv.Itoa
79 var _ = fmt.Sprintf
80 var _ = json.NewDecoder
81 var _ = io.Copy
82 var _ = url.Parse
83 var _ = gensupport.MarshalJSON
84 var _ = googleapi.Version
85 var _ = errors.New
86 var _ = strings.Replace
87 var _ = context.Canceled
88 var _ = internaloption.WithDefaultEndpoint
89 var _ = internal.Version
90 var _ = internallog.New
91
92 const apiId = "adexperiencereport:v1"
93 const apiName = "adexperiencereport"
94 const apiVersion = "v1"
95 const basePath = "https://adexperiencereport.googleapis.com/"
96 const basePathTemplate = "https://adexperiencereport.UNIVERSE_DOMAIN/"
97 const mtlsBasePath = "https://adexperiencereport.mtls.googleapis.com/"
98
99 // NewService creates a new Service.
100 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
101 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
102 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
103 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
104 opts = append(opts, internaloption.EnableNewAuthLibrary())
105 client, endpoint, err := htransport.NewClient(ctx, opts...)
106 if err != nil {
107 return nil, err
108 }
109 s := &Service{client: client, BasePath: basePath, logger: internaloption.GetLogger(opts)}
110 s.Sites = NewSitesService(s)
111 s.ViolatingSites = NewViolatingSitesService(s)
112 if endpoint != "" {
113 s.BasePath = endpoint
114 }
115 return s, nil
116 }
117
118 // New creates a new Service. It uses the provided http.Client for requests.
119 //
120 // Deprecated: please use NewService instead.
121 // To provide a custom HTTP client, use option.WithHTTPClient.
122 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
123 func New(client *http.Client) (*Service, error) {
124 if client == nil {
125 return nil, errors.New("client is nil")
126 }
127 return NewService(context.TODO(), option.WithHTTPClient(client))
128 }
129
130 type Service struct {
131 client *http.Client
132 logger *slog.Logger
133 BasePath string // API endpoint base URL
134 UserAgent string // optional additional User-Agent fragment
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 // PlatformSummary: A site's Ad Experience Report summary on a single platform.
167 type PlatformSummary struct {
168 // BetterAdsStatus: The site's Ad Experience Report status on this platform.
169 //
170 // Possible values:
171 // "UNKNOWN" - Not reviewed.
172 // "PASSING" - Passing.
173 // "WARNING" - Warning. No longer a possible status.
174 // "FAILING" - Failing.
175 BetterAdsStatus string `json:"betterAdsStatus,omitempty"`
176 // EnforcementTime: The time at which enforcement
177 // (https://support.google.com/webtools/answer/7308033) against the site began
178 // or will begin on this platform. Not set when the filter_status is OFF.
179 EnforcementTime string `json:"enforcementTime,omitempty"`
180 // FilterStatus: The site's enforcement status
181 // (https://support.google.com/webtools/answer/7308033) on this platform.
182 //
183 // Possible values:
184 // "UNKNOWN" - N/A.
185 // "ON" - Ad filtering is on.
186 // "OFF" - Ad filtering is off.
187 // "PAUSED" - Ad filtering is paused.
188 // "PENDING" - Ad filtering is pending.
189 FilterStatus string `json:"filterStatus,omitempty"`
190 // LastChangeTime: The time at which the site's status last changed on this
191 // platform.
192 LastChangeTime string `json:"lastChangeTime,omitempty"`
193 // Region: The site's regions on this platform. No longer populated, because
194 // there is no longer any semantic difference between sites in different
195 // regions.
196 //
197 // Possible values:
198 // "REGION_UNKNOWN" - Ad standard not yet defined for your region.
199 // "REGION_A" - Region A.
200 // "REGION_B" - Region B.
201 // "REGION_C" - Region C.
202 Region []string `json:"region,omitempty"`
203 // ReportUrl: A link to the full Ad Experience Report for the site on this
204 // platform.. Not set in ViolatingSitesResponse. Note that you must complete
205 // the Search Console verification process
206 // (https://support.google.com/webmasters/answer/9008080) for the site before
207 // you can access the full report.
208 ReportUrl string `json:"reportUrl,omitempty"`
209 // UnderReview: Whether the site is currently under review on this platform.
210 UnderReview bool `json:"underReview,omitempty"`
211 // ForceSendFields is a list of field names (e.g. "BetterAdsStatus") to
212 // unconditionally include in API requests. By default, fields with empty or
213 // default values are omitted from API requests. See
214 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
215 // details.
216 ForceSendFields []string `json:"-"`
217 // NullFields is a list of field names (e.g. "BetterAdsStatus") to include in
218 // API requests with the JSON null value. By default, fields with empty values
219 // are omitted from API requests. See
220 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
221 NullFields []string `json:"-"`
222 }
223
224 func (s PlatformSummary) MarshalJSON() ([]byte, error) {
225 type NoMethod PlatformSummary
226 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
227 }
228
229 // SiteSummaryResponse: Response message for GetSiteSummary.
230 type SiteSummaryResponse struct {
231 // DesktopSummary: The site's Ad Experience Report summary on desktop.
232 DesktopSummary *PlatformSummary `json:"desktopSummary,omitempty"`
233 // MobileSummary: The site's Ad Experience Report summary on mobile.
234 MobileSummary *PlatformSummary `json:"mobileSummary,omitempty"`
235 // ReviewedSite: The name of the reviewed site, e.g. `google.com`.
236 ReviewedSite string `json:"reviewedSite,omitempty"`
237
238 // ServerResponse contains the HTTP response code and headers from the server.
239 googleapi.ServerResponse `json:"-"`
240 // ForceSendFields is a list of field names (e.g. "DesktopSummary") to
241 // unconditionally include in API requests. By default, fields with empty or
242 // default values are omitted from API requests. See
243 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
244 // details.
245 ForceSendFields []string `json:"-"`
246 // NullFields is a list of field names (e.g. "DesktopSummary") to include in
247 // API requests with the JSON null value. By default, fields with empty values
248 // are omitted from API requests. See
249 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
250 NullFields []string `json:"-"`
251 }
252
253 func (s SiteSummaryResponse) MarshalJSON() ([]byte, error) {
254 type NoMethod SiteSummaryResponse
255 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
256 }
257
258 // ViolatingSitesResponse: Response message for ListViolatingSites.
259 type ViolatingSitesResponse struct {
260 // ViolatingSites: The list of violating sites.
261 ViolatingSites []*SiteSummaryResponse `json:"violatingSites,omitempty"`
262
263 // ServerResponse contains the HTTP response code and headers from the server.
264 googleapi.ServerResponse `json:"-"`
265 // ForceSendFields is a list of field names (e.g. "ViolatingSites") to
266 // unconditionally include in API requests. By default, fields with empty or
267 // default values are omitted from API requests. See
268 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
269 // details.
270 ForceSendFields []string `json:"-"`
271 // NullFields is a list of field names (e.g. "ViolatingSites") to include in
272 // API requests with the JSON null value. By default, fields with empty values
273 // are omitted from API requests. See
274 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
275 NullFields []string `json:"-"`
276 }
277
278 func (s ViolatingSitesResponse) MarshalJSON() ([]byte, error) {
279 type NoMethod ViolatingSitesResponse
280 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
281 }
282
283 type SitesGetCall struct {
284 s *Service
285 name string
286 urlParams_ gensupport.URLParams
287 ifNoneMatch_ string
288 ctx_ context.Context
289 header_ http.Header
290 }
291
292 // Get: Gets a site's Ad Experience Report summary.
293 //
294 // - name: The name of the site whose summary to get, e.g.
295 // `sites/http%3A%2F%2Fwww.google.com%2F`. Format: `sites/{site}`.
296 func (r *SitesService) Get(name string) *SitesGetCall {
297 c := &SitesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
298 c.name = name
299 return c
300 }
301
302 // Fields allows partial responses to be retrieved. See
303 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
304 // details.
305 func (c *SitesGetCall) Fields(s ...googleapi.Field) *SitesGetCall {
306 c.urlParams_.Set("fields", googleapi.CombineFields(s))
307 return c
308 }
309
310 // IfNoneMatch sets an optional parameter which makes the operation fail if the
311 // object's ETag matches the given value. This is useful for getting updates
312 // only after the object has changed since the last request.
313 func (c *SitesGetCall) IfNoneMatch(entityTag string) *SitesGetCall {
314 c.ifNoneMatch_ = entityTag
315 return c
316 }
317
318 // Context sets the context to be used in this call's Do method.
319 func (c *SitesGetCall) Context(ctx context.Context) *SitesGetCall {
320 c.ctx_ = ctx
321 return c
322 }
323
324 // Header returns a http.Header that can be modified by the caller to add
325 // headers to the request.
326 func (c *SitesGetCall) Header() http.Header {
327 if c.header_ == nil {
328 c.header_ = make(http.Header)
329 }
330 return c.header_
331 }
332
333 func (c *SitesGetCall) doRequest(alt string) (*http.Response, error) {
334 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
335 if c.ifNoneMatch_ != "" {
336 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
337 }
338 c.urlParams_.Set("alt", alt)
339 c.urlParams_.Set("prettyPrint", "false")
340 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
341 urls += "?" + c.urlParams_.Encode()
342 req, err := http.NewRequest("GET", urls, nil)
343 if err != nil {
344 return nil, err
345 }
346 req.Header = reqHeaders
347 googleapi.Expand(req.URL, map[string]string{
348 "name": c.name,
349 })
350 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "adexperiencereport.sites.get", "request", internallog.HTTPRequest(req, nil))
351 return gensupport.SendRequest(c.ctx_, c.s.client, req)
352 }
353
354 // Do executes the "adexperiencereport.sites.get" call.
355 // Any non-2xx status code is an error. Response headers are in either
356 // *SiteSummaryResponse.ServerResponse.Header or (if a response was returned at
357 // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
358 // check whether the returned error was because http.StatusNotModified was
359 // returned.
360 func (c *SitesGetCall) Do(opts ...googleapi.CallOption) (*SiteSummaryResponse, error) {
361 gensupport.SetOptions(c.urlParams_, opts...)
362 res, err := c.doRequest("json")
363 if res != nil && res.StatusCode == http.StatusNotModified {
364 if res.Body != nil {
365 res.Body.Close()
366 }
367 return nil, gensupport.WrapError(&googleapi.Error{
368 Code: res.StatusCode,
369 Header: res.Header,
370 })
371 }
372 if err != nil {
373 return nil, err
374 }
375 defer googleapi.CloseBody(res)
376 if err := googleapi.CheckResponse(res); err != nil {
377 return nil, gensupport.WrapError(err)
378 }
379 ret := &SiteSummaryResponse{
380 ServerResponse: googleapi.ServerResponse{
381 Header: res.Header,
382 HTTPStatusCode: res.StatusCode,
383 },
384 }
385 target := &ret
386 b, err := gensupport.DecodeResponseBytes(target, res)
387 if err != nil {
388 return nil, err
389 }
390 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "adexperiencereport.sites.get", "response", internallog.HTTPResponse(res, b))
391 return ret, nil
392 }
393
394 type ViolatingSitesListCall struct {
395 s *Service
396 urlParams_ gensupport.URLParams
397 ifNoneMatch_ string
398 ctx_ context.Context
399 header_ http.Header
400 }
401
402 // List: Lists sites that are failing in the Ad Experience Report on at least
403 // one platform.
404 func (r *ViolatingSitesService) List() *ViolatingSitesListCall {
405 c := &ViolatingSitesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
406 return c
407 }
408
409 // Fields allows partial responses to be retrieved. See
410 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
411 // details.
412 func (c *ViolatingSitesListCall) Fields(s ...googleapi.Field) *ViolatingSitesListCall {
413 c.urlParams_.Set("fields", googleapi.CombineFields(s))
414 return c
415 }
416
417 // IfNoneMatch sets an optional parameter which makes the operation fail if the
418 // object's ETag matches the given value. This is useful for getting updates
419 // only after the object has changed since the last request.
420 func (c *ViolatingSitesListCall) IfNoneMatch(entityTag string) *ViolatingSitesListCall {
421 c.ifNoneMatch_ = entityTag
422 return c
423 }
424
425 // Context sets the context to be used in this call's Do method.
426 func (c *ViolatingSitesListCall) Context(ctx context.Context) *ViolatingSitesListCall {
427 c.ctx_ = ctx
428 return c
429 }
430
431 // Header returns a http.Header that can be modified by the caller to add
432 // headers to the request.
433 func (c *ViolatingSitesListCall) Header() http.Header {
434 if c.header_ == nil {
435 c.header_ = make(http.Header)
436 }
437 return c.header_
438 }
439
440 func (c *ViolatingSitesListCall) doRequest(alt string) (*http.Response, error) {
441 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
442 if c.ifNoneMatch_ != "" {
443 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
444 }
445 c.urlParams_.Set("alt", alt)
446 c.urlParams_.Set("prettyPrint", "false")
447 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/violatingSites")
448 urls += "?" + c.urlParams_.Encode()
449 req, err := http.NewRequest("GET", urls, nil)
450 if err != nil {
451 return nil, err
452 }
453 req.Header = reqHeaders
454 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "adexperiencereport.violatingSites.list", "request", internallog.HTTPRequest(req, nil))
455 return gensupport.SendRequest(c.ctx_, c.s.client, req)
456 }
457
458 // Do executes the "adexperiencereport.violatingSites.list" call.
459 // Any non-2xx status code is an error. Response headers are in either
460 // *ViolatingSitesResponse.ServerResponse.Header or (if a response was returned
461 // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
462 // check whether the returned error was because http.StatusNotModified was
463 // returned.
464 func (c *ViolatingSitesListCall) Do(opts ...googleapi.CallOption) (*ViolatingSitesResponse, error) {
465 gensupport.SetOptions(c.urlParams_, opts...)
466 res, err := c.doRequest("json")
467 if res != nil && res.StatusCode == http.StatusNotModified {
468 if res.Body != nil {
469 res.Body.Close()
470 }
471 return nil, gensupport.WrapError(&googleapi.Error{
472 Code: res.StatusCode,
473 Header: res.Header,
474 })
475 }
476 if err != nil {
477 return nil, err
478 }
479 defer googleapi.CloseBody(res)
480 if err := googleapi.CheckResponse(res); err != nil {
481 return nil, gensupport.WrapError(err)
482 }
483 ret := &ViolatingSitesResponse{
484 ServerResponse: googleapi.ServerResponse{
485 Header: res.Header,
486 HTTPStatusCode: res.StatusCode,
487 },
488 }
489 target := &ret
490 b, err := gensupport.DecodeResponseBytes(target, res)
491 if err != nil {
492 return nil, err
493 }
494 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "adexperiencereport.violatingSites.list", "response", internallog.HTTPResponse(res, b))
495 return ret, nil
496 }