You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

194 lines
4.2 KiB

  1. // Copyright 2019 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 gapic-generator. DO NOT EDIT.
  15. package monitoring_test
  16. import (
  17. "context"
  18. monitoring "cloud.google.com/go/monitoring/apiv3"
  19. "google.golang.org/api/iterator"
  20. monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
  21. )
  22. func ExampleNewMetricClient() {
  23. ctx := context.Background()
  24. c, err := monitoring.NewMetricClient(ctx)
  25. if err != nil {
  26. // TODO: Handle error.
  27. }
  28. // TODO: Use client.
  29. _ = c
  30. }
  31. func ExampleMetricClient_ListMonitoredResourceDescriptors() {
  32. ctx := context.Background()
  33. c, err := monitoring.NewMetricClient(ctx)
  34. if err != nil {
  35. // TODO: Handle error.
  36. }
  37. req := &monitoringpb.ListMonitoredResourceDescriptorsRequest{
  38. // TODO: Fill request struct fields.
  39. }
  40. it := c.ListMonitoredResourceDescriptors(ctx, req)
  41. for {
  42. resp, err := it.Next()
  43. if err == iterator.Done {
  44. break
  45. }
  46. if err != nil {
  47. // TODO: Handle error.
  48. }
  49. // TODO: Use resp.
  50. _ = resp
  51. }
  52. }
  53. func ExampleMetricClient_GetMonitoredResourceDescriptor() {
  54. ctx := context.Background()
  55. c, err := monitoring.NewMetricClient(ctx)
  56. if err != nil {
  57. // TODO: Handle error.
  58. }
  59. req := &monitoringpb.GetMonitoredResourceDescriptorRequest{
  60. // TODO: Fill request struct fields.
  61. }
  62. resp, err := c.GetMonitoredResourceDescriptor(ctx, req)
  63. if err != nil {
  64. // TODO: Handle error.
  65. }
  66. // TODO: Use resp.
  67. _ = resp
  68. }
  69. func ExampleMetricClient_ListMetricDescriptors() {
  70. ctx := context.Background()
  71. c, err := monitoring.NewMetricClient(ctx)
  72. if err != nil {
  73. // TODO: Handle error.
  74. }
  75. req := &monitoringpb.ListMetricDescriptorsRequest{
  76. // TODO: Fill request struct fields.
  77. }
  78. it := c.ListMetricDescriptors(ctx, req)
  79. for {
  80. resp, err := it.Next()
  81. if err == iterator.Done {
  82. break
  83. }
  84. if err != nil {
  85. // TODO: Handle error.
  86. }
  87. // TODO: Use resp.
  88. _ = resp
  89. }
  90. }
  91. func ExampleMetricClient_GetMetricDescriptor() {
  92. ctx := context.Background()
  93. c, err := monitoring.NewMetricClient(ctx)
  94. if err != nil {
  95. // TODO: Handle error.
  96. }
  97. req := &monitoringpb.GetMetricDescriptorRequest{
  98. // TODO: Fill request struct fields.
  99. }
  100. resp, err := c.GetMetricDescriptor(ctx, req)
  101. if err != nil {
  102. // TODO: Handle error.
  103. }
  104. // TODO: Use resp.
  105. _ = resp
  106. }
  107. func ExampleMetricClient_CreateMetricDescriptor() {
  108. ctx := context.Background()
  109. c, err := monitoring.NewMetricClient(ctx)
  110. if err != nil {
  111. // TODO: Handle error.
  112. }
  113. req := &monitoringpb.CreateMetricDescriptorRequest{
  114. // TODO: Fill request struct fields.
  115. }
  116. resp, err := c.CreateMetricDescriptor(ctx, req)
  117. if err != nil {
  118. // TODO: Handle error.
  119. }
  120. // TODO: Use resp.
  121. _ = resp
  122. }
  123. func ExampleMetricClient_DeleteMetricDescriptor() {
  124. ctx := context.Background()
  125. c, err := monitoring.NewMetricClient(ctx)
  126. if err != nil {
  127. // TODO: Handle error.
  128. }
  129. req := &monitoringpb.DeleteMetricDescriptorRequest{
  130. // TODO: Fill request struct fields.
  131. }
  132. err = c.DeleteMetricDescriptor(ctx, req)
  133. if err != nil {
  134. // TODO: Handle error.
  135. }
  136. }
  137. func ExampleMetricClient_ListTimeSeries() {
  138. ctx := context.Background()
  139. c, err := monitoring.NewMetricClient(ctx)
  140. if err != nil {
  141. // TODO: Handle error.
  142. }
  143. req := &monitoringpb.ListTimeSeriesRequest{
  144. // TODO: Fill request struct fields.
  145. }
  146. it := c.ListTimeSeries(ctx, req)
  147. for {
  148. resp, err := it.Next()
  149. if err == iterator.Done {
  150. break
  151. }
  152. if err != nil {
  153. // TODO: Handle error.
  154. }
  155. // TODO: Use resp.
  156. _ = resp
  157. }
  158. }
  159. func ExampleMetricClient_CreateTimeSeries() {
  160. ctx := context.Background()
  161. c, err := monitoring.NewMetricClient(ctx)
  162. if err != nil {
  163. // TODO: Handle error.
  164. }
  165. req := &monitoringpb.CreateTimeSeriesRequest{
  166. // TODO: Fill request struct fields.
  167. }
  168. err = c.CreateTimeSeries(ctx, req)
  169. if err != nil {
  170. // TODO: Handle error.
  171. }
  172. }