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 metricsscope_test 18 19 import ( 20 "context" 21 22 metricsscope "cloud.google.com/go/monitoring/metricsscope/apiv1" 23 metricsscopepb "cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb" 24 ) 25 26 func ExampleNewMetricsScopesClient() { 27 ctx := context.Background() 28 // This snippet has been automatically generated and should be regarded as a code template only. 29 // It will require modifications to work: 30 // - It may require correct/in-range values for request initialization. 31 // - It may require specifying regional endpoints when creating the service client as shown in: 32 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 33 c, err := metricsscope.NewMetricsScopesClient(ctx) 34 if err != nil { 35 // TODO: Handle error. 36 } 37 defer c.Close() 38 39 // TODO: Use client. 40 _ = c 41 } 42 43 func ExampleMetricsScopesClient_CreateMonitoredProject() { 44 ctx := context.Background() 45 // This snippet has been automatically generated and should be regarded as a code template only. 46 // It will require modifications to work: 47 // - It may require correct/in-range values for request initialization. 48 // - It may require specifying regional endpoints when creating the service client as shown in: 49 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 50 c, err := metricsscope.NewMetricsScopesClient(ctx) 51 if err != nil { 52 // TODO: Handle error. 53 } 54 defer c.Close() 55 56 req := &metricsscopepb.CreateMonitoredProjectRequest{ 57 // TODO: Fill request struct fields. 58 // See https://pkg.go.dev/cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb#CreateMonitoredProjectRequest. 59 } 60 op, err := c.CreateMonitoredProject(ctx, req) 61 if err != nil { 62 // TODO: Handle error. 63 } 64 65 resp, err := op.Wait(ctx) 66 if err != nil { 67 // TODO: Handle error. 68 } 69 // TODO: Use resp. 70 _ = resp 71 } 72 73 func ExampleMetricsScopesClient_DeleteMonitoredProject() { 74 ctx := context.Background() 75 // This snippet has been automatically generated and should be regarded as a code template only. 76 // It will require modifications to work: 77 // - It may require correct/in-range values for request initialization. 78 // - It may require specifying regional endpoints when creating the service client as shown in: 79 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 80 c, err := metricsscope.NewMetricsScopesClient(ctx) 81 if err != nil { 82 // TODO: Handle error. 83 } 84 defer c.Close() 85 86 req := &metricsscopepb.DeleteMonitoredProjectRequest{ 87 // TODO: Fill request struct fields. 88 // See https://pkg.go.dev/cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb#DeleteMonitoredProjectRequest. 89 } 90 op, err := c.DeleteMonitoredProject(ctx, req) 91 if err != nil { 92 // TODO: Handle error. 93 } 94 95 err = op.Wait(ctx) 96 if err != nil { 97 // TODO: Handle error. 98 } 99 } 100 101 func ExampleMetricsScopesClient_GetMetricsScope() { 102 ctx := context.Background() 103 // This snippet has been automatically generated and should be regarded as a code template only. 104 // It will require modifications to work: 105 // - It may require correct/in-range values for request initialization. 106 // - It may require specifying regional endpoints when creating the service client as shown in: 107 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 108 c, err := metricsscope.NewMetricsScopesClient(ctx) 109 if err != nil { 110 // TODO: Handle error. 111 } 112 defer c.Close() 113 114 req := &metricsscopepb.GetMetricsScopeRequest{ 115 // TODO: Fill request struct fields. 116 // See https://pkg.go.dev/cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb#GetMetricsScopeRequest. 117 } 118 resp, err := c.GetMetricsScope(ctx, req) 119 if err != nil { 120 // TODO: Handle error. 121 } 122 // TODO: Use resp. 123 _ = resp 124 } 125 126 func ExampleMetricsScopesClient_ListMetricsScopesByMonitoredProject() { 127 ctx := context.Background() 128 // This snippet has been automatically generated and should be regarded as a code template only. 129 // It will require modifications to work: 130 // - It may require correct/in-range values for request initialization. 131 // - It may require specifying regional endpoints when creating the service client as shown in: 132 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 133 c, err := metricsscope.NewMetricsScopesClient(ctx) 134 if err != nil { 135 // TODO: Handle error. 136 } 137 defer c.Close() 138 139 req := &metricsscopepb.ListMetricsScopesByMonitoredProjectRequest{ 140 // TODO: Fill request struct fields. 141 // See https://pkg.go.dev/cloud.google.com/go/monitoring/metricsscope/apiv1/metricsscopepb#ListMetricsScopesByMonitoredProjectRequest. 142 } 143 resp, err := c.ListMetricsScopesByMonitoredProject(ctx, req) 144 if err != nil { 145 // TODO: Handle error. 146 } 147 // TODO: Use resp. 148 _ = resp 149 } 150