| 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 storagetransfer_test |
| 18 | |
| 19 | import ( |
| 20 | "context" |
| 21 | |
| 22 | longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" |
| 23 | storagetransfer "cloud.google.com/go/storagetransfer/apiv1" |
| 24 | storagetransferpb "cloud.google.com/go/storagetransfer/apiv1/storagetransferpb" |
| 25 | "google.golang.org/api/iterator" |
| 26 | ) |
| 27 | |
| 28 | func ExampleNewClient() { |
| 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 := storagetransfer.NewClient(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 ExampleNewRESTClient() { |
| 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 := storagetransfer.NewRESTClient(ctx) |
| 53 | if err != nil { |
| 54 | // TODO: Handle error. |
| 55 | } |
| 56 | defer c.Close() |
| 57 | |
| 58 | // TODO: Use client. |
| 59 | _ = c |
| 60 | } |
| 61 | |
| 62 | func ExampleClient_CreateAgentPool() { |
| 63 | ctx := context.Background() |
| 64 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 65 | // It will require modifications to work: |
| 66 | // - It may require correct/in-range values for request initialization. |
| 67 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 68 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 69 | c, err := storagetransfer.NewClient(ctx) |
| 70 | if err != nil { |
| 71 | // TODO: Handle error. |
| 72 | } |
| 73 | defer c.Close() |
| 74 | |
| 75 | req := &storagetransferpb.CreateAgentPoolRequest{ |
| 76 | // TODO: Fill request struct fields. |
| 77 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#CreateAgentPoolRequest. |
| 78 | } |
| 79 | resp, err := c.CreateAgentPool(ctx, req) |
| 80 | if err != nil { |
| 81 | // TODO: Handle error. |
| 82 | } |
| 83 | // TODO: Use resp. |
| 84 | _ = resp |
| 85 | } |
| 86 | |
| 87 | func ExampleClient_CreateTransferJob() { |
| 88 | ctx := context.Background() |
| 89 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 90 | // It will require modifications to work: |
| 91 | // - It may require correct/in-range values for request initialization. |
| 92 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 93 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 94 | c, err := storagetransfer.NewClient(ctx) |
| 95 | if err != nil { |
| 96 | // TODO: Handle error. |
| 97 | } |
| 98 | defer c.Close() |
| 99 | |
| 100 | req := &storagetransferpb.CreateTransferJobRequest{ |
| 101 | // TODO: Fill request struct fields. |
| 102 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#CreateTransferJobRequest. |
| 103 | } |
| 104 | resp, err := c.CreateTransferJob(ctx, req) |
| 105 | if err != nil { |
| 106 | // TODO: Handle error. |
| 107 | } |
| 108 | // TODO: Use resp. |
| 109 | _ = resp |
| 110 | } |
| 111 | |
| 112 | func ExampleClient_DeleteAgentPool() { |
| 113 | ctx := context.Background() |
| 114 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 115 | // It will require modifications to work: |
| 116 | // - It may require correct/in-range values for request initialization. |
| 117 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 118 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 119 | c, err := storagetransfer.NewClient(ctx) |
| 120 | if err != nil { |
| 121 | // TODO: Handle error. |
| 122 | } |
| 123 | defer c.Close() |
| 124 | |
| 125 | req := &storagetransferpb.DeleteAgentPoolRequest{ |
| 126 | // TODO: Fill request struct fields. |
| 127 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#DeleteAgentPoolRequest. |
| 128 | } |
| 129 | err = c.DeleteAgentPool(ctx, req) |
| 130 | if err != nil { |
| 131 | // TODO: Handle error. |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | func ExampleClient_DeleteTransferJob() { |
| 136 | ctx := context.Background() |
| 137 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 138 | // It will require modifications to work: |
| 139 | // - It may require correct/in-range values for request initialization. |
| 140 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 141 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 142 | c, err := storagetransfer.NewClient(ctx) |
| 143 | if err != nil { |
| 144 | // TODO: Handle error. |
| 145 | } |
| 146 | defer c.Close() |
| 147 | |
| 148 | req := &storagetransferpb.DeleteTransferJobRequest{ |
| 149 | // TODO: Fill request struct fields. |
| 150 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#DeleteTransferJobRequest. |
| 151 | } |
| 152 | err = c.DeleteTransferJob(ctx, req) |
| 153 | if err != nil { |
| 154 | // TODO: Handle error. |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | func ExampleClient_GetAgentPool() { |
| 159 | ctx := context.Background() |
| 160 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 161 | // It will require modifications to work: |
| 162 | // - It may require correct/in-range values for request initialization. |
| 163 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 164 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 165 | c, err := storagetransfer.NewClient(ctx) |
| 166 | if err != nil { |
| 167 | // TODO: Handle error. |
| 168 | } |
| 169 | defer c.Close() |
| 170 | |
| 171 | req := &storagetransferpb.GetAgentPoolRequest{ |
| 172 | // TODO: Fill request struct fields. |
| 173 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#GetAgentPoolRequest. |
| 174 | } |
| 175 | resp, err := c.GetAgentPool(ctx, req) |
| 176 | if err != nil { |
| 177 | // TODO: Handle error. |
| 178 | } |
| 179 | // TODO: Use resp. |
| 180 | _ = resp |
| 181 | } |
| 182 | |
| 183 | func ExampleClient_GetGoogleServiceAccount() { |
| 184 | ctx := context.Background() |
| 185 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 186 | // It will require modifications to work: |
| 187 | // - It may require correct/in-range values for request initialization. |
| 188 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 189 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 190 | c, err := storagetransfer.NewClient(ctx) |
| 191 | if err != nil { |
| 192 | // TODO: Handle error. |
| 193 | } |
| 194 | defer c.Close() |
| 195 | |
| 196 | req := &storagetransferpb.GetGoogleServiceAccountRequest{ |
| 197 | // TODO: Fill request struct fields. |
| 198 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#GetGoogleServiceAccountRequest. |
| 199 | } |
| 200 | resp, err := c.GetGoogleServiceAccount(ctx, req) |
| 201 | if err != nil { |
| 202 | // TODO: Handle error. |
| 203 | } |
| 204 | // TODO: Use resp. |
| 205 | _ = resp |
| 206 | } |
| 207 | |
| 208 | func ExampleClient_GetTransferJob() { |
| 209 | ctx := context.Background() |
| 210 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 211 | // It will require modifications to work: |
| 212 | // - It may require correct/in-range values for request initialization. |
| 213 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 214 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 215 | c, err := storagetransfer.NewClient(ctx) |
| 216 | if err != nil { |
| 217 | // TODO: Handle error. |
| 218 | } |
| 219 | defer c.Close() |
| 220 | |
| 221 | req := &storagetransferpb.GetTransferJobRequest{ |
| 222 | // TODO: Fill request struct fields. |
| 223 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#GetTransferJobRequest. |
| 224 | } |
| 225 | resp, err := c.GetTransferJob(ctx, req) |
| 226 | if err != nil { |
| 227 | // TODO: Handle error. |
| 228 | } |
| 229 | // TODO: Use resp. |
| 230 | _ = resp |
| 231 | } |
| 232 | |
| 233 | func ExampleClient_ListAgentPools() { |
| 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 := storagetransfer.NewClient(ctx) |
| 241 | if err != nil { |
| 242 | // TODO: Handle error. |
| 243 | } |
| 244 | defer c.Close() |
| 245 | |
| 246 | req := &storagetransferpb.ListAgentPoolsRequest{ |
| 247 | // TODO: Fill request struct fields. |
| 248 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#ListAgentPoolsRequest. |
| 249 | } |
| 250 | it := c.ListAgentPools(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.(*storagetransferpb.ListAgentPoolsResponse) |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | func ExampleClient_ListTransferJobs() { |
| 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 := storagetransfer.NewClient(ctx) |
| 278 | if err != nil { |
| 279 | // TODO: Handle error. |
| 280 | } |
| 281 | defer c.Close() |
| 282 | |
| 283 | req := &storagetransferpb.ListTransferJobsRequest{ |
| 284 | // TODO: Fill request struct fields. |
| 285 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#ListTransferJobsRequest. |
| 286 | } |
| 287 | it := c.ListTransferJobs(ctx, req) |
| 288 | for { |
| 289 | resp, err := it.Next() |
| 290 | if err == iterator.Done { |
| 291 | break |
| 292 | } |
| 293 | if err != nil { |
| 294 | // TODO: Handle error. |
| 295 | } |
| 296 | // TODO: Use resp. |
| 297 | _ = resp |
| 298 | |
| 299 | // If you need to access the underlying RPC response, |
| 300 | // you can do so by casting the `Response` as below. |
| 301 | // Otherwise, remove this line. Only populated after |
| 302 | // first call to Next(). Not safe for concurrent access. |
| 303 | _ = it.Response.(*storagetransferpb.ListTransferJobsResponse) |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | func ExampleClient_PauseTransferOperation() { |
| 308 | ctx := context.Background() |
| 309 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 310 | // It will require modifications to work: |
| 311 | // - It may require correct/in-range values for request initialization. |
| 312 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 313 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 314 | c, err := storagetransfer.NewClient(ctx) |
| 315 | if err != nil { |
| 316 | // TODO: Handle error. |
| 317 | } |
| 318 | defer c.Close() |
| 319 | |
| 320 | req := &storagetransferpb.PauseTransferOperationRequest{ |
| 321 | // TODO: Fill request struct fields. |
| 322 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#PauseTransferOperationRequest. |
| 323 | } |
| 324 | err = c.PauseTransferOperation(ctx, req) |
| 325 | if err != nil { |
| 326 | // TODO: Handle error. |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | func ExampleClient_ResumeTransferOperation() { |
| 331 | ctx := context.Background() |
| 332 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 333 | // It will require modifications to work: |
| 334 | // - It may require correct/in-range values for request initialization. |
| 335 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 336 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 337 | c, err := storagetransfer.NewClient(ctx) |
| 338 | if err != nil { |
| 339 | // TODO: Handle error. |
| 340 | } |
| 341 | defer c.Close() |
| 342 | |
| 343 | req := &storagetransferpb.ResumeTransferOperationRequest{ |
| 344 | // TODO: Fill request struct fields. |
| 345 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#ResumeTransferOperationRequest. |
| 346 | } |
| 347 | err = c.ResumeTransferOperation(ctx, req) |
| 348 | if err != nil { |
| 349 | // TODO: Handle error. |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | func ExampleClient_RunTransferJob() { |
| 354 | ctx := context.Background() |
| 355 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 356 | // It will require modifications to work: |
| 357 | // - It may require correct/in-range values for request initialization. |
| 358 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 359 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 360 | c, err := storagetransfer.NewClient(ctx) |
| 361 | if err != nil { |
| 362 | // TODO: Handle error. |
| 363 | } |
| 364 | defer c.Close() |
| 365 | |
| 366 | req := &storagetransferpb.RunTransferJobRequest{ |
| 367 | // TODO: Fill request struct fields. |
| 368 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#RunTransferJobRequest. |
| 369 | } |
| 370 | op, err := c.RunTransferJob(ctx, req) |
| 371 | if err != nil { |
| 372 | // TODO: Handle error. |
| 373 | } |
| 374 | |
| 375 | err = op.Wait(ctx) |
| 376 | if err != nil { |
| 377 | // TODO: Handle error. |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | func ExampleClient_UpdateAgentPool() { |
| 382 | ctx := context.Background() |
| 383 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 384 | // It will require modifications to work: |
| 385 | // - It may require correct/in-range values for request initialization. |
| 386 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 387 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 388 | c, err := storagetransfer.NewClient(ctx) |
| 389 | if err != nil { |
| 390 | // TODO: Handle error. |
| 391 | } |
| 392 | defer c.Close() |
| 393 | |
| 394 | req := &storagetransferpb.UpdateAgentPoolRequest{ |
| 395 | // TODO: Fill request struct fields. |
| 396 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#UpdateAgentPoolRequest. |
| 397 | } |
| 398 | resp, err := c.UpdateAgentPool(ctx, req) |
| 399 | if err != nil { |
| 400 | // TODO: Handle error. |
| 401 | } |
| 402 | // TODO: Use resp. |
| 403 | _ = resp |
| 404 | } |
| 405 | |
| 406 | func ExampleClient_UpdateTransferJob() { |
| 407 | ctx := context.Background() |
| 408 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 409 | // It will require modifications to work: |
| 410 | // - It may require correct/in-range values for request initialization. |
| 411 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 412 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 413 | c, err := storagetransfer.NewClient(ctx) |
| 414 | if err != nil { |
| 415 | // TODO: Handle error. |
| 416 | } |
| 417 | defer c.Close() |
| 418 | |
| 419 | req := &storagetransferpb.UpdateTransferJobRequest{ |
| 420 | // TODO: Fill request struct fields. |
| 421 | // See https://pkg.go.dev/cloud.google.com/go/storagetransfer/apiv1/storagetransferpb#UpdateTransferJobRequest. |
| 422 | } |
| 423 | resp, err := c.UpdateTransferJob(ctx, req) |
| 424 | if err != nil { |
| 425 | // TODO: Handle error. |
| 426 | } |
| 427 | // TODO: Use resp. |
| 428 | _ = resp |
| 429 | } |
| 430 | |
| 431 | func ExampleClient_CancelOperation() { |
| 432 | ctx := context.Background() |
| 433 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 434 | // It will require modifications to work: |
| 435 | // - It may require correct/in-range values for request initialization. |
| 436 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 437 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 438 | c, err := storagetransfer.NewClient(ctx) |
| 439 | if err != nil { |
| 440 | // TODO: Handle error. |
| 441 | } |
| 442 | defer c.Close() |
| 443 | |
| 444 | req := &longrunningpb.CancelOperationRequest{ |
| 445 | // TODO: Fill request struct fields. |
| 446 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest. |
| 447 | } |
| 448 | err = c.CancelOperation(ctx, req) |
| 449 | if err != nil { |
| 450 | // TODO: Handle error. |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | func ExampleClient_GetOperation() { |
| 455 | ctx := context.Background() |
| 456 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 457 | // It will require modifications to work: |
| 458 | // - It may require correct/in-range values for request initialization. |
| 459 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 460 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 461 | c, err := storagetransfer.NewClient(ctx) |
| 462 | if err != nil { |
| 463 | // TODO: Handle error. |
| 464 | } |
| 465 | defer c.Close() |
| 466 | |
| 467 | req := &longrunningpb.GetOperationRequest{ |
| 468 | // TODO: Fill request struct fields. |
| 469 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. |
| 470 | } |
| 471 | resp, err := c.GetOperation(ctx, req) |
| 472 | if err != nil { |
| 473 | // TODO: Handle error. |
| 474 | } |
| 475 | // TODO: Use resp. |
| 476 | _ = resp |
| 477 | } |
| 478 | |
| 479 | func ExampleClient_ListOperations() { |
| 480 | ctx := context.Background() |
| 481 | // This snippet has been automatically generated and should be regarded as a code template only. |
| 482 | // It will require modifications to work: |
| 483 | // - It may require correct/in-range values for request initialization. |
| 484 | // - It may require specifying regional endpoints when creating the service client as shown in: |
| 485 | // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 486 | c, err := storagetransfer.NewClient(ctx) |
| 487 | if err != nil { |
| 488 | // TODO: Handle error. |
| 489 | } |
| 490 | defer c.Close() |
| 491 | |
| 492 | req := &longrunningpb.ListOperationsRequest{ |
| 493 | // TODO: Fill request struct fields. |
| 494 | // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. |
| 495 | } |
| 496 | it := c.ListOperations(ctx, req) |
| 497 | for { |
| 498 | resp, err := it.Next() |
| 499 | if err == iterator.Done { |
| 500 | break |
| 501 | } |
| 502 | if err != nil { |
| 503 | // TODO: Handle error. |
| 504 | } |
| 505 | // TODO: Use resp. |
| 506 | _ = resp |
| 507 | |
| 508 | // If you need to access the underlying RPC response, |
| 509 | // you can do so by casting the `Response` as below. |
| 510 | // Otherwise, remove this line. Only populated after |
| 511 | // first call to Next(). Not safe for concurrent access. |
| 512 | _ = it.Response.(*longrunningpb.ListOperationsResponse) |
| 513 | } |
| 514 | } |