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 resourcemanager is an auto-generated package for the 18// Cloud Resource Manager API. 19// 20// Creates, reads, and updates metadata for Google Cloud Platform resource 21// containers. 22// 23// NOTE: This package is in beta. It is not stable, and may be subject to changes. 24// 25// Example usage 26// 27// To get started with this package, create a client. 28// ctx := context.Background() 29// c, err := resourcemanager.NewFoldersClient(ctx) 30// if err != nil { 31// // TODO: Handle error. 32// } 33// defer c.Close() 34// 35// The client will use your default application credentials. Clients should be reused instead of created as needed. 36// The methods of Client are safe for concurrent use by multiple goroutines. 37// The returned client must be Closed when it is done being used. 38// 39// Using the Client 40// 41// The following is an example of making an API call with the newly created client. 42// 43// ctx := context.Background() 44// c, err := resourcemanager.NewFoldersClient(ctx) 45// if err != nil { 46// // TODO: Handle error. 47// } 48// defer c.Close() 49// 50// req := &resourcemanagerpb.GetFolderRequest{ 51// // TODO: Fill request struct fields. 52// // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/resourcemanager/v3#GetFolderRequest. 53// } 54// resp, err := c.GetFolder(ctx, req) 55// if err != nil { 56// // TODO: Handle error. 57// } 58// // TODO: Use resp. 59// _ = resp 60// 61// Use of Context 62// 63// The ctx passed to NewClient is used for authentication requests and 64// for creating the underlying connection, but is not used for subsequent calls. 65// Individual methods on the client use the ctx given to them. 66// 67// To close the open connection, use the Close() method. 68// 69// For information about setting deadlines, reusing contexts, and more 70// please visit https://pkg.go.dev/cloud.google.com/go. 71package resourcemanager // import "cloud.google.com/go/resourcemanager/apiv3" 72 73import ( 74 "context" 75 "os" 76 "runtime" 77 "strconv" 78 "strings" 79 "unicode" 80 81 "google.golang.org/api/option" 82 "google.golang.org/grpc/metadata" 83) 84 85// For more information on implementing a client constructor hook, see 86// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. 87type clientHookParams struct{} 88type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) 89 90const versionClient = "20210921" 91 92func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { 93 out, _ := metadata.FromOutgoingContext(ctx) 94 out = out.Copy() 95 for _, md := range mds { 96 for k, v := range md { 97 out[k] = append(out[k], v...) 98 } 99 } 100 return metadata.NewOutgoingContext(ctx, out) 101} 102 103func checkDisableDeadlines() (bool, error) { 104 raw, ok := os.LookupEnv("GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE") 105 if !ok { 106 return false, nil 107 } 108 109 b, err := strconv.ParseBool(raw) 110 return b, err 111} 112 113// DefaultAuthScopes reports the default set of authentication scopes to use with this package. 114func DefaultAuthScopes() []string { 115 return []string{ 116 "https://www.googleapis.com/auth/cloud-platform", 117 "https://www.googleapis.com/auth/cloud-platform.read-only", 118 } 119} 120 121// versionGo returns the Go runtime version. The returned string 122// has no whitespace, suitable for reporting in header. 123func versionGo() string { 124 const develPrefix = "devel +" 125 126 s := runtime.Version() 127 if strings.HasPrefix(s, develPrefix) { 128 s = s[len(develPrefix):] 129 if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { 130 s = s[:p] 131 } 132 return s 133 } 134 135 notSemverRune := func(r rune) bool { 136 return !strings.ContainsRune("0123456789.", r) 137 } 138 139 if strings.HasPrefix(s, "go1") { 140 s = s[2:] 141 var prerelease string 142 if p := strings.IndexFunc(s, notSemverRune); p >= 0 { 143 s, prerelease = s[:p], s[p:] 144 } 145 if strings.HasSuffix(s, ".") { 146 s += "0" 147 } else if strings.Count(s, ".") < 2 { 148 s += ".0" 149 } 150 if prerelease != "" { 151 s += "-" + prerelease 152 } 153 return s 154 } 155 return "UNKNOWN" 156} 157