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