...

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

Documentation: google.golang.org/api/siteverification/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 siteverification provides access to the Google Site Verification API.
     8  //
     9  // For product documentation, see: https://developers.google.com/site-verification/
    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/siteverification/v1"
    27  //	...
    28  //	ctx := context.Background()
    29  //	siteverificationService, err := siteverification.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  // By default, all available scopes (see "Constants") are used to authenticate.
    38  // To restrict scopes, use [google.golang.org/api/option.WithScopes]:
    39  //
    40  //	siteverificationService, err := siteverification.NewService(ctx, option.WithScopes(siteverification.SiteverificationVerifyOnlyScope))
    41  //
    42  // To use an API key for authentication (note: some APIs do not support API
    43  // keys), use [google.golang.org/api/option.WithAPIKey]:
    44  //
    45  //	siteverificationService, err := siteverification.NewService(ctx, option.WithAPIKey("AIza..."))
    46  //
    47  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    48  // flow, use [google.golang.org/api/option.WithTokenSource]:
    49  //
    50  //	config := &oauth2.Config{...}
    51  //	// ...
    52  //	token, err := config.Exchange(ctx, ...)
    53  //	siteverificationService, err := siteverification.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    54  //
    55  // See [google.golang.org/api/option.ClientOption] for details on options.
    56  package siteverification // import "google.golang.org/api/siteverification/v1"
    57  
    58  import (
    59  	"bytes"
    60  	"context"
    61  	"encoding/json"
    62  	"errors"
    63  	"fmt"
    64  	"io"
    65  	"net/http"
    66  	"net/url"
    67  	"strconv"
    68  	"strings"
    69  
    70  	googleapi "google.golang.org/api/googleapi"
    71  	internal "google.golang.org/api/internal"
    72  	gensupport "google.golang.org/api/internal/gensupport"
    73  	option "google.golang.org/api/option"
    74  	internaloption "google.golang.org/api/option/internaloption"
    75  	htransport "google.golang.org/api/transport/http"
    76  )
    77  
    78  // Always reference these packages, just in case the auto-generated code
    79  // below doesn't.
    80  var _ = bytes.NewBuffer
    81  var _ = strconv.Itoa
    82  var _ = fmt.Sprintf
    83  var _ = json.NewDecoder
    84  var _ = io.Copy
    85  var _ = url.Parse
    86  var _ = gensupport.MarshalJSON
    87  var _ = googleapi.Version
    88  var _ = errors.New
    89  var _ = strings.Replace
    90  var _ = context.Canceled
    91  var _ = internaloption.WithDefaultEndpoint
    92  var _ = internal.Version
    93  
    94  const apiId = "siteVerification:v1"
    95  const apiName = "siteVerification"
    96  const apiVersion = "v1"
    97  const basePath = "https://www.googleapis.com/siteVerification/v1/"
    98  const basePathTemplate = "https://www.UNIVERSE_DOMAIN/siteVerification/v1/"
    99  
   100  // OAuth2 scopes used by this API.
   101  const (
   102  	// Manage the list of sites and domains you control
   103  	SiteverificationScope = "https://www.googleapis.com/auth/siteverification"
   104  
   105  	// Manage your new site verifications with Google
   106  	SiteverificationVerifyOnlyScope = "https://www.googleapis.com/auth/siteverification.verify_only"
   107  )
   108  
   109  // NewService creates a new Service.
   110  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
   111  	scopesOption := internaloption.WithDefaultScopes(
   112  		"https://www.googleapis.com/auth/siteverification",
   113  		"https://www.googleapis.com/auth/siteverification.verify_only",
   114  	)
   115  	// NOTE: prepend, so we don't override user-specified scopes.
   116  	opts = append([]option.ClientOption{scopesOption}, opts...)
   117  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   118  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   119  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   120  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   121  	if err != nil {
   122  		return nil, err
   123  	}
   124  	s, err := New(client)
   125  	if err != nil {
   126  		return nil, err
   127  	}
   128  	if endpoint != "" {
   129  		s.BasePath = endpoint
   130  	}
   131  	return s, nil
   132  }
   133  
   134  // New creates a new Service. It uses the provided http.Client for requests.
   135  //
   136  // Deprecated: please use NewService instead.
   137  // To provide a custom HTTP client, use option.WithHTTPClient.
   138  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   139  func New(client *http.Client) (*Service, error) {
   140  	if client == nil {
   141  		return nil, errors.New("client is nil")
   142  	}
   143  	s := &Service{client: client, BasePath: basePath}
   144  	s.WebResource = NewWebResourceService(s)
   145  	return s, nil
   146  }
   147  
   148  type Service struct {
   149  	client    *http.Client
   150  	BasePath  string // API endpoint base URL
   151  	UserAgent string // optional additional User-Agent fragment
   152  
   153  	WebResource *WebResourceService
   154  }
   155  
   156  func (s *Service) userAgent() string {
   157  	if s.UserAgent == "" {
   158  		return googleapi.UserAgent
   159  	}
   160  	return googleapi.UserAgent + " " + s.UserAgent
   161  }
   162  
   163  func NewWebResourceService(s *Service) *WebResourceService {
   164  	rs := &WebResourceService{s: s}
   165  	return rs
   166  }
   167  
   168  type WebResourceService struct {
   169  	s *Service
   170  }
   171  
   172  type SiteVerificationWebResourceGettokenRequest struct {
   173  	// Site: The site for which a verification token will be generated.
   174  	Site *SiteVerificationWebResourceGettokenRequestSite `json:"site,omitempty"`
   175  	// VerificationMethod: The verification method that will be used to verify this
   176  	// site. For sites, 'FILE' or 'META' methods may be used. For domains, only
   177  	// 'DNS' may be used.
   178  	VerificationMethod string `json:"verificationMethod,omitempty"`
   179  	// ForceSendFields is a list of field names (e.g. "Site") to unconditionally
   180  	// include in API requests. By default, fields with empty or default values are
   181  	// omitted from API requests. See
   182  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   183  	// details.
   184  	ForceSendFields []string `json:"-"`
   185  	// NullFields is a list of field names (e.g. "Site") to include in API requests
   186  	// with the JSON null value. By default, fields with empty values are omitted
   187  	// from API requests. See
   188  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   189  	NullFields []string `json:"-"`
   190  }
   191  
   192  func (s *SiteVerificationWebResourceGettokenRequest) MarshalJSON() ([]byte, error) {
   193  	type NoMethod SiteVerificationWebResourceGettokenRequest
   194  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   195  }
   196  
   197  // SiteVerificationWebResourceGettokenRequestSite: The site for which a
   198  // verification token will be generated.
   199  type SiteVerificationWebResourceGettokenRequestSite struct {
   200  	// Identifier: The site identifier. If the type is set to SITE, the identifier
   201  	// is a URL. If the type is set to INET_DOMAIN, the site identifier is a domain
   202  	// name.
   203  	Identifier string `json:"identifier,omitempty"`
   204  	// Type: The type of resource to be verified. Can be SITE or INET_DOMAIN
   205  	// (domain name).
   206  	Type string `json:"type,omitempty"`
   207  	// ForceSendFields is a list of field names (e.g. "Identifier") to
   208  	// unconditionally include in API requests. By default, fields with empty or
   209  	// default values are omitted from API requests. See
   210  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   211  	// details.
   212  	ForceSendFields []string `json:"-"`
   213  	// NullFields is a list of field names (e.g. "Identifier") to include in API
   214  	// requests with the JSON null value. By default, fields with empty values are
   215  	// omitted from API requests. See
   216  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   217  	NullFields []string `json:"-"`
   218  }
   219  
   220  func (s *SiteVerificationWebResourceGettokenRequestSite) MarshalJSON() ([]byte, error) {
   221  	type NoMethod SiteVerificationWebResourceGettokenRequestSite
   222  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   223  }
   224  
   225  type SiteVerificationWebResourceGettokenResponse struct {
   226  	// Method: The verification method to use in conjunction with this token. For
   227  	// FILE, the token should be placed in the top-level directory of the site,
   228  	// stored inside a file of the same name. For META, the token should be placed
   229  	// in the HEAD tag of the default page that is loaded for the site. For DNS,
   230  	// the token should be placed in a TXT record of the domain.
   231  	Method string `json:"method,omitempty"`
   232  	// Token: The verification token. The token must be placed appropriately in
   233  	// order for verification to succeed.
   234  	Token string `json:"token,omitempty"`
   235  
   236  	// ServerResponse contains the HTTP response code and headers from the server.
   237  	googleapi.ServerResponse `json:"-"`
   238  	// ForceSendFields is a list of field names (e.g. "Method") to unconditionally
   239  	// include in API requests. By default, fields with empty or default values are
   240  	// omitted from API requests. See
   241  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   242  	// details.
   243  	ForceSendFields []string `json:"-"`
   244  	// NullFields is a list of field names (e.g. "Method") to include in API
   245  	// requests with the JSON null value. By default, fields with empty values are
   246  	// omitted from API requests. See
   247  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   248  	NullFields []string `json:"-"`
   249  }
   250  
   251  func (s *SiteVerificationWebResourceGettokenResponse) MarshalJSON() ([]byte, error) {
   252  	type NoMethod SiteVerificationWebResourceGettokenResponse
   253  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   254  }
   255  
   256  type SiteVerificationWebResourceListResponse struct {
   257  	// Items: The list of sites that are owned by the authenticated user.
   258  	Items []*SiteVerificationWebResourceResource `json:"items,omitempty"`
   259  
   260  	// ServerResponse contains the HTTP response code and headers from the server.
   261  	googleapi.ServerResponse `json:"-"`
   262  	// ForceSendFields is a list of field names (e.g. "Items") to unconditionally
   263  	// include in API requests. By default, fields with empty or default values are
   264  	// omitted from API requests. See
   265  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   266  	// details.
   267  	ForceSendFields []string `json:"-"`
   268  	// NullFields is a list of field names (e.g. "Items") to include in API
   269  	// requests with the JSON null value. By default, fields with empty values are
   270  	// omitted from API requests. See
   271  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   272  	NullFields []string `json:"-"`
   273  }
   274  
   275  func (s *SiteVerificationWebResourceListResponse) MarshalJSON() ([]byte, error) {
   276  	type NoMethod SiteVerificationWebResourceListResponse
   277  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   278  }
   279  
   280  type SiteVerificationWebResourceResource struct {
   281  	// Id: The string used to identify this site. This value should be used in the
   282  	// "id" portion of the REST URL for the Get, Update, and Delete operations.
   283  	Id string `json:"id,omitempty"`
   284  	// Owners: The email addresses of all verified owners.
   285  	Owners []string `json:"owners,omitempty"`
   286  	// Site: The address and type of a site that is verified or will be verified.
   287  	Site *SiteVerificationWebResourceResourceSite `json:"site,omitempty"`
   288  
   289  	// ServerResponse contains the HTTP response code and headers from the server.
   290  	googleapi.ServerResponse `json:"-"`
   291  	// ForceSendFields is a list of field names (e.g. "Id") to unconditionally
   292  	// include in API requests. By default, fields with empty or default values are
   293  	// omitted from API requests. See
   294  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   295  	// details.
   296  	ForceSendFields []string `json:"-"`
   297  	// NullFields is a list of field names (e.g. "Id") to include in API requests
   298  	// with the JSON null value. By default, fields with empty values are omitted
   299  	// from API requests. See
   300  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   301  	NullFields []string `json:"-"`
   302  }
   303  
   304  func (s *SiteVerificationWebResourceResource) MarshalJSON() ([]byte, error) {
   305  	type NoMethod SiteVerificationWebResourceResource
   306  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   307  }
   308  
   309  // SiteVerificationWebResourceResourceSite: The address and type of a site that
   310  // is verified or will be verified.
   311  type SiteVerificationWebResourceResourceSite struct {
   312  	// Identifier: The site identifier. If the type is set to SITE, the identifier
   313  	// is a URL. If the type is set to INET_DOMAIN, the site identifier is a domain
   314  	// name.
   315  	Identifier string `json:"identifier,omitempty"`
   316  	// Type: The site type. Can be SITE or INET_DOMAIN (domain name).
   317  	Type string `json:"type,omitempty"`
   318  	// ForceSendFields is a list of field names (e.g. "Identifier") to
   319  	// unconditionally include in API requests. By default, fields with empty or
   320  	// default values are omitted from API requests. See
   321  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   322  	// details.
   323  	ForceSendFields []string `json:"-"`
   324  	// NullFields is a list of field names (e.g. "Identifier") to include in API
   325  	// requests with the JSON null value. By default, fields with empty values are
   326  	// omitted from API requests. See
   327  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   328  	NullFields []string `json:"-"`
   329  }
   330  
   331  func (s *SiteVerificationWebResourceResourceSite) MarshalJSON() ([]byte, error) {
   332  	type NoMethod SiteVerificationWebResourceResourceSite
   333  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   334  }
   335  
   336  type WebResourceDeleteCall struct {
   337  	s          *Service
   338  	id         string
   339  	urlParams_ gensupport.URLParams
   340  	ctx_       context.Context
   341  	header_    http.Header
   342  }
   343  
   344  // Delete: Relinquish ownership of a website or domain.
   345  //
   346  // - id: The id of a verified site or domain.
   347  func (r *WebResourceService) Delete(id string) *WebResourceDeleteCall {
   348  	c := &WebResourceDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   349  	c.id = id
   350  	return c
   351  }
   352  
   353  // Fields allows partial responses to be retrieved. See
   354  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   355  // details.
   356  func (c *WebResourceDeleteCall) Fields(s ...googleapi.Field) *WebResourceDeleteCall {
   357  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   358  	return c
   359  }
   360  
   361  // Context sets the context to be used in this call's Do method.
   362  func (c *WebResourceDeleteCall) Context(ctx context.Context) *WebResourceDeleteCall {
   363  	c.ctx_ = ctx
   364  	return c
   365  }
   366  
   367  // Header returns a http.Header that can be modified by the caller to add
   368  // headers to the request.
   369  func (c *WebResourceDeleteCall) Header() http.Header {
   370  	if c.header_ == nil {
   371  		c.header_ = make(http.Header)
   372  	}
   373  	return c.header_
   374  }
   375  
   376  func (c *WebResourceDeleteCall) doRequest(alt string) (*http.Response, error) {
   377  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   378  	var body io.Reader = nil
   379  	c.urlParams_.Set("alt", alt)
   380  	c.urlParams_.Set("prettyPrint", "false")
   381  	urls := googleapi.ResolveRelative(c.s.BasePath, "webResource/{id}")
   382  	urls += "?" + c.urlParams_.Encode()
   383  	req, err := http.NewRequest("DELETE", urls, body)
   384  	if err != nil {
   385  		return nil, err
   386  	}
   387  	req.Header = reqHeaders
   388  	googleapi.Expand(req.URL, map[string]string{
   389  		"id": c.id,
   390  	})
   391  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   392  }
   393  
   394  // Do executes the "siteVerification.webResource.delete" call.
   395  func (c *WebResourceDeleteCall) Do(opts ...googleapi.CallOption) error {
   396  	gensupport.SetOptions(c.urlParams_, opts...)
   397  	res, err := c.doRequest("json")
   398  	if err != nil {
   399  		return err
   400  	}
   401  	defer googleapi.CloseBody(res)
   402  	if err := googleapi.CheckResponse(res); err != nil {
   403  		return gensupport.WrapError(err)
   404  	}
   405  	return nil
   406  }
   407  
   408  type WebResourceGetCall struct {
   409  	s            *Service
   410  	id           string
   411  	urlParams_   gensupport.URLParams
   412  	ifNoneMatch_ string
   413  	ctx_         context.Context
   414  	header_      http.Header
   415  }
   416  
   417  // Get: Get the most current data for a website or domain.
   418  //
   419  // - id: The id of a verified site or domain.
   420  func (r *WebResourceService) Get(id string) *WebResourceGetCall {
   421  	c := &WebResourceGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   422  	c.id = id
   423  	return c
   424  }
   425  
   426  // Fields allows partial responses to be retrieved. See
   427  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   428  // details.
   429  func (c *WebResourceGetCall) Fields(s ...googleapi.Field) *WebResourceGetCall {
   430  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   431  	return c
   432  }
   433  
   434  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   435  // object's ETag matches the given value. This is useful for getting updates
   436  // only after the object has changed since the last request.
   437  func (c *WebResourceGetCall) IfNoneMatch(entityTag string) *WebResourceGetCall {
   438  	c.ifNoneMatch_ = entityTag
   439  	return c
   440  }
   441  
   442  // Context sets the context to be used in this call's Do method.
   443  func (c *WebResourceGetCall) Context(ctx context.Context) *WebResourceGetCall {
   444  	c.ctx_ = ctx
   445  	return c
   446  }
   447  
   448  // Header returns a http.Header that can be modified by the caller to add
   449  // headers to the request.
   450  func (c *WebResourceGetCall) Header() http.Header {
   451  	if c.header_ == nil {
   452  		c.header_ = make(http.Header)
   453  	}
   454  	return c.header_
   455  }
   456  
   457  func (c *WebResourceGetCall) doRequest(alt string) (*http.Response, error) {
   458  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   459  	if c.ifNoneMatch_ != "" {
   460  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   461  	}
   462  	var body io.Reader = nil
   463  	c.urlParams_.Set("alt", alt)
   464  	c.urlParams_.Set("prettyPrint", "false")
   465  	urls := googleapi.ResolveRelative(c.s.BasePath, "webResource/{id}")
   466  	urls += "?" + c.urlParams_.Encode()
   467  	req, err := http.NewRequest("GET", urls, body)
   468  	if err != nil {
   469  		return nil, err
   470  	}
   471  	req.Header = reqHeaders
   472  	googleapi.Expand(req.URL, map[string]string{
   473  		"id": c.id,
   474  	})
   475  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   476  }
   477  
   478  // Do executes the "siteVerification.webResource.get" call.
   479  // Any non-2xx status code is an error. Response headers are in either
   480  // *SiteVerificationWebResourceResource.ServerResponse.Header or (if a response
   481  // was returned at all) in error.(*googleapi.Error).Header. Use
   482  // googleapi.IsNotModified to check whether the returned error was because
   483  // http.StatusNotModified was returned.
   484  func (c *WebResourceGetCall) Do(opts ...googleapi.CallOption) (*SiteVerificationWebResourceResource, error) {
   485  	gensupport.SetOptions(c.urlParams_, opts...)
   486  	res, err := c.doRequest("json")
   487  	if res != nil && res.StatusCode == http.StatusNotModified {
   488  		if res.Body != nil {
   489  			res.Body.Close()
   490  		}
   491  		return nil, gensupport.WrapError(&googleapi.Error{
   492  			Code:   res.StatusCode,
   493  			Header: res.Header,
   494  		})
   495  	}
   496  	if err != nil {
   497  		return nil, err
   498  	}
   499  	defer googleapi.CloseBody(res)
   500  	if err := googleapi.CheckResponse(res); err != nil {
   501  		return nil, gensupport.WrapError(err)
   502  	}
   503  	ret := &SiteVerificationWebResourceResource{
   504  		ServerResponse: googleapi.ServerResponse{
   505  			Header:         res.Header,
   506  			HTTPStatusCode: res.StatusCode,
   507  		},
   508  	}
   509  	target := &ret
   510  	if err := gensupport.DecodeResponse(target, res); err != nil {
   511  		return nil, err
   512  	}
   513  	return ret, nil
   514  }
   515  
   516  type WebResourceGetTokenCall struct {
   517  	s                                          *Service
   518  	siteverificationwebresourcegettokenrequest *SiteVerificationWebResourceGettokenRequest
   519  	urlParams_                                 gensupport.URLParams
   520  	ctx_                                       context.Context
   521  	header_                                    http.Header
   522  }
   523  
   524  // GetToken: Get a verification token for placing on a website or domain.
   525  func (r *WebResourceService) GetToken(siteverificationwebresourcegettokenrequest *SiteVerificationWebResourceGettokenRequest) *WebResourceGetTokenCall {
   526  	c := &WebResourceGetTokenCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   527  	c.siteverificationwebresourcegettokenrequest = siteverificationwebresourcegettokenrequest
   528  	return c
   529  }
   530  
   531  // Fields allows partial responses to be retrieved. See
   532  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   533  // details.
   534  func (c *WebResourceGetTokenCall) Fields(s ...googleapi.Field) *WebResourceGetTokenCall {
   535  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   536  	return c
   537  }
   538  
   539  // Context sets the context to be used in this call's Do method.
   540  func (c *WebResourceGetTokenCall) Context(ctx context.Context) *WebResourceGetTokenCall {
   541  	c.ctx_ = ctx
   542  	return c
   543  }
   544  
   545  // Header returns a http.Header that can be modified by the caller to add
   546  // headers to the request.
   547  func (c *WebResourceGetTokenCall) Header() http.Header {
   548  	if c.header_ == nil {
   549  		c.header_ = make(http.Header)
   550  	}
   551  	return c.header_
   552  }
   553  
   554  func (c *WebResourceGetTokenCall) doRequest(alt string) (*http.Response, error) {
   555  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   556  	var body io.Reader = nil
   557  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.siteverificationwebresourcegettokenrequest)
   558  	if err != nil {
   559  		return nil, err
   560  	}
   561  	c.urlParams_.Set("alt", alt)
   562  	c.urlParams_.Set("prettyPrint", "false")
   563  	urls := googleapi.ResolveRelative(c.s.BasePath, "token")
   564  	urls += "?" + c.urlParams_.Encode()
   565  	req, err := http.NewRequest("POST", urls, body)
   566  	if err != nil {
   567  		return nil, err
   568  	}
   569  	req.Header = reqHeaders
   570  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   571  }
   572  
   573  // Do executes the "siteVerification.webResource.getToken" call.
   574  // Any non-2xx status code is an error. Response headers are in either
   575  // *SiteVerificationWebResourceGettokenResponse.ServerResponse.Header or (if a
   576  // response was returned at all) in error.(*googleapi.Error).Header. Use
   577  // googleapi.IsNotModified to check whether the returned error was because
   578  // http.StatusNotModified was returned.
   579  func (c *WebResourceGetTokenCall) Do(opts ...googleapi.CallOption) (*SiteVerificationWebResourceGettokenResponse, error) {
   580  	gensupport.SetOptions(c.urlParams_, opts...)
   581  	res, err := c.doRequest("json")
   582  	if res != nil && res.StatusCode == http.StatusNotModified {
   583  		if res.Body != nil {
   584  			res.Body.Close()
   585  		}
   586  		return nil, gensupport.WrapError(&googleapi.Error{
   587  			Code:   res.StatusCode,
   588  			Header: res.Header,
   589  		})
   590  	}
   591  	if err != nil {
   592  		return nil, err
   593  	}
   594  	defer googleapi.CloseBody(res)
   595  	if err := googleapi.CheckResponse(res); err != nil {
   596  		return nil, gensupport.WrapError(err)
   597  	}
   598  	ret := &SiteVerificationWebResourceGettokenResponse{
   599  		ServerResponse: googleapi.ServerResponse{
   600  			Header:         res.Header,
   601  			HTTPStatusCode: res.StatusCode,
   602  		},
   603  	}
   604  	target := &ret
   605  	if err := gensupport.DecodeResponse(target, res); err != nil {
   606  		return nil, err
   607  	}
   608  	return ret, nil
   609  }
   610  
   611  type WebResourceInsertCall struct {
   612  	s                                   *Service
   613  	siteverificationwebresourceresource *SiteVerificationWebResourceResource
   614  	urlParams_                          gensupport.URLParams
   615  	ctx_                                context.Context
   616  	header_                             http.Header
   617  }
   618  
   619  // Insert: Attempt verification of a website or domain.
   620  //
   621  // - verificationMethod: The method to use for verifying a site or domain.
   622  func (r *WebResourceService) Insert(verificationMethod string, siteverificationwebresourceresource *SiteVerificationWebResourceResource) *WebResourceInsertCall {
   623  	c := &WebResourceInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   624  	c.urlParams_.Set("verificationMethod", verificationMethod)
   625  	c.siteverificationwebresourceresource = siteverificationwebresourceresource
   626  	return c
   627  }
   628  
   629  // Fields allows partial responses to be retrieved. See
   630  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   631  // details.
   632  func (c *WebResourceInsertCall) Fields(s ...googleapi.Field) *WebResourceInsertCall {
   633  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   634  	return c
   635  }
   636  
   637  // Context sets the context to be used in this call's Do method.
   638  func (c *WebResourceInsertCall) Context(ctx context.Context) *WebResourceInsertCall {
   639  	c.ctx_ = ctx
   640  	return c
   641  }
   642  
   643  // Header returns a http.Header that can be modified by the caller to add
   644  // headers to the request.
   645  func (c *WebResourceInsertCall) Header() http.Header {
   646  	if c.header_ == nil {
   647  		c.header_ = make(http.Header)
   648  	}
   649  	return c.header_
   650  }
   651  
   652  func (c *WebResourceInsertCall) doRequest(alt string) (*http.Response, error) {
   653  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   654  	var body io.Reader = nil
   655  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.siteverificationwebresourceresource)
   656  	if err != nil {
   657  		return nil, err
   658  	}
   659  	c.urlParams_.Set("alt", alt)
   660  	c.urlParams_.Set("prettyPrint", "false")
   661  	urls := googleapi.ResolveRelative(c.s.BasePath, "webResource")
   662  	urls += "?" + c.urlParams_.Encode()
   663  	req, err := http.NewRequest("POST", urls, body)
   664  	if err != nil {
   665  		return nil, err
   666  	}
   667  	req.Header = reqHeaders
   668  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   669  }
   670  
   671  // Do executes the "siteVerification.webResource.insert" call.
   672  // Any non-2xx status code is an error. Response headers are in either
   673  // *SiteVerificationWebResourceResource.ServerResponse.Header or (if a response
   674  // was returned at all) in error.(*googleapi.Error).Header. Use
   675  // googleapi.IsNotModified to check whether the returned error was because
   676  // http.StatusNotModified was returned.
   677  func (c *WebResourceInsertCall) Do(opts ...googleapi.CallOption) (*SiteVerificationWebResourceResource, error) {
   678  	gensupport.SetOptions(c.urlParams_, opts...)
   679  	res, err := c.doRequest("json")
   680  	if res != nil && res.StatusCode == http.StatusNotModified {
   681  		if res.Body != nil {
   682  			res.Body.Close()
   683  		}
   684  		return nil, gensupport.WrapError(&googleapi.Error{
   685  			Code:   res.StatusCode,
   686  			Header: res.Header,
   687  		})
   688  	}
   689  	if err != nil {
   690  		return nil, err
   691  	}
   692  	defer googleapi.CloseBody(res)
   693  	if err := googleapi.CheckResponse(res); err != nil {
   694  		return nil, gensupport.WrapError(err)
   695  	}
   696  	ret := &SiteVerificationWebResourceResource{
   697  		ServerResponse: googleapi.ServerResponse{
   698  			Header:         res.Header,
   699  			HTTPStatusCode: res.StatusCode,
   700  		},
   701  	}
   702  	target := &ret
   703  	if err := gensupport.DecodeResponse(target, res); err != nil {
   704  		return nil, err
   705  	}
   706  	return ret, nil
   707  }
   708  
   709  type WebResourceListCall struct {
   710  	s            *Service
   711  	urlParams_   gensupport.URLParams
   712  	ifNoneMatch_ string
   713  	ctx_         context.Context
   714  	header_      http.Header
   715  }
   716  
   717  // List: Get the list of your verified websites and domains.
   718  func (r *WebResourceService) List() *WebResourceListCall {
   719  	c := &WebResourceListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   720  	return c
   721  }
   722  
   723  // Fields allows partial responses to be retrieved. See
   724  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   725  // details.
   726  func (c *WebResourceListCall) Fields(s ...googleapi.Field) *WebResourceListCall {
   727  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   728  	return c
   729  }
   730  
   731  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   732  // object's ETag matches the given value. This is useful for getting updates
   733  // only after the object has changed since the last request.
   734  func (c *WebResourceListCall) IfNoneMatch(entityTag string) *WebResourceListCall {
   735  	c.ifNoneMatch_ = entityTag
   736  	return c
   737  }
   738  
   739  // Context sets the context to be used in this call's Do method.
   740  func (c *WebResourceListCall) Context(ctx context.Context) *WebResourceListCall {
   741  	c.ctx_ = ctx
   742  	return c
   743  }
   744  
   745  // Header returns a http.Header that can be modified by the caller to add
   746  // headers to the request.
   747  func (c *WebResourceListCall) Header() http.Header {
   748  	if c.header_ == nil {
   749  		c.header_ = make(http.Header)
   750  	}
   751  	return c.header_
   752  }
   753  
   754  func (c *WebResourceListCall) doRequest(alt string) (*http.Response, error) {
   755  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   756  	if c.ifNoneMatch_ != "" {
   757  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   758  	}
   759  	var body io.Reader = nil
   760  	c.urlParams_.Set("alt", alt)
   761  	c.urlParams_.Set("prettyPrint", "false")
   762  	urls := googleapi.ResolveRelative(c.s.BasePath, "webResource")
   763  	urls += "?" + c.urlParams_.Encode()
   764  	req, err := http.NewRequest("GET", urls, body)
   765  	if err != nil {
   766  		return nil, err
   767  	}
   768  	req.Header = reqHeaders
   769  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   770  }
   771  
   772  // Do executes the "siteVerification.webResource.list" call.
   773  // Any non-2xx status code is an error. Response headers are in either
   774  // *SiteVerificationWebResourceListResponse.ServerResponse.Header or (if a
   775  // response was returned at all) in error.(*googleapi.Error).Header. Use
   776  // googleapi.IsNotModified to check whether the returned error was because
   777  // http.StatusNotModified was returned.
   778  func (c *WebResourceListCall) Do(opts ...googleapi.CallOption) (*SiteVerificationWebResourceListResponse, error) {
   779  	gensupport.SetOptions(c.urlParams_, opts...)
   780  	res, err := c.doRequest("json")
   781  	if res != nil && res.StatusCode == http.StatusNotModified {
   782  		if res.Body != nil {
   783  			res.Body.Close()
   784  		}
   785  		return nil, gensupport.WrapError(&googleapi.Error{
   786  			Code:   res.StatusCode,
   787  			Header: res.Header,
   788  		})
   789  	}
   790  	if err != nil {
   791  		return nil, err
   792  	}
   793  	defer googleapi.CloseBody(res)
   794  	if err := googleapi.CheckResponse(res); err != nil {
   795  		return nil, gensupport.WrapError(err)
   796  	}
   797  	ret := &SiteVerificationWebResourceListResponse{
   798  		ServerResponse: googleapi.ServerResponse{
   799  			Header:         res.Header,
   800  			HTTPStatusCode: res.StatusCode,
   801  		},
   802  	}
   803  	target := &ret
   804  	if err := gensupport.DecodeResponse(target, res); err != nil {
   805  		return nil, err
   806  	}
   807  	return ret, nil
   808  }
   809  
   810  type WebResourcePatchCall struct {
   811  	s                                   *Service
   812  	id                                  string
   813  	siteverificationwebresourceresource *SiteVerificationWebResourceResource
   814  	urlParams_                          gensupport.URLParams
   815  	ctx_                                context.Context
   816  	header_                             http.Header
   817  }
   818  
   819  // Patch: Modify the list of owners for your website or domain. This method
   820  // supports patch semantics.
   821  //
   822  // - id: The id of a verified site or domain.
   823  func (r *WebResourceService) Patch(id string, siteverificationwebresourceresource *SiteVerificationWebResourceResource) *WebResourcePatchCall {
   824  	c := &WebResourcePatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   825  	c.id = id
   826  	c.siteverificationwebresourceresource = siteverificationwebresourceresource
   827  	return c
   828  }
   829  
   830  // Fields allows partial responses to be retrieved. See
   831  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   832  // details.
   833  func (c *WebResourcePatchCall) Fields(s ...googleapi.Field) *WebResourcePatchCall {
   834  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   835  	return c
   836  }
   837  
   838  // Context sets the context to be used in this call's Do method.
   839  func (c *WebResourcePatchCall) Context(ctx context.Context) *WebResourcePatchCall {
   840  	c.ctx_ = ctx
   841  	return c
   842  }
   843  
   844  // Header returns a http.Header that can be modified by the caller to add
   845  // headers to the request.
   846  func (c *WebResourcePatchCall) Header() http.Header {
   847  	if c.header_ == nil {
   848  		c.header_ = make(http.Header)
   849  	}
   850  	return c.header_
   851  }
   852  
   853  func (c *WebResourcePatchCall) doRequest(alt string) (*http.Response, error) {
   854  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   855  	var body io.Reader = nil
   856  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.siteverificationwebresourceresource)
   857  	if err != nil {
   858  		return nil, err
   859  	}
   860  	c.urlParams_.Set("alt", alt)
   861  	c.urlParams_.Set("prettyPrint", "false")
   862  	urls := googleapi.ResolveRelative(c.s.BasePath, "webResource/{id}")
   863  	urls += "?" + c.urlParams_.Encode()
   864  	req, err := http.NewRequest("PATCH", urls, body)
   865  	if err != nil {
   866  		return nil, err
   867  	}
   868  	req.Header = reqHeaders
   869  	googleapi.Expand(req.URL, map[string]string{
   870  		"id": c.id,
   871  	})
   872  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   873  }
   874  
   875  // Do executes the "siteVerification.webResource.patch" call.
   876  // Any non-2xx status code is an error. Response headers are in either
   877  // *SiteVerificationWebResourceResource.ServerResponse.Header or (if a response
   878  // was returned at all) in error.(*googleapi.Error).Header. Use
   879  // googleapi.IsNotModified to check whether the returned error was because
   880  // http.StatusNotModified was returned.
   881  func (c *WebResourcePatchCall) Do(opts ...googleapi.CallOption) (*SiteVerificationWebResourceResource, error) {
   882  	gensupport.SetOptions(c.urlParams_, opts...)
   883  	res, err := c.doRequest("json")
   884  	if res != nil && res.StatusCode == http.StatusNotModified {
   885  		if res.Body != nil {
   886  			res.Body.Close()
   887  		}
   888  		return nil, gensupport.WrapError(&googleapi.Error{
   889  			Code:   res.StatusCode,
   890  			Header: res.Header,
   891  		})
   892  	}
   893  	if err != nil {
   894  		return nil, err
   895  	}
   896  	defer googleapi.CloseBody(res)
   897  	if err := googleapi.CheckResponse(res); err != nil {
   898  		return nil, gensupport.WrapError(err)
   899  	}
   900  	ret := &SiteVerificationWebResourceResource{
   901  		ServerResponse: googleapi.ServerResponse{
   902  			Header:         res.Header,
   903  			HTTPStatusCode: res.StatusCode,
   904  		},
   905  	}
   906  	target := &ret
   907  	if err := gensupport.DecodeResponse(target, res); err != nil {
   908  		return nil, err
   909  	}
   910  	return ret, nil
   911  }
   912  
   913  type WebResourceUpdateCall struct {
   914  	s                                   *Service
   915  	id                                  string
   916  	siteverificationwebresourceresource *SiteVerificationWebResourceResource
   917  	urlParams_                          gensupport.URLParams
   918  	ctx_                                context.Context
   919  	header_                             http.Header
   920  }
   921  
   922  // Update: Modify the list of owners for your website or domain.
   923  //
   924  // - id: The id of a verified site or domain.
   925  func (r *WebResourceService) Update(id string, siteverificationwebresourceresource *SiteVerificationWebResourceResource) *WebResourceUpdateCall {
   926  	c := &WebResourceUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   927  	c.id = id
   928  	c.siteverificationwebresourceresource = siteverificationwebresourceresource
   929  	return c
   930  }
   931  
   932  // Fields allows partial responses to be retrieved. See
   933  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   934  // details.
   935  func (c *WebResourceUpdateCall) Fields(s ...googleapi.Field) *WebResourceUpdateCall {
   936  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   937  	return c
   938  }
   939  
   940  // Context sets the context to be used in this call's Do method.
   941  func (c *WebResourceUpdateCall) Context(ctx context.Context) *WebResourceUpdateCall {
   942  	c.ctx_ = ctx
   943  	return c
   944  }
   945  
   946  // Header returns a http.Header that can be modified by the caller to add
   947  // headers to the request.
   948  func (c *WebResourceUpdateCall) Header() http.Header {
   949  	if c.header_ == nil {
   950  		c.header_ = make(http.Header)
   951  	}
   952  	return c.header_
   953  }
   954  
   955  func (c *WebResourceUpdateCall) doRequest(alt string) (*http.Response, error) {
   956  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   957  	var body io.Reader = nil
   958  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.siteverificationwebresourceresource)
   959  	if err != nil {
   960  		return nil, err
   961  	}
   962  	c.urlParams_.Set("alt", alt)
   963  	c.urlParams_.Set("prettyPrint", "false")
   964  	urls := googleapi.ResolveRelative(c.s.BasePath, "webResource/{id}")
   965  	urls += "?" + c.urlParams_.Encode()
   966  	req, err := http.NewRequest("PUT", urls, body)
   967  	if err != nil {
   968  		return nil, err
   969  	}
   970  	req.Header = reqHeaders
   971  	googleapi.Expand(req.URL, map[string]string{
   972  		"id": c.id,
   973  	})
   974  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   975  }
   976  
   977  // Do executes the "siteVerification.webResource.update" call.
   978  // Any non-2xx status code is an error. Response headers are in either
   979  // *SiteVerificationWebResourceResource.ServerResponse.Header or (if a response
   980  // was returned at all) in error.(*googleapi.Error).Header. Use
   981  // googleapi.IsNotModified to check whether the returned error was because
   982  // http.StatusNotModified was returned.
   983  func (c *WebResourceUpdateCall) Do(opts ...googleapi.CallOption) (*SiteVerificationWebResourceResource, error) {
   984  	gensupport.SetOptions(c.urlParams_, opts...)
   985  	res, err := c.doRequest("json")
   986  	if res != nil && res.StatusCode == http.StatusNotModified {
   987  		if res.Body != nil {
   988  			res.Body.Close()
   989  		}
   990  		return nil, gensupport.WrapError(&googleapi.Error{
   991  			Code:   res.StatusCode,
   992  			Header: res.Header,
   993  		})
   994  	}
   995  	if err != nil {
   996  		return nil, err
   997  	}
   998  	defer googleapi.CloseBody(res)
   999  	if err := googleapi.CheckResponse(res); err != nil {
  1000  		return nil, gensupport.WrapError(err)
  1001  	}
  1002  	ret := &SiteVerificationWebResourceResource{
  1003  		ServerResponse: googleapi.ServerResponse{
  1004  			Header:         res.Header,
  1005  			HTTPStatusCode: res.StatusCode,
  1006  		},
  1007  	}
  1008  	target := &ret
  1009  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1010  		return nil, err
  1011  	}
  1012  	return ret, nil
  1013  }
  1014  

View as plain text