| 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 gkemulticloud_test |
| 18 | |
| 19 | import ( |
| 20 | "context" |
| 21 | |
| 22 | gkemulticloud "cloud.google.com/go/gkemulticloud/apiv1" |
| 23 | gkemulticloudpb "cloud.google.com/go/gkemulticloud/apiv1/gkemulticloudpb" |
| 24 | longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" |
| 25 | "google.golang.org/api/iterator" |
| 26 | ) |
| 27 | |
| 28 | func ExampleNewAttachedClustersClient() { |
| 29 | ctx := context.Background() |
| 30 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 31 | // It will require modifications to work: |
| 32 | // - It may require correct/in-range values for request initialization. |
| 33 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 34 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 35 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 36 | if err != nil { |
| 37 | // TODO: Handle error. |
| 38 | } |
| 39 | defer c.Close() |
| 40 | |
| 41 | // TODO: Use client. |
| 42 | _ = c |
| 43 | } |
| 44 | |
| 45 | func ExampleAttachedClustersClient_CreateAttachedCluster() { |
| 46 | ctx := context.Background() |
| 47 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 48 | // It will require modifications to work: |
| 49 | // - It may require correct/in-range values for request initialization. |
| 50 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 51 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 52 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 53 | if err != nil { |
| 54 | // TODO: Handle error. |
| 55 | } |
| 56 | defer c.Close() |
| 57 | |
| 58 | req := &gkemulticloudpb.CreateAttachedClusterRequest{ |
| 59 | // TODO: Fill request struct fields. |
| 60 | // See https://pkg.go.dev/cloud.google.com/go/gkemulticloud/apiv1/gkemulticloudpb#CreateAttachedClusterRequest. |
| 61 | } |
| 62 | op, err := c.CreateAttachedCluster(ctx, req) |
| 63 | if err != nil { |
| 64 | // TODO: Handle error. |
| 65 | } |
| 66 | |
| 67 | resp, err := op.Wait(ctx) |
| 68 | if err != nil { |
| 69 | // TODO: Handle error. |
| 70 | } |
| 71 | // TODO: Use resp. |
| 72 | _ = resp |
| 73 | } |
| 74 | |
| 75 | func ExampleAttachedClustersClient_DeleteAttachedCluster() { |
| 76 | ctx := context.Background() |
| 77 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 78 | // It will require modifications to work: |
| 79 | // - It may require correct/in-range values for request initialization. |
| 80 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 81 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 82 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 83 | if err != nil { |
| 84 | // TODO: Handle error. |
| 85 | } |
| 86 | defer c.Close() |
| 87 | |
| 88 | req := &gkemulticloudpb.DeleteAttachedClusterRequest{ |
| 89 | // TODO: Fill request struct fields. |
| 90 | // See https://pkg.go.dev/cloud.google.com/go/gkemulticloud/apiv1/gkemulticloudpb#DeleteAttachedClusterRequest. |
| 91 | } |
| 92 | op, err := c.DeleteAttachedCluster(ctx, req) |
| 93 | if err != nil { |
| 94 | // TODO: Handle error. |
| 95 | } |
| 96 | |
| 97 | err = op.Wait(ctx) |
| 98 | if err != nil { |
| 99 | // TODO: Handle error. |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | func ExampleAttachedClustersClient_GenerateAttachedClusterAgentToken() { |
| 104 | ctx := context.Background() |
| 105 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 106 | // It will require modifications to work: |
| 107 | // - It may require correct/in-range values for request initialization. |
| 108 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 109 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 110 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 111 | if err != nil { |
| 112 | // TODO: Handle error. |
| 113 | } |
| 114 | defer c.Close() |
| 115 | |
| 116 | req := &gkemulticloudpb.GenerateAttachedClusterAgentTokenRequest{ |
| 117 | // TODO: Fill request struct fields. |
| 118 | // See https://pkg.go.dev/cloud.google.com/go/gkemulticloud/apiv1/gkemulticloudpb#GenerateAttachedClusterAgentTokenRequest. |
| 119 | } |
| 120 | resp, err := c.GenerateAttachedClusterAgentToken(ctx, req) |
| 121 | if err != nil { |
| 122 | // TODO: Handle error. |
| 123 | } |
| 124 | // TODO: Use resp. |
| 125 | _ = resp |
| 126 | } |
| 127 | |
| 128 | func ExampleAttachedClustersClient_GenerateAttachedClusterInstallManifest() { |
| 129 | ctx := context.Background() |
| 130 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 131 | // It will require modifications to work: |
| 132 | // - It may require correct/in-range values for request initialization. |
| 133 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 134 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 135 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 136 | if err != nil { |
| 137 | // TODO: Handle error. |
| 138 | } |
| 139 | defer c.Close() |
| 140 | |
| 141 | req := &gkemulticloudpb.GenerateAttachedClusterInstallManifestRequest{ |
| 142 | // TODO: Fill request struct fields. |
| 143 | // See https://pkg.go.dev/cloud.google.com/go/gkemulticloud/apiv1/gkemulticloudpb#GenerateAttachedClusterInstallManifestRequest. |
| 144 | } |
| 145 | resp, err := c.GenerateAttachedClusterInstallManifest(ctx, req) |
| 146 | if err != nil { |
| 147 | // TODO: Handle error. |
| 148 | } |
| 149 | // TODO: Use resp. |
| 150 | _ = resp |
| 151 | } |
| 152 | |
| 153 | func ExampleAttachedClustersClient_GetAttachedCluster() { |
| 154 | ctx := context.Background() |
| 155 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 156 | // It will require modifications to work: |
| 157 | // - It may require correct/in-range values for request initialization. |
| 158 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 159 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 160 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 161 | if err != nil { |
| 162 | // TODO: Handle error. |
| 163 | } |
| 164 | defer c.Close() |
| 165 | |
| 166 | req := &gkemulticloudpb.GetAttachedClusterRequest{ |
| 167 | // TODO: Fill request struct fields. |
| 168 | // See https://pkg.go.dev/cloud.google.com/go/gkemulticloud/apiv1/gkemulticloudpb#GetAttachedClusterRequest. |
| 169 | } |
| 170 | resp, err := c.GetAttachedCluster(ctx, req) |
| 171 | if err != nil { |
| 172 | // TODO: Handle error. |
| 173 | } |
| 174 | // TODO: Use resp. |
| 175 | _ = resp |
| 176 | } |
| 177 | |
| 178 | func ExampleAttachedClustersClient_GetAttachedServerConfig() { |
| 179 | ctx := context.Background() |
| 180 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 181 | // It will require modifications to work: |
| 182 | // - It may require correct/in-range values for request initialization. |
| 183 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 184 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 185 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 186 | if err != nil { |
| 187 | // TODO: Handle error. |
| 188 | } |
| 189 | defer c.Close() |
| 190 | |
| 191 | req := &gkemulticloudpb.GetAttachedServerConfigRequest{ |
| 192 | // TODO: Fill request struct fields. |
| 193 | // See https://pkg.go.dev/cloud.google.com/go/gkemulticloud/apiv1/gkemulticloudpb#GetAttachedServerConfigRequest. |
| 194 | } |
| 195 | resp, err := c.GetAttachedServerConfig(ctx, req) |
| 196 | if err != nil { |
| 197 | // TODO: Handle error. |
| 198 | } |
| 199 | // TODO: Use resp. |
| 200 | _ = resp |
| 201 | } |
| 202 | |
| 203 | func ExampleAttachedClustersClient_ImportAttachedCluster() { |
| 204 | ctx := context.Background() |
| 205 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 206 | // It will require modifications to work: |
| 207 | // - It may require correct/in-range values for request initialization. |
| 208 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 209 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 210 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 211 | if err != nil { |
| 212 | // TODO: Handle error. |
| 213 | } |
| 214 | defer c.Close() |
| 215 | |
| 216 | req := &gkemulticloudpb.ImportAttachedClusterRequest{ |
| 217 | // TODO: Fill request struct fields. |
| 218 | // See https://pkg.go.dev/cloud.google.com/go/gkemulticloud/apiv1/gkemulticloudpb#ImportAttachedClusterRequest. |
| 219 | } |
| 220 | op, err := c.ImportAttachedCluster(ctx, req) |
| 221 | if err != nil { |
| 222 | // TODO: Handle error. |
| 223 | } |
| 224 | |
| 225 | resp, err := op.Wait(ctx) |
| 226 | if err != nil { |
| 227 | // TODO: Handle error. |
| 228 | } |
| 229 | // TODO: Use resp. |
| 230 | _ = resp |
| 231 | } |
| 232 | |
| 233 | func ExampleAttachedClustersClient_ListAttachedClusters() { |
| 234 | ctx := context.Background() |
| 235 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 236 | // It will require modifications to work: |
| 237 | // - It may require correct/in-range values for request initialization. |
| 238 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 239 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 240 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 241 | if err != nil { |
| 242 | // TODO: Handle error. |
| 243 | } |
| 244 | defer c.Close() |
| 245 | |
| 246 | req := &gkemulticloudpb.ListAttachedClustersRequest{ |
| 247 | // TODO: Fill request struct fields. |
| 248 | // See https://pkg.go.dev/cloud.google.com/go/gkemulticloud/apiv1/gkemulticloudpb#ListAttachedClustersRequest. |
| 249 | } |
| 250 | it := c.ListAttachedClusters(ctx, req) |
| 251 | for { |
| 252 | resp, err := it.Next() |
| 253 | if err == iterator.Done { |
| 254 | break |
| 255 | } |
| 256 | if err != nil { |
| 257 | // TODO: Handle error. |
| 258 | } |
| 259 | // TODO: Use resp. |
| 260 | _ = resp |
| 261 | |
| 262 | // If you need to access the underlying RPC response, |
| 263 | // you can do so by casting the `Response` as below. |
| 264 | // Otherwise, remove this line. Only populated after |
| 265 | // first call to Next(). Not safe for concurrent access. |
| 266 | _ = it.Response.(*gkemulticloudpb.ListAttachedClustersResponse) |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | func ExampleAttachedClustersClient_UpdateAttachedCluster() { |
| 271 | ctx := context.Background() |
| 272 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 273 | // It will require modifications to work: |
| 274 | // - It may require correct/in-range values for request initialization. |
| 275 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 276 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 277 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 278 | if err != nil { |
| 279 | // TODO: Handle error. |
| 280 | } |
| 281 | defer c.Close() |
| 282 | |
| 283 | req := &gkemulticloudpb.UpdateAttachedClusterRequest{ |
| 284 | // TODO: Fill request struct fields. |
| 285 | // See https://pkg.go.dev/cloud.google.com/go/gkemulticloud/apiv1/gkemulticloudpb#UpdateAttachedClusterRequest. |
| 286 | } |
| 287 | op, err := c.UpdateAttachedCluster(ctx, req) |
| 288 | if err != nil { |
| 289 | // TODO: Handle error. |
| 290 | } |
| 291 | |
| 292 | resp, err := op.Wait(ctx) |
| 293 | if err != nil { |
| 294 | // TODO: Handle error. |
| 295 | } |
| 296 | // TODO: Use resp. |
| 297 | _ = resp |
| 298 | } |
| 299 | |
| 300 | func ExampleAttachedClustersClient_CancelOperation() { |
| 301 | ctx := context.Background() |
| 302 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 303 | // It will require modifications to work: |
| 304 | // - It may require correct/in-range values for request initialization. |
| 305 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 306 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 307 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 308 | if err != nil { |
| 309 | // TODO: Handle error. |
| 310 | } |
| 311 | defer c.Close() |
| 312 | |
| 313 | req := &longrunningpb.CancelOperationRequest{ |
| 314 | // TODO: Fill request struct fields. |
| 315 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest. |
| 316 | } |
| 317 | err = c.CancelOperation(ctx, req) |
| 318 | if err != nil { |
| 319 | // TODO: Handle error. |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | func ExampleAttachedClustersClient_DeleteOperation() { |
| 324 | ctx := context.Background() |
| 325 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 326 | // It will require modifications to work: |
| 327 | // - It may require correct/in-range values for request initialization. |
| 328 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 329 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 330 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 331 | if err != nil { |
| 332 | // TODO: Handle error. |
| 333 | } |
| 334 | defer c.Close() |
| 335 | |
| 336 | req := &longrunningpb.DeleteOperationRequest{ |
| 337 | // TODO: Fill request struct fields. |
| 338 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest. |
| 339 | } |
| 340 | err = c.DeleteOperation(ctx, req) |
| 341 | if err != nil { |
| 342 | // TODO: Handle error. |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | func ExampleAttachedClustersClient_GetOperation() { |
| 347 | ctx := context.Background() |
| 348 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 349 | // It will require modifications to work: |
| 350 | // - It may require correct/in-range values for request initialization. |
| 351 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 352 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 353 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 354 | if err != nil { |
| 355 | // TODO: Handle error. |
| 356 | } |
| 357 | defer c.Close() |
| 358 | |
| 359 | req := &longrunningpb.GetOperationRequest{ |
| 360 | // TODO: Fill request struct fields. |
| 361 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. |
| 362 | } |
| 363 | resp, err := c.GetOperation(ctx, req) |
| 364 | if err != nil { |
| 365 | // TODO: Handle error. |
| 366 | } |
| 367 | // TODO: Use resp. |
| 368 | _ = resp |
| 369 | } |
| 370 | |
| 371 | func ExampleAttachedClustersClient_ListOperations() { |
| 372 | ctx := context.Background() |
| 373 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 374 | // It will require modifications to work: |
| 375 | // - It may require correct/in-range values for request initialization. |
| 376 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 377 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 378 | c, err := gkemulticloud.NewAttachedClustersClient(ctx) |
| 379 | if err != nil { |
| 380 | // TODO: Handle error. |
| 381 | } |
| 382 | defer c.Close() |
| 383 | |
| 384 | req := &longrunningpb.ListOperationsRequest{ |
| 385 | // TODO: Fill request struct fields. |
| 386 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. |
| 387 | } |
| 388 | it := c.ListOperations(ctx, req) |
| 389 | for { |
| 390 | resp, err := it.Next() |
| 391 | if err == iterator.Done { |
| 392 | break |
| 393 | } |
| 394 | if err != nil { |
| 395 | // TODO: Handle error. |
| 396 | } |
| 397 | // TODO: Use resp. |
| 398 | _ = resp |
| 399 | |
| 400 | // If you need to access the underlying RPC response, |
| 401 | // you can do so by casting the `Response` as below. |
| 402 | // Otherwise, remove this line. Only populated after |
| 403 | // first call to Next(). Not safe for concurrent access. |
| 404 | _ = it.Response.(*longrunningpb.ListOperationsResponse) |
| 405 | } |
| 406 | } |