1// Copyright 2020 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 cloudtasks is an auto-generated package for the 18// Cloud Tasks API. 19// 20// Manages the execution of large numbers of distributed requests. 21// 22// NOTE: This package is in beta. It is not stable, and may be subject to changes. 23// 24// Use of Context 25// 26// The ctx passed to NewClient is used for authentication requests and 27// for creating the underlying connection, but is not used for subsequent calls. 28// Individual methods on the client use the ctx given to them. 29// 30// To close the open connection, use the Close() method. 31// 32// For information about setting deadlines, reusing contexts, and more 33// please visit godoc.org/cloud.google.com/go. 34package cloudtasks // import "cloud.google.com/go/cloudtasks/apiv2beta3" 35 36import ( 37 "context" 38 "runtime" 39 "strings" 40 "unicode" 41 42 "google.golang.org/api/option" 43 "google.golang.org/grpc/metadata" 44) 45 46// For more information on implementing a client constructor hook, see 47// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. 48type clientHookParams struct{} 49type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) 50 51const versionClient = "20200618" 52 53func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { 54 out, _ := metadata.FromOutgoingContext(ctx) 55 out = out.Copy() 56 for _, md := range mds { 57 for k, v := range md { 58 out[k] = append(out[k], v...) 59 } 60 } 61 return metadata.NewOutgoingContext(ctx, out) 62} 63 64// DefaultAuthScopes reports the default set of authentication scopes to use with this package. 65func DefaultAuthScopes() []string { 66 return []string{ 67 "https://www.googleapis.com/auth/cloud-platform", 68 } 69} 70 71// versionGo returns the Go runtime version. The returned string 72// has no whitespace, suitable for reporting in header. 73func versionGo() string { 74 const develPrefix = "devel +" 75 76 s := runtime.Version() 77 if strings.HasPrefix(s, develPrefix) { 78 s = s[len(develPrefix):] 79 if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { 80 s = s[:p] 81 } 82 return s 83 } 84 85 notSemverRune := func(r rune) bool { 86 return !strings.ContainsRune("0123456789.", r) 87 } 88 89 if strings.HasPrefix(s, "go1") { 90 s = s[2:] 91 var prerelease string 92 if p := strings.IndexFunc(s, notSemverRune); p >= 0 { 93 s, prerelease = s[:p], s[p:] 94 } 95 if strings.HasSuffix(s, ".") { 96 s += "0" 97 } else if strings.Count(s, ".") < 2 { 98 s += ".0" 99 } 100 if prerelease != "" { 101 s += "-" + prerelease 102 } 103 return s 104 } 105 return "UNKNOWN" 106} 107