1 // Copyright 2024 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_test 18 19 import ( 20 "context" 21 22 monitoring "cloud.google.com/go/monitoring/apiv3/v2" 23 monitoringpb "cloud.google.com/go/monitoring/apiv3/v2/monitoringpb" 24 "google.golang.org/api/iterator" 25 ) 26 27 func ExampleNewNotificationChannelClient() { 28 ctx := context.Background() 29 // This snippet has been automatically generated and should be regarded as a code template only. 30 // It will require modifications to work: 31 // - It may require correct/in-range values for request initialization. 32 // - It may require specifying regional endpoints when creating the service client as shown in: 33 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 34 c, err := monitoring.NewNotificationChannelClient(ctx) 35 if err != nil { 36 // TODO: Handle error. 37 } 38 defer c.Close() 39 40 // TODO: Use client. 41 _ = c 42 } 43 44 func ExampleNotificationChannelClient_CreateNotificationChannel() { 45 ctx := context.Background() 46 // This snippet has been automatically generated and should be regarded as a code template only. 47 // It will require modifications to work: 48 // - It may require correct/in-range values for request initialization. 49 // - It may require specifying regional endpoints when creating the service client as shown in: 50 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 51 c, err := monitoring.NewNotificationChannelClient(ctx) 52 if err != nil { 53 // TODO: Handle error. 54 } 55 defer c.Close() 56 57 req := &monitoringpb.CreateNotificationChannelRequest{ 58 // TODO: Fill request struct fields. 59 // See https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3/v2/monitoringpb#CreateNotificationChannelRequest. 60 } 61 resp, err := c.CreateNotificationChannel(ctx, req) 62 if err != nil { 63 // TODO: Handle error. 64 } 65 // TODO: Use resp. 66 _ = resp 67 } 68 69 func ExampleNotificationChannelClient_DeleteNotificationChannel() { 70 ctx := context.Background() 71 // This snippet has been automatically generated and should be regarded as a code template only. 72 // It will require modifications to work: 73 // - It may require correct/in-range values for request initialization. 74 // - It may require specifying regional endpoints when creating the service client as shown in: 75 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 76 c, err := monitoring.NewNotificationChannelClient(ctx) 77 if err != nil { 78 // TODO: Handle error. 79 } 80 defer c.Close() 81 82 req := &monitoringpb.DeleteNotificationChannelRequest{ 83 // TODO: Fill request struct fields. 84 // See https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3/v2/monitoringpb#DeleteNotificationChannelRequest. 85 } 86 err = c.DeleteNotificationChannel(ctx, req) 87 if err != nil { 88 // TODO: Handle error. 89 } 90 } 91 92 func ExampleNotificationChannelClient_GetNotificationChannel() { 93 ctx := context.Background() 94 // This snippet has been automatically generated and should be regarded as a code template only. 95 // It will require modifications to work: 96 // - It may require correct/in-range values for request initialization. 97 // - It may require specifying regional endpoints when creating the service client as shown in: 98 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 99 c, err := monitoring.NewNotificationChannelClient(ctx) 100 if err != nil { 101 // TODO: Handle error. 102 } 103 defer c.Close() 104 105 req := &monitoringpb.GetNotificationChannelRequest{ 106 // TODO: Fill request struct fields. 107 // See https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3/v2/monitoringpb#GetNotificationChannelRequest. 108 } 109 resp, err := c.GetNotificationChannel(ctx, req) 110 if err != nil { 111 // TODO: Handle error. 112 } 113 // TODO: Use resp. 114 _ = resp 115 } 116 117 func ExampleNotificationChannelClient_GetNotificationChannelDescriptor() { 118 ctx := context.Background() 119 // This snippet has been automatically generated and should be regarded as a code template only. 120 // It will require modifications to work: 121 // - It may require correct/in-range values for request initialization. 122 // - It may require specifying regional endpoints when creating the service client as shown in: 123 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 124 c, err := monitoring.NewNotificationChannelClient(ctx) 125 if err != nil { 126 // TODO: Handle error. 127 } 128 defer c.Close() 129 130 req := &monitoringpb.GetNotificationChannelDescriptorRequest{ 131 // TODO: Fill request struct fields. 132 // See https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3/v2/monitoringpb#GetNotificationChannelDescriptorRequest. 133 } 134 resp, err := c.GetNotificationChannelDescriptor(ctx, req) 135 if err != nil { 136 // TODO: Handle error. 137 } 138 // TODO: Use resp. 139 _ = resp 140 } 141 142 func ExampleNotificationChannelClient_GetNotificationChannelVerificationCode() { 143 ctx := context.Background() 144 // This snippet has been automatically generated and should be regarded as a code template only. 145 // It will require modifications to work: 146 // - It may require correct/in-range values for request initialization. 147 // - It may require specifying regional endpoints when creating the service client as shown in: 148 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 149 c, err := monitoring.NewNotificationChannelClient(ctx) 150 if err != nil { 151 // TODO: Handle error. 152 } 153 defer c.Close() 154 155 req := &monitoringpb.GetNotificationChannelVerificationCodeRequest{ 156 // TODO: Fill request struct fields. 157 // See https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3/v2/monitoringpb#GetNotificationChannelVerificationCodeRequest. 158 } 159 resp, err := c.GetNotificationChannelVerificationCode(ctx, req) 160 if err != nil { 161 // TODO: Handle error. 162 } 163 // TODO: Use resp. 164 _ = resp 165 } 166 167 func ExampleNotificationChannelClient_ListNotificationChannelDescriptors() { 168 ctx := context.Background() 169 // This snippet has been automatically generated and should be regarded as a code template only. 170 // It will require modifications to work: 171 // - It may require correct/in-range values for request initialization. 172 // - It may require specifying regional endpoints when creating the service client as shown in: 173 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 174 c, err := monitoring.NewNotificationChannelClient(ctx) 175 if err != nil { 176 // TODO: Handle error. 177 } 178 defer c.Close() 179 180 req := &monitoringpb.ListNotificationChannelDescriptorsRequest{ 181 // TODO: Fill request struct fields. 182 // See https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3/v2/monitoringpb#ListNotificationChannelDescriptorsRequest. 183 } 184 it := c.ListNotificationChannelDescriptors(ctx, req) 185 for { 186 resp, err := it.Next() 187 if err == iterator.Done { 188 break 189 } 190 if err != nil { 191 // TODO: Handle error. 192 } 193 // TODO: Use resp. 194 _ = resp 195 196 // If you need to access the underlying RPC response, 197 // you can do so by casting the `Response` as below. 198 // Otherwise, remove this line. Only populated after 199 // first call to Next(). Not safe for concurrent access. 200 _ = it.Response.(*monitoringpb.ListNotificationChannelDescriptorsResponse) 201 } 202 } 203 204 func ExampleNotificationChannelClient_ListNotificationChannels() { 205 ctx := context.Background() 206 // This snippet has been automatically generated and should be regarded as a code template only. 207 // It will require modifications to work: 208 // - It may require correct/in-range values for request initialization. 209 // - It may require specifying regional endpoints when creating the service client as shown in: 210 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 211 c, err := monitoring.NewNotificationChannelClient(ctx) 212 if err != nil { 213 // TODO: Handle error. 214 } 215 defer c.Close() 216 217 req := &monitoringpb.ListNotificationChannelsRequest{ 218 // TODO: Fill request struct fields. 219 // See https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3/v2/monitoringpb#ListNotificationChannelsRequest. 220 } 221 it := c.ListNotificationChannels(ctx, req) 222 for { 223 resp, err := it.Next() 224 if err == iterator.Done { 225 break 226 } 227 if err != nil { 228 // TODO: Handle error. 229 } 230 // TODO: Use resp. 231 _ = resp 232 233 // If you need to access the underlying RPC response, 234 // you can do so by casting the `Response` as below. 235 // Otherwise, remove this line. Only populated after 236 // first call to Next(). Not safe for concurrent access. 237 _ = it.Response.(*monitoringpb.ListNotificationChannelsResponse) 238 } 239 } 240 241 func ExampleNotificationChannelClient_SendNotificationChannelVerificationCode() { 242 ctx := context.Background() 243 // This snippet has been automatically generated and should be regarded as a code template only. 244 // It will require modifications to work: 245 // - It may require correct/in-range values for request initialization. 246 // - It may require specifying regional endpoints when creating the service client as shown in: 247 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 248 c, err := monitoring.NewNotificationChannelClient(ctx) 249 if err != nil { 250 // TODO: Handle error. 251 } 252 defer c.Close() 253 254 req := &monitoringpb.SendNotificationChannelVerificationCodeRequest{ 255 // TODO: Fill request struct fields. 256 // See https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3/v2/monitoringpb#SendNotificationChannelVerificationCodeRequest. 257 } 258 err = c.SendNotificationChannelVerificationCode(ctx, req) 259 if err != nil { 260 // TODO: Handle error. 261 } 262 } 263 264 func ExampleNotificationChannelClient_UpdateNotificationChannel() { 265 ctx := context.Background() 266 // This snippet has been automatically generated and should be regarded as a code template only. 267 // It will require modifications to work: 268 // - It may require correct/in-range values for request initialization. 269 // - It may require specifying regional endpoints when creating the service client as shown in: 270 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 271 c, err := monitoring.NewNotificationChannelClient(ctx) 272 if err != nil { 273 // TODO: Handle error. 274 } 275 defer c.Close() 276 277 req := &monitoringpb.UpdateNotificationChannelRequest{ 278 // TODO: Fill request struct fields. 279 // See https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3/v2/monitoringpb#UpdateNotificationChannelRequest. 280 } 281 resp, err := c.UpdateNotificationChannel(ctx, req) 282 if err != nil { 283 // TODO: Handle error. 284 } 285 // TODO: Use resp. 286 _ = resp 287 } 288 289 func ExampleNotificationChannelClient_VerifyNotificationChannel() { 290 ctx := context.Background() 291 // This snippet has been automatically generated and should be regarded as a code template only. 292 // It will require modifications to work: 293 // - It may require correct/in-range values for request initialization. 294 // - It may require specifying regional endpoints when creating the service client as shown in: 295 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 296 c, err := monitoring.NewNotificationChannelClient(ctx) 297 if err != nil { 298 // TODO: Handle error. 299 } 300 defer c.Close() 301 302 req := &monitoringpb.VerifyNotificationChannelRequest{ 303 // TODO: Fill request struct fields. 304 // See https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3/v2/monitoringpb#VerifyNotificationChannelRequest. 305 } 306 resp, err := c.VerifyNotificationChannel(ctx, req) 307 if err != nil { 308 // TODO: Handle error. 309 } 310 // TODO: Use resp. 311 _ = resp 312 } 313