doc.go 5.2 KB

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