1// Copyright 2021 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 privateca is an auto-generated package for the 18// Certificate Authority API. 19// 20// The Certificate Authority Service API is a highly-available, scalable 21// service that enables you to simplify and automate the management of 22// private certificate authorities (CAs) while staying in control of your 23// private keys." 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 https://pkg.go.dev/cloud.google.com/go. 35package privateca // import "cloud.google.com/go/security/privateca/apiv1" 36 37import ( 38 "context" 39 "os" 40 "runtime" 41 "strconv" 42 "strings" 43 "unicode" 44 45 "google.golang.org/api/option" 46 "google.golang.org/grpc/metadata" 47) 48 49// For more information on implementing a client constructor hook, see 50// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. 51type clientHookParams struct{} 52type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) 53 54const versionClient = "20210805" 55 56func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { 57 out, _ := metadata.FromOutgoingContext(ctx) 58 out = out.Copy() 59 for _, md := range mds { 60 for k, v := range md { 61 out[k] = append(out[k], v...) 62 } 63 } 64 return metadata.NewOutgoingContext(ctx, out) 65} 66 67func checkDisableDeadlines() (bool, error) { 68 raw, ok := os.LookupEnv("GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE") 69 if !ok { 70 return false, nil 71 } 72 73 b, err := strconv.ParseBool(raw) 74 return b, err 75} 76 77// DefaultAuthScopes reports the default set of authentication scopes to use with this package. 78func DefaultAuthScopes() []string { 79 return []string{ 80 "https://www.googleapis.com/auth/cloud-platform", 81 } 82} 83 84// versionGo returns the Go runtime version. The returned string 85// has no whitespace, suitable for reporting in header. 86func versionGo() string { 87 const develPrefix = "devel +" 88 89 s := runtime.Version() 90 if strings.HasPrefix(s, develPrefix) { 91 s = s[len(develPrefix):] 92 if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { 93 s = s[:p] 94 } 95 return s 96 } 97 98 notSemverRune := func(r rune) bool { 99 return !strings.ContainsRune("0123456789.", r) 100 } 101 102 if strings.HasPrefix(s, "go1") { 103 s = s[2:] 104 var prerelease string 105 if p := strings.IndexFunc(s, notSemverRune); p >= 0 { 106 s, prerelease = s[:p], s[p:] 107 } 108 if strings.HasSuffix(s, ".") { 109 s += "0" 110 } else if strings.Count(s, ".") < 2 { 111 s += ".0" 112 } 113 if prerelease != "" { 114 s += "-" + prerelease 115 } 116 return s 117 } 118 return "UNKNOWN" 119} 120