1// Copyright 2021 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Code generated by protoc-gen-go_gapic. DO NOT EDIT. 16 17// Package datatransfer is an auto-generated package for the 18// BigQuery Data Transfer API. 19// 20// Schedule queries or transfer external data from SaaS applications to 21// Google BigQuery on a regular basis. 22// 23// Example usage 24// 25// To get started with this package, create a client. 26// ctx := context.Background() 27// c, err := datatransfer.NewClient(ctx) 28// if err != nil { 29// // TODO: Handle error. 30// } 31// defer c.Close() 32// 33// The client will use your default application credentials. Clients should be reused instead of created as needed. 34// The methods of Client are safe for concurrent use by multiple goroutines. 35// The returned client must be Closed when it is done being used. 36// 37// Using the Client 38// 39// The following is an example of making an API call with the newly created client. 40// 41// ctx := context.Background() 42// c, err := datatransfer.NewClient(ctx) 43// if err != nil { 44// // TODO: Handle error. 45// } 46// defer c.Close() 47// 48// req := &datatransferpb.GetDataSourceRequest{ 49// // TODO: Fill request struct fields. 50// // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/bigquery/datatransfer/v1#GetDataSourceRequest. 51// } 52// resp, err := c.GetDataSource(ctx, req) 53// if err != nil { 54// // TODO: Handle error. 55// } 56// // TODO: Use resp. 57// _ = resp 58// 59// Use of Context 60// 61// The ctx passed to NewClient is used for authentication requests and 62// for creating the underlying connection, but is not used for subsequent calls. 63// Individual methods on the client use the ctx given to them. 64// 65// To close the open connection, use the Close() method. 66// 67// For information about setting deadlines, reusing contexts, and more 68// please visit https://pkg.go.dev/cloud.google.com/go. 69package datatransfer // import "cloud.google.com/go/bigquery/datatransfer/apiv1" 70 71import ( 72 "context" 73 "os" 74 "runtime" 75 "strconv" 76 "strings" 77 "unicode" 78 79 "google.golang.org/api/option" 80 "google.golang.org/grpc/metadata" 81) 82 83// For more information on implementing a client constructor hook, see 84// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. 85type clientHookParams struct{} 86type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) 87 88const versionClient = "20210921" 89 90func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { 91 out, _ := metadata.FromOutgoingContext(ctx) 92 out = out.Copy() 93 for _, md := range mds { 94 for k, v := range md { 95 out[k] = append(out[k], v...) 96 } 97 } 98 return metadata.NewOutgoingContext(ctx, out) 99} 100 101func checkDisableDeadlines() (bool, error) { 102 raw, ok := os.LookupEnv("GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE") 103 if !ok { 104 return false, nil 105 } 106 107 b, err := strconv.ParseBool(raw) 108 return b, err 109} 110 111// DefaultAuthScopes reports the default set of authentication scopes to use with this package. 112func DefaultAuthScopes() []string { 113 return []string{ 114 "https://www.googleapis.com/auth/cloud-platform", 115 } 116} 117 118// versionGo returns the Go runtime version. The returned string 119// has no whitespace, suitable for reporting in header. 120func versionGo() string { 121 const develPrefix = "devel +" 122 123 s := runtime.Version() 124 if strings.HasPrefix(s, develPrefix) { 125 s = s[len(develPrefix):] 126 if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { 127 s = s[:p] 128 } 129 return s 130 } 131 132 notSemverRune := func(r rune) bool { 133 return !strings.ContainsRune("0123456789.", r) 134 } 135 136 if strings.HasPrefix(s, "go1") { 137 s = s[2:] 138 var prerelease string 139 if p := strings.IndexFunc(s, notSemverRune); p >= 0 { 140 s, prerelease = s[:p], s[p:] 141 } 142 if strings.HasSuffix(s, ".") { 143 s += "0" 144 } else if strings.Count(s, ".") < 2 { 145 s += ".0" 146 } 147 if prerelease != "" { 148 s += "-" + prerelease 149 } 150 return s 151 } 152 return "UNKNOWN" 153} 154