cloud.google.com/go/aiplatform@v1.106.0/apiv1/evaluation_client_example_test.go (about) 1 // Copyright 2025 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 aiplatform_test 18 19 import ( 20 "context" 21 22 aiplatform "cloud.google.com/go/aiplatform/apiv1" 23 aiplatformpb "cloud.google.com/go/aiplatform/apiv1/aiplatformpb" 24 iampb "cloud.google.com/go/iam/apiv1/iampb" 25 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" 26 "google.golang.org/api/iterator" 27 locationpb "google.golang.org/genproto/googleapis/cloud/location" 28 ) 29 30 func ExampleNewEvaluationClient() { 31 ctx := context.Background() 32 // This snippet has been automatically generated and should be regarded as a code template only. 33 // It will require modifications to work: 34 // - It may require correct/in-range values for request initialization. 35 // - It may require specifying regional endpoints when creating the service client as shown in: 36 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 37 c, err := aiplatform.NewEvaluationClient(ctx) 38 if err != nil { 39 // TODO: Handle error. 40 } 41 defer c.Close() 42 43 // TODO: Use client. 44 _ = c 45 } 46 47 func ExampleEvaluationClient_EvaluateInstances() { 48 ctx := context.Background() 49 // This snippet has been automatically generated and should be regarded as a code template only. 50 // It will require modifications to work: 51 // - It may require correct/in-range values for request initialization. 52 // - It may require specifying regional endpoints when creating the service client as shown in: 53 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 54 c, err := aiplatform.NewEvaluationClient(ctx) 55 if err != nil { 56 // TODO: Handle error. 57 } 58 defer c.Close() 59 60 req := &aiplatformpb.EvaluateInstancesRequest{ 61 // TODO: Fill request struct fields. 62 // See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#EvaluateInstancesRequest. 63 } 64 resp, err := c.EvaluateInstances(ctx, req) 65 if err != nil { 66 // TODO: Handle error. 67 } 68 // TODO: Use resp. 69 _ = resp 70 } 71 72 func ExampleEvaluationClient_GetLocation() { 73 ctx := context.Background() 74 // This snippet has been automatically generated and should be regarded as a code template only. 75 // It will require modifications to work: 76 // - It may require correct/in-range values for request initialization. 77 // - It may require specifying regional endpoints when creating the service client as shown in: 78 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 79 c, err := aiplatform.NewEvaluationClient(ctx) 80 if err != nil { 81 // TODO: Handle error. 82 } 83 defer c.Close() 84 85 req := &locationpb.GetLocationRequest{ 86 // TODO: Fill request struct fields. 87 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. 88 } 89 resp, err := c.GetLocation(ctx, req) 90 if err != nil { 91 // TODO: Handle error. 92 } 93 // TODO: Use resp. 94 _ = resp 95 } 96 97 func ExampleEvaluationClient_ListLocations() { 98 ctx := context.Background() 99 // This snippet has been automatically generated and should be regarded as a code template only. 100 // It will require modifications to work: 101 // - It may require correct/in-range values for request initialization. 102 // - It may require specifying regional endpoints when creating the service client as shown in: 103 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 104 c, err := aiplatform.NewEvaluationClient(ctx) 105 if err != nil { 106 // TODO: Handle error. 107 } 108 defer c.Close() 109 110 req := &locationpb.ListLocationsRequest{ 111 // TODO: Fill request struct fields. 112 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. 113 } 114 it := c.ListLocations(ctx, req) 115 for { 116 resp, err := it.Next() 117 if err == iterator.Done { 118 break 119 } 120 if err != nil { 121 // TODO: Handle error. 122 } 123 // TODO: Use resp. 124 _ = resp 125 126 // If you need to access the underlying RPC response, 127 // you can do so by casting the `Response` as below. 128 // Otherwise, remove this line. Only populated after 129 // first call to Next(). Not safe for concurrent access. 130 _ = it.Response.(*locationpb.ListLocationsResponse) 131 } 132 } 133 134 func ExampleEvaluationClient_GetIamPolicy() { 135 ctx := context.Background() 136 // This snippet has been automatically generated and should be regarded as a code template only. 137 // It will require modifications to work: 138 // - It may require correct/in-range values for request initialization. 139 // - It may require specifying regional endpoints when creating the service client as shown in: 140 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 141 c, err := aiplatform.NewEvaluationClient(ctx) 142 if err != nil { 143 // TODO: Handle error. 144 } 145 defer c.Close() 146 147 req := &iampb.GetIamPolicyRequest{ 148 // TODO: Fill request struct fields. 149 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest. 150 } 151 resp, err := c.GetIamPolicy(ctx, req) 152 if err != nil { 153 // TODO: Handle error. 154 } 155 // TODO: Use resp. 156 _ = resp 157 } 158 159 func ExampleEvaluationClient_SetIamPolicy() { 160 ctx := context.Background() 161 // This snippet has been automatically generated and should be regarded as a code template only. 162 // It will require modifications to work: 163 // - It may require correct/in-range values for request initialization. 164 // - It may require specifying regional endpoints when creating the service client as shown in: 165 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 166 c, err := aiplatform.NewEvaluationClient(ctx) 167 if err != nil { 168 // TODO: Handle error. 169 } 170 defer c.Close() 171 172 req := &iampb.SetIamPolicyRequest{ 173 // TODO: Fill request struct fields. 174 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest. 175 } 176 resp, err := c.SetIamPolicy(ctx, req) 177 if err != nil { 178 // TODO: Handle error. 179 } 180 // TODO: Use resp. 181 _ = resp 182 } 183 184 func ExampleEvaluationClient_TestIamPermissions() { 185 ctx := context.Background() 186 // This snippet has been automatically generated and should be regarded as a code template only. 187 // It will require modifications to work: 188 // - It may require correct/in-range values for request initialization. 189 // - It may require specifying regional endpoints when creating the service client as shown in: 190 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 191 c, err := aiplatform.NewEvaluationClient(ctx) 192 if err != nil { 193 // TODO: Handle error. 194 } 195 defer c.Close() 196 197 req := &iampb.TestIamPermissionsRequest{ 198 // TODO: Fill request struct fields. 199 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest. 200 } 201 resp, err := c.TestIamPermissions(ctx, req) 202 if err != nil { 203 // TODO: Handle error. 204 } 205 // TODO: Use resp. 206 _ = resp 207 } 208 209 func ExampleEvaluationClient_CancelOperation() { 210 ctx := context.Background() 211 // This snippet has been automatically generated and should be regarded as a code template only. 212 // It will require modifications to work: 213 // - It may require correct/in-range values for request initialization. 214 // - It may require specifying regional endpoints when creating the service client as shown in: 215 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 216 c, err := aiplatform.NewEvaluationClient(ctx) 217 if err != nil { 218 // TODO: Handle error. 219 } 220 defer c.Close() 221 222 req := &longrunningpb.CancelOperationRequest{ 223 // TODO: Fill request struct fields. 224 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest. 225 } 226 err = c.CancelOperation(ctx, req) 227 if err != nil { 228 // TODO: Handle error. 229 } 230 } 231 232 func ExampleEvaluationClient_DeleteOperation() { 233 ctx := context.Background() 234 // This snippet has been automatically generated and should be regarded as a code template only. 235 // It will require modifications to work: 236 // - It may require correct/in-range values for request initialization. 237 // - It may require specifying regional endpoints when creating the service client as shown in: 238 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 239 c, err := aiplatform.NewEvaluationClient(ctx) 240 if err != nil { 241 // TODO: Handle error. 242 } 243 defer c.Close() 244 245 req := &longrunningpb.DeleteOperationRequest{ 246 // TODO: Fill request struct fields. 247 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest. 248 } 249 err = c.DeleteOperation(ctx, req) 250 if err != nil { 251 // TODO: Handle error. 252 } 253 } 254 255 func ExampleEvaluationClient_GetOperation() { 256 ctx := context.Background() 257 // This snippet has been automatically generated and should be regarded as a code template only. 258 // It will require modifications to work: 259 // - It may require correct/in-range values for request initialization. 260 // - It may require specifying regional endpoints when creating the service client as shown in: 261 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 262 c, err := aiplatform.NewEvaluationClient(ctx) 263 if err != nil { 264 // TODO: Handle error. 265 } 266 defer c.Close() 267 268 req := &longrunningpb.GetOperationRequest{ 269 // TODO: Fill request struct fields. 270 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. 271 } 272 resp, err := c.GetOperation(ctx, req) 273 if err != nil { 274 // TODO: Handle error. 275 } 276 // TODO: Use resp. 277 _ = resp 278 } 279 280 func ExampleEvaluationClient_ListOperations() { 281 ctx := context.Background() 282 // This snippet has been automatically generated and should be regarded as a code template only. 283 // It will require modifications to work: 284 // - It may require correct/in-range values for request initialization. 285 // - It may require specifying regional endpoints when creating the service client as shown in: 286 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 287 c, err := aiplatform.NewEvaluationClient(ctx) 288 if err != nil { 289 // TODO: Handle error. 290 } 291 defer c.Close() 292 293 req := &longrunningpb.ListOperationsRequest{ 294 // TODO: Fill request struct fields. 295 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. 296 } 297 it := c.ListOperations(ctx, req) 298 for { 299 resp, err := it.Next() 300 if err == iterator.Done { 301 break 302 } 303 if err != nil { 304 // TODO: Handle error. 305 } 306 // TODO: Use resp. 307 _ = resp 308 309 // If you need to access the underlying RPC response, 310 // you can do so by casting the `Response` as below. 311 // Otherwise, remove this line. Only populated after 312 // first call to Next(). Not safe for concurrent access. 313 _ = it.Response.(*longrunningpb.ListOperationsResponse) 314 } 315 } 316 317 func ExampleEvaluationClient_WaitOperation() { 318 ctx := context.Background() 319 // This snippet has been automatically generated and should be regarded as a code template only. 320 // It will require modifications to work: 321 // - It may require correct/in-range values for request initialization. 322 // - It may require specifying regional endpoints when creating the service client as shown in: 323 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 324 c, err := aiplatform.NewEvaluationClient(ctx) 325 if err != nil { 326 // TODO: Handle error. 327 } 328 defer c.Close() 329 330 req := &longrunningpb.WaitOperationRequest{ 331 // TODO: Fill request struct fields. 332 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#WaitOperationRequest. 333 } 334 resp, err := c.WaitOperation(ctx, req) 335 if err != nil { 336 // TODO: Handle error. 337 } 338 // TODO: Use resp. 339 _ = resp 340 }