1// Copyright 2021 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 17package logging_test 18 19import ( 20 "context" 21 22 logging "cloud.google.com/go/logging/apiv2" 23 "google.golang.org/api/iterator" 24 loggingpb "google.golang.org/genproto/googleapis/logging/v2" 25) 26 27func ExampleNewMetricsClient() { 28 ctx := context.Background() 29 c, err := logging.NewMetricsClient(ctx) 30 if err != nil { 31 // TODO: Handle error. 32 } 33 defer c.Close() 34 35 // TODO: Use client. 36 _ = c 37} 38 39func ExampleMetricsClient_ListLogMetrics() { 40 ctx := context.Background() 41 c, err := logging.NewMetricsClient(ctx) 42 if err != nil { 43 // TODO: Handle error. 44 } 45 defer c.Close() 46 47 req := &loggingpb.ListLogMetricsRequest{ 48 // TODO: Fill request struct fields. 49 } 50 it := c.ListLogMetrics(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 64func ExampleMetricsClient_GetLogMetric() { 65 ctx := context.Background() 66 c, err := logging.NewMetricsClient(ctx) 67 if err != nil { 68 // TODO: Handle error. 69 } 70 defer c.Close() 71 72 req := &loggingpb.GetLogMetricRequest{ 73 // TODO: Fill request struct fields. 74 } 75 resp, err := c.GetLogMetric(ctx, req) 76 if err != nil { 77 // TODO: Handle error. 78 } 79 // TODO: Use resp. 80 _ = resp 81} 82 83func ExampleMetricsClient_CreateLogMetric() { 84 ctx := context.Background() 85 c, err := logging.NewMetricsClient(ctx) 86 if err != nil { 87 // TODO: Handle error. 88 } 89 defer c.Close() 90 91 req := &loggingpb.CreateLogMetricRequest{ 92 // TODO: Fill request struct fields. 93 } 94 resp, err := c.CreateLogMetric(ctx, req) 95 if err != nil { 96 // TODO: Handle error. 97 } 98 // TODO: Use resp. 99 _ = resp 100} 101 102func ExampleMetricsClient_UpdateLogMetric() { 103 ctx := context.Background() 104 c, err := logging.NewMetricsClient(ctx) 105 if err != nil { 106 // TODO: Handle error. 107 } 108 defer c.Close() 109 110 req := &loggingpb.UpdateLogMetricRequest{ 111 // TODO: Fill request struct fields. 112 } 113 resp, err := c.UpdateLogMetric(ctx, req) 114 if err != nil { 115 // TODO: Handle error. 116 } 117 // TODO: Use resp. 118 _ = resp 119} 120 121func ExampleMetricsClient_DeleteLogMetric() { 122 ctx := context.Background() 123 c, err := logging.NewMetricsClient(ctx) 124 if err != nil { 125 // TODO: Handle error. 126 } 127 defer c.Close() 128 129 req := &loggingpb.DeleteLogMetricRequest{ 130 // TODO: Fill request struct fields. 131 } 132 err = c.DeleteLogMetric(ctx, req) 133 if err != nil { 134 // TODO: Handle error. 135 } 136} 137