1// Copyright 2021 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 doubleclickbidmanager provides access to the DoubleClick Bid Manager API.
8//
9// For product documentation, see: https://developers.google.com/bid-manager/
10//
11// Creating a client
12//
13// Usage example:
14//
15//   import "google.golang.org/api/doubleclickbidmanager/v1"
16//   ...
17//   ctx := context.Background()
18//   doubleclickbidmanagerService, err := doubleclickbidmanager.NewService(ctx)
19//
20// In this example, Google Application Default Credentials are used for authentication.
21//
22// For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
23//
24// Other authentication options
25//
26// To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
27//
28//   doubleclickbidmanagerService, err := doubleclickbidmanager.NewService(ctx, option.WithAPIKey("AIza..."))
29//
30// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
31//
32//   config := &oauth2.Config{...}
33//   // ...
34//   token, err := config.Exchange(ctx, ...)
35//   doubleclickbidmanagerService, err := doubleclickbidmanager.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
36//
37// See https://godoc.org/google.golang.org/api/option/ for details on options.
38package doubleclickbidmanager // import "google.golang.org/api/doubleclickbidmanager/v1"
39
40import (
41	"bytes"
42	"context"
43	"encoding/json"
44	"errors"
45	"fmt"
46	"io"
47	"net/http"
48	"net/url"
49	"strconv"
50	"strings"
51
52	googleapi "google.golang.org/api/googleapi"
53	gensupport "google.golang.org/api/internal/gensupport"
54	option "google.golang.org/api/option"
55	internaloption "google.golang.org/api/option/internaloption"
56	htransport "google.golang.org/api/transport/http"
57)
58
59// Always reference these packages, just in case the auto-generated code
60// below doesn't.
61var _ = bytes.NewBuffer
62var _ = strconv.Itoa
63var _ = fmt.Sprintf
64var _ = json.NewDecoder
65var _ = io.Copy
66var _ = url.Parse
67var _ = gensupport.MarshalJSON
68var _ = googleapi.Version
69var _ = errors.New
70var _ = strings.Replace
71var _ = context.Canceled
72var _ = internaloption.WithDefaultEndpoint
73
74const apiId = "doubleclickbidmanager:v1"
75const apiName = "doubleclickbidmanager"
76const apiVersion = "v1"
77const basePath = "https://doubleclickbidmanager.googleapis.com/doubleclickbidmanager/v1/"
78const mtlsBasePath = "https://doubleclickbidmanager.mtls.googleapis.com/doubleclickbidmanager/v1/"
79
80// NewService creates a new Service.
81func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
82	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
83	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
84	client, endpoint, err := htransport.NewClient(ctx, opts...)
85	if err != nil {
86		return nil, err
87	}
88	s, err := New(client)
89	if err != nil {
90		return nil, err
91	}
92	if endpoint != "" {
93		s.BasePath = endpoint
94	}
95	return s, nil
96}
97
98// New creates a new Service. It uses the provided http.Client for requests.
99//
100// Deprecated: please use NewService instead.
101// To provide a custom HTTP client, use option.WithHTTPClient.
102// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
103func New(client *http.Client) (*Service, error) {
104	if client == nil {
105		return nil, errors.New("client is nil")
106	}
107	s := &Service{client: client, BasePath: basePath}
108	return s, nil
109}
110
111type Service struct {
112	client    *http.Client
113	BasePath  string // API endpoint base URL
114	UserAgent string // optional additional User-Agent fragment
115}
116
117func (s *Service) userAgent() string {
118	if s.UserAgent == "" {
119		return googleapi.UserAgent
120	}
121	return googleapi.UserAgent + " " + s.UserAgent
122}
123