...

Source file src/google.golang.org/api/realtimebidding/v1alpha/realtimebidding-gen.go

Documentation: google.golang.org/api/realtimebidding/v1alpha

     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 realtimebidding provides access to the Real-time Bidding API.
     8  //
     9  // For product documentation, see: https://developers.google.com/authorized-buyers/apis/realtimebidding/reference/rest/
    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/realtimebidding/v1alpha"
    27  //	...
    28  //	ctx := context.Background()
    29  //	realtimebiddingService, err := realtimebidding.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  //	realtimebiddingService, err := realtimebidding.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  //	realtimebiddingService, err := realtimebidding.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    49  //
    50  // See [google.golang.org/api/option.ClientOption] for details on options.
    51  package realtimebidding // import "google.golang.org/api/realtimebidding/v1alpha"
    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 = "realtimebidding:v1alpha"
    90  const apiName = "realtimebidding"
    91  const apiVersion = "v1alpha"
    92  const basePath = "https://realtimebidding.googleapis.com/"
    93  const basePathTemplate = "https://realtimebidding.UNIVERSE_DOMAIN/"
    94  const mtlsBasePath = "https://realtimebidding.mtls.googleapis.com/"
    95  
    96  // OAuth2 scopes used by this API.
    97  const (
    98  	// See, create, edit, and delete your Authorized Buyers and Open Bidding
    99  	// account entities
   100  	RealtimeBiddingScope = "https://www.googleapis.com/auth/realtime-bidding"
   101  )
   102  
   103  // NewService creates a new Service.
   104  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
   105  	scopesOption := internaloption.WithDefaultScopes(
   106  		"https://www.googleapis.com/auth/realtime-bidding",
   107  	)
   108  	// NOTE: prepend, so we don't override user-specified scopes.
   109  	opts = append([]option.ClientOption{scopesOption}, opts...)
   110  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   111  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   112  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   113  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   114  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   115  	if err != nil {
   116  		return nil, err
   117  	}
   118  	s, err := New(client)
   119  	if err != nil {
   120  		return nil, err
   121  	}
   122  	if endpoint != "" {
   123  		s.BasePath = endpoint
   124  	}
   125  	return s, nil
   126  }
   127  
   128  // New creates a new Service. It uses the provided http.Client for requests.
   129  //
   130  // Deprecated: please use NewService instead.
   131  // To provide a custom HTTP client, use option.WithHTTPClient.
   132  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   133  func New(client *http.Client) (*Service, error) {
   134  	if client == nil {
   135  		return nil, errors.New("client is nil")
   136  	}
   137  	s := &Service{client: client, BasePath: basePath}
   138  	s.Bidders = NewBiddersService(s)
   139  	return s, nil
   140  }
   141  
   142  type Service struct {
   143  	client    *http.Client
   144  	BasePath  string // API endpoint base URL
   145  	UserAgent string // optional additional User-Agent fragment
   146  
   147  	Bidders *BiddersService
   148  }
   149  
   150  func (s *Service) userAgent() string {
   151  	if s.UserAgent == "" {
   152  		return googleapi.UserAgent
   153  	}
   154  	return googleapi.UserAgent + " " + s.UserAgent
   155  }
   156  
   157  func NewBiddersService(s *Service) *BiddersService {
   158  	rs := &BiddersService{s: s}
   159  	rs.BiddingFunctions = NewBiddersBiddingFunctionsService(s)
   160  	return rs
   161  }
   162  
   163  type BiddersService struct {
   164  	s *Service
   165  
   166  	BiddingFunctions *BiddersBiddingFunctionsService
   167  }
   168  
   169  func NewBiddersBiddingFunctionsService(s *Service) *BiddersBiddingFunctionsService {
   170  	rs := &BiddersBiddingFunctionsService{s: s}
   171  	return rs
   172  }
   173  
   174  type BiddersBiddingFunctionsService struct {
   175  	s *Service
   176  }
   177  
   178  // ActivateBiddingFunctionRequest: The request to activate a bidding function.
   179  type ActivateBiddingFunctionRequest struct {
   180  }
   181  
   182  // ArchiveBiddingFunctionRequest: A request to archive a bidding function.
   183  type ArchiveBiddingFunctionRequest struct {
   184  }
   185  
   186  // BiddingFunction: The bidding function to be executed as part of the
   187  // TURTLEDOVE simulation experiment bidding flow.
   188  type BiddingFunction struct {
   189  	// BiddingFunction: The raw Javascript source code of the bidding function.
   190  	BiddingFunction string `json:"biddingFunction,omitempty"`
   191  	// Name: The name of the bidding function that must follow the pattern:
   192  	// `bidders/{bidder_account_id}/biddingFunctions/{bidding_function_name}`.
   193  	Name string `json:"name,omitempty"`
   194  	// State: Output only. The state of the bidding function.
   195  	//
   196  	// Possible values:
   197  	//   "STATE_UNSPECIFIED" - Default value that should not be used.
   198  	//   "ACTIVE" - An active function. Only `ACTIVE` bidding functions or ad
   199  	// scoring functions are made available for the server-side TURTLEDOVE
   200  	// simulations. Every account is limited to 10 active bidding functions per
   201  	// account.
   202  	//   "ARCHIVED" - A function that is no longer made available for invocation in
   203  	// a simulation and instead archived. An archived function can later be made
   204  	// active by activating the function through `ActivateBiddingFunction`.
   205  	State string `json:"state,omitempty"`
   206  	// Type: The type of the bidding function to be created.
   207  	//
   208  	// Possible values:
   209  	//   "FUNCTION_TYPE_UNSPECIFIED" - Default value that should not be used.
   210  	//   "TURTLEDOVE_SIMULATION_BIDDING_FUNCTION" - Bidding function that can be
   211  	// used by Authorized Buyers in the original TURTLEDOVE simulation. See
   212  	// documentation on the TURTLEDOVE simulation at
   213  	// https://developers.google.com/authorized-buyers/rtb/turtledove. The function
   214  	// takes in a Javascript object, `inputs`, that contains the following named
   215  	// fields: `openrtbContextualBidRequest` OR `googleContextualBidRequest`,
   216  	// `customContextualSignal`, `interestBasedBidData`, `interestGroupData`, and
   217  	// returns the bid price CPM. Example: ``` /* Returns a bid price CPM. * *
   218  	// @param {Object} inputs an object with the * following named fields: * -
   219  	// openrtbContextualBidRequest * OR googleContextualBidRequest * -
   220  	// customContextualSignal * - interestBasedBidData * - interestGroupData */
   221  	// function biddingFunction(inputs) { ... return
   222  	// inputs.interestBasedBidData.cpm *
   223  	// inputs.customContextualSignals.placementMultiplier; } ```
   224  	//   "FLEDGE_BIDDING_FUNCTION" - Buyer's interest group bidding function that
   225  	// can be used by Authorized Buyers in the FLEDGE simulation. See the FLEDGE
   226  	// explainer at
   227  	// https://github.com/WICG/turtledove/blob/main/FLEDGE.md#32-on-device-bidding.
   228  	// The function takes one argument, `inputs`, that contains an object with the
   229  	// following named fields of the form: ``` { "interestGroup" : { "ad" : [
   230  	// "buyerCreativeId": "...", # Ad creative ID "adData": { # JSON object } ],
   231  	// "userBiddingSignals": { . # JSON object } }, "auctionSignals": { "url": #
   232  	// string, "slotVisibility": # enum value, "slotDimensions": [ { "height": #
   233  	// number value "width": # number value } ] }, "perBuyerSignals": { # JSON
   234  	// object }, "trustedBiddingSignals": { # JSON object }, "browserSignals": {
   235  	// "recent_impression_ages_secs": [ # Array of integers. Not yet populated. ] }
   236  	// } ``` `interestGroup`: An object containing a list of `ad` objects, which
   237  	// contain the following named fields: - `buyerCreativeId`: The ad creative ID
   238  	// string. - `adData`: Any JSON value of the bidder's choosing to contain data
   239  	// associated with an ad provided in `BidResponse.ad.adslot.ad_data` for the
   240  	// Google Authorized Buyers protocol and `BidResponse.seatbid.bid.ext.ad_data`
   241  	// for the OpenRTB protocol. - `userBiddingSignals`: Any JSON value of the
   242  	// bidder's choosing containing interest group data that corresponds to
   243  	// user_bidding_signals (as in FLEDGE). This field will be populated from
   244  	// `BidResponse.interest_group_map.user_bidding_signals` for Google Authorized
   245  	// Buyers protocol and
   246  	// `BidResponse.ext.interest_group_map.user_bidding_signals` for the OpenRTB
   247  	// protocol. `auctionSignals`: Contains data from the seller. It corresponds to
   248  	// the auction signals data described in the FLEDGE proposal. It is an object
   249  	// containing the following named fields: - `url`: The string URL of the page
   250  	// with parameters removed. - `slotVisibility`: Enum of one of the following
   251  	// potential values: - NO_DETECTION = 0 - ABOVE_THE_FOLD = 1 - BELOW_THE_FOLD =
   252  	// 2 - `slotDimensions`: A list of objects containing containing width and
   253  	// height pairs in `width` and `height` fields, respectively, from
   254  	// `BidRequest.adslot.width` and `BidRequest.adslot.height` for the Google
   255  	// Authorized Buyers protocol and `BidRequest.imp.banner.format.w` and
   256  	// `BidRequest.imp.banner.format.h` for the OpenRTB protocol.
   257  	// `perBuyerSignals`: The contextual signals from the bid response that are
   258  	// populated in
   259  	// `BidResponse.interest_group_bidding.interest_group_buyers.per_buyer_signals`
   260  	// for the Google Authorized Buyers protocol and
   261  	// `BidResponse.ext.interest_group_bidding.interest_group_buyers.per_buyer_signa
   262  	// ls` for the OpenRTB protocol. These signals can be of any JSON format of
   263  	// your choosing, however, the buyer's domain name must match between: - the
   264  	// interest group response in `BidResponse.interest_group_map.buyer_domain` for
   265  	// the Google Authorized Buyers protocol or in
   266  	// `BidResponse.ext.interest_group_map.buyer_domain` for the OpenRTB protocol.
   267  	// - the contextual response as a key to the map in
   268  	// `BidResponse.interest_group_bidding.interest_group_buyers` for the Google
   269  	// Authorized Buyers protocol or in
   270  	// `BidResponse.ext.interest_group_bidding.interest_group_buyers` for the
   271  	// OpenRTB protocol. In other words, there must be a match between the buyer
   272  	// domain of the contextual per_buyer_signals and the domain of an interest
   273  	// group. `trustedBiddingSignals`: The trusted bidding signals that corresponds
   274  	// to the trusted_bidding_signals in the FLEDGE proposal. It is provided in the
   275  	// interest group response as
   276  	// `BidResponse.interest_group_map.user_bidding_signals` for the Google
   277  	// Authorized Buyers protocol and
   278  	// `BidResponse.ext.interest_group_map.user_bidding_signals` for the OpenRTB
   279  	// protocol. This field can be any JSON format of your choosing.
   280  	// `browserSignals`: An object of simulated browser-provider signals. It is an
   281  	// object with a single named field, `recent_impression_ages_secs`, that
   282  	// contains a list of estimated number value recent impression ages in seconds
   283  	// for a given interest group. `recent_impression_ages_secs` is not yet
   284  	// populated. The function returns the string creative ID of the selected ad,
   285  	// the bid price CPM, and (optionally) selected product IDs. In addition, the
   286  	// bidding function may populate an optional debug string that may be used for
   287  	// remote debugging and troubleshooting of a bidder-provided bidding function.
   288  	// The debug string should not contain a user identifier. The maximum length of
   289  	// the debug string is 200 bytes. This debug string is available in
   290  	// `BidResponseFeedback`
   291  	// (https://developers.google.com/authorized-buyers/rtb/realtime-bidding-guide#bidresponsefeedback-object)
   292  	// and `BidFeedback`
   293  	// (https://developers.google.com/authorized-buyers/rtb/openrtb-guide#bidfeedback),
   294  	// for the Google protocol and OpenRTB protocol respectively. In addition, the
   295  	// debug string can be inserted into the creative HTML snippet through macro
   296  	// substitution if the following string is included in the snippet:
   297  	// “%%DEBUG_STRING%%”. Ensure the debug string complies with [Platform
   298  	// Program
   299  	// Policies](https://support.google.com/platformspolicy/answer/3013851). Sample
   300  	// Bidding Function: ``` function biddingFunction(inputs) { ... return {
   301  	// "buyerCreativeId": "ad_creative_id_1", "bidPriceCpm": 0.3, "productIds":
   302  	// ["product_id_1", "product_id_2", "product_id_3"] "debugString": "Bidding
   303  	// function executed successfully!" } } ```
   304  	Type string `json:"type,omitempty"`
   305  
   306  	// ServerResponse contains the HTTP response code and headers from the server.
   307  	googleapi.ServerResponse `json:"-"`
   308  	// ForceSendFields is a list of field names (e.g. "BiddingFunction") to
   309  	// unconditionally include in API requests. By default, fields with empty or
   310  	// default values are omitted from API requests. See
   311  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   312  	// details.
   313  	ForceSendFields []string `json:"-"`
   314  	// NullFields is a list of field names (e.g. "BiddingFunction") to include in
   315  	// API requests with the JSON null value. By default, fields with empty values
   316  	// are omitted from API requests. See
   317  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   318  	NullFields []string `json:"-"`
   319  }
   320  
   321  func (s *BiddingFunction) MarshalJSON() ([]byte, error) {
   322  	type NoMethod BiddingFunction
   323  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   324  }
   325  
   326  // ListBiddingFunctionsResponse: A response containing a list of a bidder's
   327  // bidding functions.
   328  type ListBiddingFunctionsResponse struct {
   329  	// BiddingFunctions: A list of a bidder's bidding functions.
   330  	BiddingFunctions []*BiddingFunction `json:"biddingFunctions,omitempty"`
   331  	// NextPageToken: A token which can be passed to a subsequent call to the
   332  	// `ListBiddingFunctions` method to retrieve the next page of results in
   333  	// ListBiddingFunctionsRequest.pageToken.
   334  	NextPageToken string `json:"nextPageToken,omitempty"`
   335  
   336  	// ServerResponse contains the HTTP response code and headers from the server.
   337  	googleapi.ServerResponse `json:"-"`
   338  	// ForceSendFields is a list of field names (e.g. "BiddingFunctions") to
   339  	// unconditionally include in API requests. By default, fields with empty or
   340  	// default values are omitted from API requests. See
   341  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   342  	// details.
   343  	ForceSendFields []string `json:"-"`
   344  	// NullFields is a list of field names (e.g. "BiddingFunctions") to include in
   345  	// API requests with the JSON null value. By default, fields with empty values
   346  	// are omitted from API requests. See
   347  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   348  	NullFields []string `json:"-"`
   349  }
   350  
   351  func (s *ListBiddingFunctionsResponse) MarshalJSON() ([]byte, error) {
   352  	type NoMethod ListBiddingFunctionsResponse
   353  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   354  }
   355  
   356  type BiddersBiddingFunctionsActivateCall struct {
   357  	s                              *Service
   358  	name                           string
   359  	activatebiddingfunctionrequest *ActivateBiddingFunctionRequest
   360  	urlParams_                     gensupport.URLParams
   361  	ctx_                           context.Context
   362  	header_                        http.Header
   363  }
   364  
   365  // Activate: Activates an existing bidding function. An activated function is
   366  // available for invocation for the server-side TURTLEDOVE simulations.
   367  //
   368  //   - name: The name of the bidding function to activate. Format:
   369  //     `bidders/{bidder_account_id}/biddingFunction/{bidding_function_name}`.
   370  func (r *BiddersBiddingFunctionsService) Activate(name string, activatebiddingfunctionrequest *ActivateBiddingFunctionRequest) *BiddersBiddingFunctionsActivateCall {
   371  	c := &BiddersBiddingFunctionsActivateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   372  	c.name = name
   373  	c.activatebiddingfunctionrequest = activatebiddingfunctionrequest
   374  	return c
   375  }
   376  
   377  // Fields allows partial responses to be retrieved. See
   378  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   379  // details.
   380  func (c *BiddersBiddingFunctionsActivateCall) Fields(s ...googleapi.Field) *BiddersBiddingFunctionsActivateCall {
   381  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   382  	return c
   383  }
   384  
   385  // Context sets the context to be used in this call's Do method.
   386  func (c *BiddersBiddingFunctionsActivateCall) Context(ctx context.Context) *BiddersBiddingFunctionsActivateCall {
   387  	c.ctx_ = ctx
   388  	return c
   389  }
   390  
   391  // Header returns a http.Header that can be modified by the caller to add
   392  // headers to the request.
   393  func (c *BiddersBiddingFunctionsActivateCall) Header() http.Header {
   394  	if c.header_ == nil {
   395  		c.header_ = make(http.Header)
   396  	}
   397  	return c.header_
   398  }
   399  
   400  func (c *BiddersBiddingFunctionsActivateCall) doRequest(alt string) (*http.Response, error) {
   401  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   402  	var body io.Reader = nil
   403  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.activatebiddingfunctionrequest)
   404  	if err != nil {
   405  		return nil, err
   406  	}
   407  	c.urlParams_.Set("alt", alt)
   408  	c.urlParams_.Set("prettyPrint", "false")
   409  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+name}:activate")
   410  	urls += "?" + c.urlParams_.Encode()
   411  	req, err := http.NewRequest("POST", urls, body)
   412  	if err != nil {
   413  		return nil, err
   414  	}
   415  	req.Header = reqHeaders
   416  	googleapi.Expand(req.URL, map[string]string{
   417  		"name": c.name,
   418  	})
   419  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   420  }
   421  
   422  // Do executes the "realtimebidding.bidders.biddingFunctions.activate" call.
   423  // Any non-2xx status code is an error. Response headers are in either
   424  // *BiddingFunction.ServerResponse.Header or (if a response was returned at
   425  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   426  // check whether the returned error was because http.StatusNotModified was
   427  // returned.
   428  func (c *BiddersBiddingFunctionsActivateCall) Do(opts ...googleapi.CallOption) (*BiddingFunction, error) {
   429  	gensupport.SetOptions(c.urlParams_, opts...)
   430  	res, err := c.doRequest("json")
   431  	if res != nil && res.StatusCode == http.StatusNotModified {
   432  		if res.Body != nil {
   433  			res.Body.Close()
   434  		}
   435  		return nil, gensupport.WrapError(&googleapi.Error{
   436  			Code:   res.StatusCode,
   437  			Header: res.Header,
   438  		})
   439  	}
   440  	if err != nil {
   441  		return nil, err
   442  	}
   443  	defer googleapi.CloseBody(res)
   444  	if err := googleapi.CheckResponse(res); err != nil {
   445  		return nil, gensupport.WrapError(err)
   446  	}
   447  	ret := &BiddingFunction{
   448  		ServerResponse: googleapi.ServerResponse{
   449  			Header:         res.Header,
   450  			HTTPStatusCode: res.StatusCode,
   451  		},
   452  	}
   453  	target := &ret
   454  	if err := gensupport.DecodeResponse(target, res); err != nil {
   455  		return nil, err
   456  	}
   457  	return ret, nil
   458  }
   459  
   460  type BiddersBiddingFunctionsArchiveCall struct {
   461  	s                             *Service
   462  	name                          string
   463  	archivebiddingfunctionrequest *ArchiveBiddingFunctionRequest
   464  	urlParams_                    gensupport.URLParams
   465  	ctx_                          context.Context
   466  	header_                       http.Header
   467  }
   468  
   469  // Archive: Archives an existing bidding function. An archived function will
   470  // not be available for function invocation for the server-side TURTLEDOVE
   471  // simulations unless it is activated.
   472  //
   473  //   - name: The name of the bidding function to archive. Format:
   474  //     `bidders/{bidder_account_id}/biddingFunction/{bidding_function_name}`.
   475  func (r *BiddersBiddingFunctionsService) Archive(name string, archivebiddingfunctionrequest *ArchiveBiddingFunctionRequest) *BiddersBiddingFunctionsArchiveCall {
   476  	c := &BiddersBiddingFunctionsArchiveCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   477  	c.name = name
   478  	c.archivebiddingfunctionrequest = archivebiddingfunctionrequest
   479  	return c
   480  }
   481  
   482  // Fields allows partial responses to be retrieved. See
   483  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   484  // details.
   485  func (c *BiddersBiddingFunctionsArchiveCall) Fields(s ...googleapi.Field) *BiddersBiddingFunctionsArchiveCall {
   486  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   487  	return c
   488  }
   489  
   490  // Context sets the context to be used in this call's Do method.
   491  func (c *BiddersBiddingFunctionsArchiveCall) Context(ctx context.Context) *BiddersBiddingFunctionsArchiveCall {
   492  	c.ctx_ = ctx
   493  	return c
   494  }
   495  
   496  // Header returns a http.Header that can be modified by the caller to add
   497  // headers to the request.
   498  func (c *BiddersBiddingFunctionsArchiveCall) Header() http.Header {
   499  	if c.header_ == nil {
   500  		c.header_ = make(http.Header)
   501  	}
   502  	return c.header_
   503  }
   504  
   505  func (c *BiddersBiddingFunctionsArchiveCall) doRequest(alt string) (*http.Response, error) {
   506  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   507  	var body io.Reader = nil
   508  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.archivebiddingfunctionrequest)
   509  	if err != nil {
   510  		return nil, err
   511  	}
   512  	c.urlParams_.Set("alt", alt)
   513  	c.urlParams_.Set("prettyPrint", "false")
   514  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+name}:archive")
   515  	urls += "?" + c.urlParams_.Encode()
   516  	req, err := http.NewRequest("POST", urls, body)
   517  	if err != nil {
   518  		return nil, err
   519  	}
   520  	req.Header = reqHeaders
   521  	googleapi.Expand(req.URL, map[string]string{
   522  		"name": c.name,
   523  	})
   524  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   525  }
   526  
   527  // Do executes the "realtimebidding.bidders.biddingFunctions.archive" call.
   528  // Any non-2xx status code is an error. Response headers are in either
   529  // *BiddingFunction.ServerResponse.Header or (if a response was returned at
   530  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   531  // check whether the returned error was because http.StatusNotModified was
   532  // returned.
   533  func (c *BiddersBiddingFunctionsArchiveCall) Do(opts ...googleapi.CallOption) (*BiddingFunction, error) {
   534  	gensupport.SetOptions(c.urlParams_, opts...)
   535  	res, err := c.doRequest("json")
   536  	if res != nil && res.StatusCode == http.StatusNotModified {
   537  		if res.Body != nil {
   538  			res.Body.Close()
   539  		}
   540  		return nil, gensupport.WrapError(&googleapi.Error{
   541  			Code:   res.StatusCode,
   542  			Header: res.Header,
   543  		})
   544  	}
   545  	if err != nil {
   546  		return nil, err
   547  	}
   548  	defer googleapi.CloseBody(res)
   549  	if err := googleapi.CheckResponse(res); err != nil {
   550  		return nil, gensupport.WrapError(err)
   551  	}
   552  	ret := &BiddingFunction{
   553  		ServerResponse: googleapi.ServerResponse{
   554  			Header:         res.Header,
   555  			HTTPStatusCode: res.StatusCode,
   556  		},
   557  	}
   558  	target := &ret
   559  	if err := gensupport.DecodeResponse(target, res); err != nil {
   560  		return nil, err
   561  	}
   562  	return ret, nil
   563  }
   564  
   565  type BiddersBiddingFunctionsCreateCall struct {
   566  	s               *Service
   567  	parent          string
   568  	biddingfunction *BiddingFunction
   569  	urlParams_      gensupport.URLParams
   570  	ctx_            context.Context
   571  	header_         http.Header
   572  }
   573  
   574  // Create: Creates a new bidding function.
   575  //
   576  //   - parent: The name of the bidder for which to create the bidding function.
   577  //     Format: `bidders/{bidderAccountId}`.
   578  func (r *BiddersBiddingFunctionsService) Create(parent string, biddingfunction *BiddingFunction) *BiddersBiddingFunctionsCreateCall {
   579  	c := &BiddersBiddingFunctionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   580  	c.parent = parent
   581  	c.biddingfunction = biddingfunction
   582  	return c
   583  }
   584  
   585  // Fields allows partial responses to be retrieved. See
   586  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   587  // details.
   588  func (c *BiddersBiddingFunctionsCreateCall) Fields(s ...googleapi.Field) *BiddersBiddingFunctionsCreateCall {
   589  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   590  	return c
   591  }
   592  
   593  // Context sets the context to be used in this call's Do method.
   594  func (c *BiddersBiddingFunctionsCreateCall) Context(ctx context.Context) *BiddersBiddingFunctionsCreateCall {
   595  	c.ctx_ = ctx
   596  	return c
   597  }
   598  
   599  // Header returns a http.Header that can be modified by the caller to add
   600  // headers to the request.
   601  func (c *BiddersBiddingFunctionsCreateCall) Header() http.Header {
   602  	if c.header_ == nil {
   603  		c.header_ = make(http.Header)
   604  	}
   605  	return c.header_
   606  }
   607  
   608  func (c *BiddersBiddingFunctionsCreateCall) doRequest(alt string) (*http.Response, error) {
   609  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   610  	var body io.Reader = nil
   611  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.biddingfunction)
   612  	if err != nil {
   613  		return nil, err
   614  	}
   615  	c.urlParams_.Set("alt", alt)
   616  	c.urlParams_.Set("prettyPrint", "false")
   617  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+parent}/biddingFunctions")
   618  	urls += "?" + c.urlParams_.Encode()
   619  	req, err := http.NewRequest("POST", urls, body)
   620  	if err != nil {
   621  		return nil, err
   622  	}
   623  	req.Header = reqHeaders
   624  	googleapi.Expand(req.URL, map[string]string{
   625  		"parent": c.parent,
   626  	})
   627  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   628  }
   629  
   630  // Do executes the "realtimebidding.bidders.biddingFunctions.create" call.
   631  // Any non-2xx status code is an error. Response headers are in either
   632  // *BiddingFunction.ServerResponse.Header or (if a response was returned at
   633  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   634  // check whether the returned error was because http.StatusNotModified was
   635  // returned.
   636  func (c *BiddersBiddingFunctionsCreateCall) Do(opts ...googleapi.CallOption) (*BiddingFunction, error) {
   637  	gensupport.SetOptions(c.urlParams_, opts...)
   638  	res, err := c.doRequest("json")
   639  	if res != nil && res.StatusCode == http.StatusNotModified {
   640  		if res.Body != nil {
   641  			res.Body.Close()
   642  		}
   643  		return nil, gensupport.WrapError(&googleapi.Error{
   644  			Code:   res.StatusCode,
   645  			Header: res.Header,
   646  		})
   647  	}
   648  	if err != nil {
   649  		return nil, err
   650  	}
   651  	defer googleapi.CloseBody(res)
   652  	if err := googleapi.CheckResponse(res); err != nil {
   653  		return nil, gensupport.WrapError(err)
   654  	}
   655  	ret := &BiddingFunction{
   656  		ServerResponse: googleapi.ServerResponse{
   657  			Header:         res.Header,
   658  			HTTPStatusCode: res.StatusCode,
   659  		},
   660  	}
   661  	target := &ret
   662  	if err := gensupport.DecodeResponse(target, res); err != nil {
   663  		return nil, err
   664  	}
   665  	return ret, nil
   666  }
   667  
   668  type BiddersBiddingFunctionsListCall struct {
   669  	s            *Service
   670  	parent       string
   671  	urlParams_   gensupport.URLParams
   672  	ifNoneMatch_ string
   673  	ctx_         context.Context
   674  	header_      http.Header
   675  }
   676  
   677  // List: Lists the bidding functions that a bidder currently has registered.
   678  //
   679  //   - parent: Name of the bidder whose bidding functions will be listed. Format:
   680  //     `bidders/{bidder_account_id}`.
   681  func (r *BiddersBiddingFunctionsService) List(parent string) *BiddersBiddingFunctionsListCall {
   682  	c := &BiddersBiddingFunctionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   683  	c.parent = parent
   684  	return c
   685  }
   686  
   687  // PageSize sets the optional parameter "pageSize": The maximum number of
   688  // bidding functions to return.
   689  func (c *BiddersBiddingFunctionsListCall) PageSize(pageSize int64) *BiddersBiddingFunctionsListCall {
   690  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   691  	return c
   692  }
   693  
   694  // PageToken sets the optional parameter "pageToken": A token identifying a
   695  // page of results the server should return. This value is received from a
   696  // previous `ListBiddingFunctions` call in
   697  // ListBiddingFunctionsResponse.nextPageToken.
   698  func (c *BiddersBiddingFunctionsListCall) PageToken(pageToken string) *BiddersBiddingFunctionsListCall {
   699  	c.urlParams_.Set("pageToken", pageToken)
   700  	return c
   701  }
   702  
   703  // Fields allows partial responses to be retrieved. See
   704  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   705  // details.
   706  func (c *BiddersBiddingFunctionsListCall) Fields(s ...googleapi.Field) *BiddersBiddingFunctionsListCall {
   707  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   708  	return c
   709  }
   710  
   711  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   712  // object's ETag matches the given value. This is useful for getting updates
   713  // only after the object has changed since the last request.
   714  func (c *BiddersBiddingFunctionsListCall) IfNoneMatch(entityTag string) *BiddersBiddingFunctionsListCall {
   715  	c.ifNoneMatch_ = entityTag
   716  	return c
   717  }
   718  
   719  // Context sets the context to be used in this call's Do method.
   720  func (c *BiddersBiddingFunctionsListCall) Context(ctx context.Context) *BiddersBiddingFunctionsListCall {
   721  	c.ctx_ = ctx
   722  	return c
   723  }
   724  
   725  // Header returns a http.Header that can be modified by the caller to add
   726  // headers to the request.
   727  func (c *BiddersBiddingFunctionsListCall) Header() http.Header {
   728  	if c.header_ == nil {
   729  		c.header_ = make(http.Header)
   730  	}
   731  	return c.header_
   732  }
   733  
   734  func (c *BiddersBiddingFunctionsListCall) doRequest(alt string) (*http.Response, error) {
   735  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   736  	if c.ifNoneMatch_ != "" {
   737  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   738  	}
   739  	var body io.Reader = nil
   740  	c.urlParams_.Set("alt", alt)
   741  	c.urlParams_.Set("prettyPrint", "false")
   742  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha/{+parent}/biddingFunctions")
   743  	urls += "?" + c.urlParams_.Encode()
   744  	req, err := http.NewRequest("GET", urls, body)
   745  	if err != nil {
   746  		return nil, err
   747  	}
   748  	req.Header = reqHeaders
   749  	googleapi.Expand(req.URL, map[string]string{
   750  		"parent": c.parent,
   751  	})
   752  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   753  }
   754  
   755  // Do executes the "realtimebidding.bidders.biddingFunctions.list" call.
   756  // Any non-2xx status code is an error. Response headers are in either
   757  // *ListBiddingFunctionsResponse.ServerResponse.Header or (if a response was
   758  // returned at all) in error.(*googleapi.Error).Header. Use
   759  // googleapi.IsNotModified to check whether the returned error was because
   760  // http.StatusNotModified was returned.
   761  func (c *BiddersBiddingFunctionsListCall) Do(opts ...googleapi.CallOption) (*ListBiddingFunctionsResponse, error) {
   762  	gensupport.SetOptions(c.urlParams_, opts...)
   763  	res, err := c.doRequest("json")
   764  	if res != nil && res.StatusCode == http.StatusNotModified {
   765  		if res.Body != nil {
   766  			res.Body.Close()
   767  		}
   768  		return nil, gensupport.WrapError(&googleapi.Error{
   769  			Code:   res.StatusCode,
   770  			Header: res.Header,
   771  		})
   772  	}
   773  	if err != nil {
   774  		return nil, err
   775  	}
   776  	defer googleapi.CloseBody(res)
   777  	if err := googleapi.CheckResponse(res); err != nil {
   778  		return nil, gensupport.WrapError(err)
   779  	}
   780  	ret := &ListBiddingFunctionsResponse{
   781  		ServerResponse: googleapi.ServerResponse{
   782  			Header:         res.Header,
   783  			HTTPStatusCode: res.StatusCode,
   784  		},
   785  	}
   786  	target := &ret
   787  	if err := gensupport.DecodeResponse(target, res); err != nil {
   788  		return nil, err
   789  	}
   790  	return ret, nil
   791  }
   792  
   793  // Pages invokes f for each page of results.
   794  // A non-nil error returned from f will halt the iteration.
   795  // The provided context supersedes any context provided to the Context method.
   796  func (c *BiddersBiddingFunctionsListCall) Pages(ctx context.Context, f func(*ListBiddingFunctionsResponse) error) error {
   797  	c.ctx_ = ctx
   798  	defer c.PageToken(c.urlParams_.Get("pageToken"))
   799  	for {
   800  		x, err := c.Do()
   801  		if err != nil {
   802  			return err
   803  		}
   804  		if err := f(x); err != nil {
   805  			return err
   806  		}
   807  		if x.NextPageToken == "" {
   808  			return nil
   809  		}
   810  		c.PageToken(x.NextPageToken)
   811  	}
   812  }
   813  

View as plain text