...

Source file src/google.golang.org/api/adexperiencereport/v1/adexperiencereport-gen.go

Documentation: google.golang.org/api/adexperiencereport/v1

     1  // Copyright 2024 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  	"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  // Always reference these packages, just in case the auto-generated code
    74  // below doesn't.
    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 = "adexperiencereport:v1"
    90  const apiName = "adexperiencereport"
    91  const apiVersion = "v1"
    92  const basePath = "https://adexperiencereport.googleapis.com/"
    93  const basePathTemplate = "https://adexperiencereport.UNIVERSE_DOMAIN/"
    94  const mtlsBasePath = "https://adexperiencereport.mtls.googleapis.com/"
    95  
    96  // NewService creates a new Service.
    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  // New creates a new Service. It uses the provided http.Client for requests.
   117  //
   118  // Deprecated: please use NewService instead.
   119  // To provide a custom HTTP client, use option.WithHTTPClient.
   120  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   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 // 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  	var body io.Reader = nil
   339  	c.urlParams_.Set("alt", alt)
   340  	c.urlParams_.Set("prettyPrint", "false")
   341  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   342  	urls += "?" + c.urlParams_.Encode()
   343  	req, err := http.NewRequest("GET", urls, body)
   344  	if err != nil {
   345  		return nil, err
   346  	}
   347  	req.Header = reqHeaders
   348  	googleapi.Expand(req.URL, map[string]string{
   349  		"name": c.name,
   350  	})
   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  	if err := gensupport.DecodeResponse(target, res); err != nil {
   387  		return nil, err
   388  	}
   389  	return ret, nil
   390  }
   391  
   392  type ViolatingSitesListCall struct {
   393  	s            *Service
   394  	urlParams_   gensupport.URLParams
   395  	ifNoneMatch_ string
   396  	ctx_         context.Context
   397  	header_      http.Header
   398  }
   399  
   400  // List: Lists sites that are failing in the Ad Experience Report on at least
   401  // one platform.
   402  func (r *ViolatingSitesService) List() *ViolatingSitesListCall {
   403  	c := &ViolatingSitesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   404  	return c
   405  }
   406  
   407  // Fields allows partial responses to be retrieved. See
   408  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   409  // details.
   410  func (c *ViolatingSitesListCall) Fields(s ...googleapi.Field) *ViolatingSitesListCall {
   411  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   412  	return c
   413  }
   414  
   415  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   416  // object's ETag matches the given value. This is useful for getting updates
   417  // only after the object has changed since the last request.
   418  func (c *ViolatingSitesListCall) IfNoneMatch(entityTag string) *ViolatingSitesListCall {
   419  	c.ifNoneMatch_ = entityTag
   420  	return c
   421  }
   422  
   423  // Context sets the context to be used in this call's Do method.
   424  func (c *ViolatingSitesListCall) Context(ctx context.Context) *ViolatingSitesListCall {
   425  	c.ctx_ = ctx
   426  	return c
   427  }
   428  
   429  // Header returns a http.Header that can be modified by the caller to add
   430  // headers to the request.
   431  func (c *ViolatingSitesListCall) Header() http.Header {
   432  	if c.header_ == nil {
   433  		c.header_ = make(http.Header)
   434  	}
   435  	return c.header_
   436  }
   437  
   438  func (c *ViolatingSitesListCall) doRequest(alt string) (*http.Response, error) {
   439  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   440  	if c.ifNoneMatch_ != "" {
   441  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   442  	}
   443  	var body io.Reader = nil
   444  	c.urlParams_.Set("alt", alt)
   445  	c.urlParams_.Set("prettyPrint", "false")
   446  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/violatingSites")
   447  	urls += "?" + c.urlParams_.Encode()
   448  	req, err := http.NewRequest("GET", urls, body)
   449  	if err != nil {
   450  		return nil, err
   451  	}
   452  	req.Header = reqHeaders
   453  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   454  }
   455  
   456  // Do executes the "adexperiencereport.violatingSites.list" call.
   457  // Any non-2xx status code is an error. Response headers are in either
   458  // *ViolatingSitesResponse.ServerResponse.Header or (if a response was returned
   459  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   460  // check whether the returned error was because http.StatusNotModified was
   461  // returned.
   462  func (c *ViolatingSitesListCall) Do(opts ...googleapi.CallOption) (*ViolatingSitesResponse, error) {
   463  	gensupport.SetOptions(c.urlParams_, opts...)
   464  	res, err := c.doRequest("json")
   465  	if res != nil && res.StatusCode == http.StatusNotModified {
   466  		if res.Body != nil {
   467  			res.Body.Close()
   468  		}
   469  		return nil, gensupport.WrapError(&googleapi.Error{
   470  			Code:   res.StatusCode,
   471  			Header: res.Header,
   472  		})
   473  	}
   474  	if err != nil {
   475  		return nil, err
   476  	}
   477  	defer googleapi.CloseBody(res)
   478  	if err := googleapi.CheckResponse(res); err != nil {
   479  		return nil, gensupport.WrapError(err)
   480  	}
   481  	ret := &ViolatingSitesResponse{
   482  		ServerResponse: googleapi.ServerResponse{
   483  			Header:         res.Header,
   484  			HTTPStatusCode: res.StatusCode,
   485  		},
   486  	}
   487  	target := &ret
   488  	if err := gensupport.DecodeResponse(target, res); err != nil {
   489  		return nil, err
   490  	}
   491  	return ret, nil
   492  }
   493  

View as plain text