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