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 dialogflow is an auto-generated package for the
18// Dialogflow API.
19//
20// Builds conversational interfaces (for example, chatbots, and voice-powered
21// apps and devices).
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 dialogflow // import "cloud.google.com/go/dialogflow/apiv2"
34
35import (
36	"context"
37	"runtime"
38	"strings"
39	"unicode"
40
41	"google.golang.org/grpc/metadata"
42)
43
44const versionClient = "20200116"
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		"https://www.googleapis.com/auth/dialogflow",
62	}
63}
64
65// versionGo returns the Go runtime version. The returned string
66// has no whitespace, suitable for reporting in header.
67func versionGo() string {
68	const develPrefix = "devel +"
69
70	s := runtime.Version()
71	if strings.HasPrefix(s, develPrefix) {
72		s = s[len(develPrefix):]
73		if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 {
74			s = s[:p]
75		}
76		return s
77	}
78
79	notSemverRune := func(r rune) bool {
80		return !strings.ContainsRune("0123456789.", r)
81	}
82
83	if strings.HasPrefix(s, "go1") {
84		s = s[2:]
85		var prerelease string
86		if p := strings.IndexFunc(s, notSemverRune); p >= 0 {
87			s, prerelease = s[:p], s[p:]
88		}
89		if strings.HasSuffix(s, ".") {
90			s += "0"
91		} else if strings.Count(s, ".") < 2 {
92			s += ".0"
93		}
94		if prerelease != "" {
95			s += "-" + prerelease
96		}
97		return s
98	}
99	return "UNKNOWN"
100}
101