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