...

Source file src/cloud.google.com/go/monitoring/apiv3/notification_channel_client_example_test.go

Documentation: cloud.google.com/go/monitoring/apiv3

     1  // Copyright 2020 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"
    23  	"cloud.google.com/go/monitoring/apiv3/v2/monitoringpb"
    24  	"google.golang.org/api/iterator"
    25  )
    26  
    27  func ExampleNewNotificationChannelClient() {
    28  	ctx := context.Background()
    29  	c, err := monitoring.NewNotificationChannelClient(ctx)
    30  	if err != nil {
    31  		// TODO: Handle error.
    32  	}
    33  	// TODO: Use client.
    34  	_ = c
    35  }
    36  
    37  func ExampleNotificationChannelClient_ListNotificationChannelDescriptors() {
    38  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
    39  	// import "google.golang.org/api/iterator"
    40  
    41  	ctx := context.Background()
    42  	c, err := monitoring.NewNotificationChannelClient(ctx)
    43  	if err != nil {
    44  		// TODO: Handle error.
    45  	}
    46  
    47  	req := &monitoringpb.ListNotificationChannelDescriptorsRequest{
    48  		// TODO: Fill request struct fields.
    49  	}
    50  	it := c.ListNotificationChannelDescriptors(ctx, req)
    51  	for {
    52  		resp, err := it.Next()
    53  		if err == iterator.Done {
    54  			break
    55  		}
    56  		if err != nil {
    57  			// TODO: Handle error.
    58  		}
    59  		// TODO: Use resp.
    60  		_ = resp
    61  	}
    62  }
    63  
    64  func ExampleNotificationChannelClient_GetNotificationChannelDescriptor() {
    65  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
    66  
    67  	ctx := context.Background()
    68  	c, err := monitoring.NewNotificationChannelClient(ctx)
    69  	if err != nil {
    70  		// TODO: Handle error.
    71  	}
    72  
    73  	req := &monitoringpb.GetNotificationChannelDescriptorRequest{
    74  		// TODO: Fill request struct fields.
    75  	}
    76  	resp, err := c.GetNotificationChannelDescriptor(ctx, req)
    77  	if err != nil {
    78  		// TODO: Handle error.
    79  	}
    80  	// TODO: Use resp.
    81  	_ = resp
    82  }
    83  
    84  func ExampleNotificationChannelClient_ListNotificationChannels() {
    85  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
    86  	// import "google.golang.org/api/iterator"
    87  
    88  	ctx := context.Background()
    89  	c, err := monitoring.NewNotificationChannelClient(ctx)
    90  	if err != nil {
    91  		// TODO: Handle error.
    92  	}
    93  
    94  	req := &monitoringpb.ListNotificationChannelsRequest{
    95  		// TODO: Fill request struct fields.
    96  	}
    97  	it := c.ListNotificationChannels(ctx, req)
    98  	for {
    99  		resp, err := it.Next()
   100  		if err == iterator.Done {
   101  			break
   102  		}
   103  		if err != nil {
   104  			// TODO: Handle error.
   105  		}
   106  		// TODO: Use resp.
   107  		_ = resp
   108  	}
   109  }
   110  
   111  func ExampleNotificationChannelClient_GetNotificationChannel() {
   112  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   113  
   114  	ctx := context.Background()
   115  	c, err := monitoring.NewNotificationChannelClient(ctx)
   116  	if err != nil {
   117  		// TODO: Handle error.
   118  	}
   119  
   120  	req := &monitoringpb.GetNotificationChannelRequest{
   121  		// TODO: Fill request struct fields.
   122  	}
   123  	resp, err := c.GetNotificationChannel(ctx, req)
   124  	if err != nil {
   125  		// TODO: Handle error.
   126  	}
   127  	// TODO: Use resp.
   128  	_ = resp
   129  }
   130  
   131  func ExampleNotificationChannelClient_CreateNotificationChannel() {
   132  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   133  
   134  	ctx := context.Background()
   135  	c, err := monitoring.NewNotificationChannelClient(ctx)
   136  	if err != nil {
   137  		// TODO: Handle error.
   138  	}
   139  
   140  	req := &monitoringpb.CreateNotificationChannelRequest{
   141  		// TODO: Fill request struct fields.
   142  	}
   143  	resp, err := c.CreateNotificationChannel(ctx, req)
   144  	if err != nil {
   145  		// TODO: Handle error.
   146  	}
   147  	// TODO: Use resp.
   148  	_ = resp
   149  }
   150  
   151  func ExampleNotificationChannelClient_UpdateNotificationChannel() {
   152  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   153  
   154  	ctx := context.Background()
   155  	c, err := monitoring.NewNotificationChannelClient(ctx)
   156  	if err != nil {
   157  		// TODO: Handle error.
   158  	}
   159  
   160  	req := &monitoringpb.UpdateNotificationChannelRequest{
   161  		// TODO: Fill request struct fields.
   162  	}
   163  	resp, err := c.UpdateNotificationChannel(ctx, req)
   164  	if err != nil {
   165  		// TODO: Handle error.
   166  	}
   167  	// TODO: Use resp.
   168  	_ = resp
   169  }
   170  
   171  func ExampleNotificationChannelClient_DeleteNotificationChannel() {
   172  	ctx := context.Background()
   173  	c, err := monitoring.NewNotificationChannelClient(ctx)
   174  	if err != nil {
   175  		// TODO: Handle error.
   176  	}
   177  
   178  	req := &monitoringpb.DeleteNotificationChannelRequest{
   179  		// TODO: Fill request struct fields.
   180  	}
   181  	err = c.DeleteNotificationChannel(ctx, req)
   182  	if err != nil {
   183  		// TODO: Handle error.
   184  	}
   185  }
   186  
   187  func ExampleNotificationChannelClient_SendNotificationChannelVerificationCode() {
   188  	ctx := context.Background()
   189  	c, err := monitoring.NewNotificationChannelClient(ctx)
   190  	if err != nil {
   191  		// TODO: Handle error.
   192  	}
   193  
   194  	req := &monitoringpb.SendNotificationChannelVerificationCodeRequest{
   195  		// TODO: Fill request struct fields.
   196  	}
   197  	err = c.SendNotificationChannelVerificationCode(ctx, req)
   198  	if err != nil {
   199  		// TODO: Handle error.
   200  	}
   201  }
   202  
   203  func ExampleNotificationChannelClient_GetNotificationChannelVerificationCode() {
   204  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   205  
   206  	ctx := context.Background()
   207  	c, err := monitoring.NewNotificationChannelClient(ctx)
   208  	if err != nil {
   209  		// TODO: Handle error.
   210  	}
   211  
   212  	req := &monitoringpb.GetNotificationChannelVerificationCodeRequest{
   213  		// TODO: Fill request struct fields.
   214  	}
   215  	resp, err := c.GetNotificationChannelVerificationCode(ctx, req)
   216  	if err != nil {
   217  		// TODO: Handle error.
   218  	}
   219  	// TODO: Use resp.
   220  	_ = resp
   221  }
   222  
   223  func ExampleNotificationChannelClient_VerifyNotificationChannel() {
   224  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   225  
   226  	ctx := context.Background()
   227  	c, err := monitoring.NewNotificationChannelClient(ctx)
   228  	if err != nil {
   229  		// TODO: Handle error.
   230  	}
   231  
   232  	req := &monitoringpb.VerifyNotificationChannelRequest{
   233  		// TODO: Fill request struct fields.
   234  	}
   235  	resp, err := c.VerifyNotificationChannel(ctx, req)
   236  	if err != nil {
   237  		// TODO: Handle error.
   238  	}
   239  	// TODO: Use resp.
   240  	_ = resp
   241  }
   242  

View as plain text