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