...

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

Documentation: google.golang.org/api/abusiveexperiencereport/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 abusiveexperiencereport provides access to the Abusive Experience Report API.
     8  //
     9  // For product documentation, see: https://developers.google.com/abusive-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/abusiveexperiencereport/v1"
    27  //	...
    28  //	ctx := context.Background()
    29  //	abusiveexperiencereportService, err := abusiveexperiencereport.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  //	abusiveexperiencereportService, err := abusiveexperiencereport.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  //	abusiveexperiencereportService, err := abusiveexperiencereport.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    49  //
    50  // See [google.golang.org/api/option.ClientOption] for details on options.
    51  package abusiveexperiencereport // import "google.golang.org/api/abusiveexperiencereport/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 = "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  // 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  // SiteSummaryResponse: Response message for GetSiteSummary.
   167  type SiteSummaryResponse struct {
   168  	// AbusiveStatus: The site's Abusive Experience Report status.
   169  	//
   170  	// Possible values:
   171  	//   "UNKNOWN" - Not reviewed.
   172  	//   "PASSING" - Passing.
   173  	//   "FAILING" - Failing.
   174  	AbusiveStatus string `json:"abusiveStatus,omitempty"`
   175  	// EnforcementTime: The time at which enforcement
   176  	// (https://support.google.com/webtools/answer/7538608) against the site began
   177  	// or will begin. Not set when the filter_status is OFF.
   178  	EnforcementTime string `json:"enforcementTime,omitempty"`
   179  	// FilterStatus: The site's enforcement status
   180  	// (https://support.google.com/webtools/answer/7538608).
   181  	//
   182  	// Possible values:
   183  	//   "UNKNOWN" - N/A.
   184  	//   "ON" - Enforcement is on.
   185  	//   "OFF" - Enforcement is off.
   186  	//   "PAUSED" - Enforcement is paused.
   187  	//   "PENDING" - Enforcement is pending.
   188  	FilterStatus string `json:"filterStatus,omitempty"`
   189  	// LastChangeTime: The time at which the site's status last changed.
   190  	LastChangeTime string `json:"lastChangeTime,omitempty"`
   191  	// ReportUrl: A link to the full Abusive Experience Report for the site. Not
   192  	// set in ViolatingSitesResponse. Note that you must complete the Search
   193  	// Console verification process
   194  	// (https://support.google.com/webmasters/answer/9008080) for the site before
   195  	// you can access the full report.
   196  	ReportUrl string `json:"reportUrl,omitempty"`
   197  	// ReviewedSite: The name of the reviewed site, e.g. `google.com`.
   198  	ReviewedSite string `json:"reviewedSite,omitempty"`
   199  	// UnderReview: Whether the site is currently under review.
   200  	UnderReview bool `json:"underReview,omitempty"`
   201  
   202  	// ServerResponse contains the HTTP response code and headers from the server.
   203  	googleapi.ServerResponse `json:"-"`
   204  	// ForceSendFields is a list of field names (e.g. "AbusiveStatus") to
   205  	// unconditionally include in API requests. By default, fields with empty or
   206  	// default values are omitted from API requests. See
   207  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   208  	// details.
   209  	ForceSendFields []string `json:"-"`
   210  	// NullFields is a list of field names (e.g. "AbusiveStatus") to include in API
   211  	// requests with the JSON null value. By default, fields with empty values are
   212  	// omitted from API requests. See
   213  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // ViolatingSitesResponse: Response message for ListViolatingSites.
   223  type ViolatingSitesResponse struct {
   224  	// ViolatingSites: The list of violating sites.
   225  	ViolatingSites []*SiteSummaryResponse `json:"violatingSites,omitempty"`
   226  
   227  	// ServerResponse contains the HTTP response code and headers from the server.
   228  	googleapi.ServerResponse `json:"-"`
   229  	// ForceSendFields is a list of field names (e.g. "ViolatingSites") to
   230  	// unconditionally include in API requests. By default, fields with empty or
   231  	// default values are omitted from API requests. See
   232  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   233  	// details.
   234  	ForceSendFields []string `json:"-"`
   235  	// NullFields is a list of field names (e.g. "ViolatingSites") to include in
   236  	// API requests with the JSON null value. By default, fields with empty values
   237  	// are omitted from API requests. See
   238  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // Get: Gets a site's Abusive Experience Report summary.
   257  //
   258  //   - name: The name of the site whose summary to get, e.g.
   259  //     `sites/http%3A%2F%2Fwww.google.com%2F`. Format: `sites/{site}`.
   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  // Fields allows partial responses to be retrieved. See
   267  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   268  // details.
   269  func (c *SitesGetCall) Fields(s ...googleapi.Field) *SitesGetCall {
   270  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   271  	return c
   272  }
   273  
   274  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   275  // object's ETag matches the given value. This is useful for getting updates
   276  // only after the object has changed since the last request.
   277  func (c *SitesGetCall) IfNoneMatch(entityTag string) *SitesGetCall {
   278  	c.ifNoneMatch_ = entityTag
   279  	return c
   280  }
   281  
   282  // Context sets the context to be used in this call's Do method.
   283  func (c *SitesGetCall) Context(ctx context.Context) *SitesGetCall {
   284  	c.ctx_ = ctx
   285  	return c
   286  }
   287  
   288  // Header returns a http.Header that can be modified by the caller to add
   289  // headers to the request.
   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  // Do executes the "abusiveexperiencereport.sites.get" call.
   319  // Any non-2xx status code is an error. Response headers are in either
   320  // *SiteSummaryResponse.ServerResponse.Header or (if a response was returned at
   321  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   322  // check whether the returned error was because http.StatusNotModified was
   323  // returned.
   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  // List: Lists sites that are failing in the Abusive Experience Report.
   365  func (r *ViolatingSitesService) List() *ViolatingSitesListCall {
   366  	c := &ViolatingSitesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   367  	return c
   368  }
   369  
   370  // Fields allows partial responses to be retrieved. See
   371  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   372  // details.
   373  func (c *ViolatingSitesListCall) Fields(s ...googleapi.Field) *ViolatingSitesListCall {
   374  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   375  	return c
   376  }
   377  
   378  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   379  // object's ETag matches the given value. This is useful for getting updates
   380  // only after the object has changed since the last request.
   381  func (c *ViolatingSitesListCall) IfNoneMatch(entityTag string) *ViolatingSitesListCall {
   382  	c.ifNoneMatch_ = entityTag
   383  	return c
   384  }
   385  
   386  // Context sets the context to be used in this call's Do method.
   387  func (c *ViolatingSitesListCall) Context(ctx context.Context) *ViolatingSitesListCall {
   388  	c.ctx_ = ctx
   389  	return c
   390  }
   391  
   392  // Header returns a http.Header that can be modified by the caller to add
   393  // headers to the request.
   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  // Do executes the "abusiveexperiencereport.violatingSites.list" call.
   420  // Any non-2xx status code is an error. Response headers are in either
   421  // *ViolatingSitesResponse.ServerResponse.Header or (if a response was returned
   422  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   423  // check whether the returned error was because http.StatusNotModified was
   424  // returned.
   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