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