Debian Codegraph @

realtimebidding/v1alpha/realtimebidding-gen.go

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