...

Source file src/cloud.google.com/go/monitoring/apiv3/group_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 ExampleNewGroupClient() {
    28  	ctx := context.Background()
    29  	c, err := monitoring.NewGroupClient(ctx)
    30  	if err != nil {
    31  		// TODO: Handle error.
    32  	}
    33  	// TODO: Use client.
    34  	_ = c
    35  }
    36  
    37  func ExampleGroupClient_ListGroups() {
    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.NewGroupClient(ctx)
    43  	if err != nil {
    44  		// TODO: Handle error.
    45  	}
    46  
    47  	req := &monitoringpb.ListGroupsRequest{
    48  		// TODO: Fill request struct fields.
    49  	}
    50  	it := c.ListGroups(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 ExampleGroupClient_GetGroup() {
    65  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
    66  
    67  	ctx := context.Background()
    68  	c, err := monitoring.NewGroupClient(ctx)
    69  	if err != nil {
    70  		// TODO: Handle error.
    71  	}
    72  
    73  	req := &monitoringpb.GetGroupRequest{
    74  		// TODO: Fill request struct fields.
    75  	}
    76  	resp, err := c.GetGroup(ctx, req)
    77  	if err != nil {
    78  		// TODO: Handle error.
    79  	}
    80  	// TODO: Use resp.
    81  	_ = resp
    82  }
    83  
    84  func ExampleGroupClient_CreateGroup() {
    85  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
    86  
    87  	ctx := context.Background()
    88  	c, err := monitoring.NewGroupClient(ctx)
    89  	if err != nil {
    90  		// TODO: Handle error.
    91  	}
    92  
    93  	req := &monitoringpb.CreateGroupRequest{
    94  		// TODO: Fill request struct fields.
    95  	}
    96  	resp, err := c.CreateGroup(ctx, req)
    97  	if err != nil {
    98  		// TODO: Handle error.
    99  	}
   100  	// TODO: Use resp.
   101  	_ = resp
   102  }
   103  
   104  func ExampleGroupClient_UpdateGroup() {
   105  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   106  
   107  	ctx := context.Background()
   108  	c, err := monitoring.NewGroupClient(ctx)
   109  	if err != nil {
   110  		// TODO: Handle error.
   111  	}
   112  
   113  	req := &monitoringpb.UpdateGroupRequest{
   114  		// TODO: Fill request struct fields.
   115  	}
   116  	resp, err := c.UpdateGroup(ctx, req)
   117  	if err != nil {
   118  		// TODO: Handle error.
   119  	}
   120  	// TODO: Use resp.
   121  	_ = resp
   122  }
   123  
   124  func ExampleGroupClient_DeleteGroup() {
   125  	ctx := context.Background()
   126  	c, err := monitoring.NewGroupClient(ctx)
   127  	if err != nil {
   128  		// TODO: Handle error.
   129  	}
   130  
   131  	req := &monitoringpb.DeleteGroupRequest{
   132  		// TODO: Fill request struct fields.
   133  	}
   134  	err = c.DeleteGroup(ctx, req)
   135  	if err != nil {
   136  		// TODO: Handle error.
   137  	}
   138  }
   139  
   140  func ExampleGroupClient_ListGroupMembers() {
   141  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   142  	// import "google.golang.org/api/iterator"
   143  
   144  	ctx := context.Background()
   145  	c, err := monitoring.NewGroupClient(ctx)
   146  	if err != nil {
   147  		// TODO: Handle error.
   148  	}
   149  
   150  	req := &monitoringpb.ListGroupMembersRequest{
   151  		// TODO: Fill request struct fields.
   152  	}
   153  	it := c.ListGroupMembers(ctx, req)
   154  	for {
   155  		resp, err := it.Next()
   156  		if err == iterator.Done {
   157  			break
   158  		}
   159  		if err != nil {
   160  			// TODO: Handle error.
   161  		}
   162  		// TODO: Use resp.
   163  		_ = resp
   164  	}
   165  }
   166  

View as plain text