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