1 // Copyright 2024 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 reservation_test 18 19 import ( 20 "context" 21 22 reservation "cloud.google.com/go/bigquery/reservation/apiv1" 23 reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb" 24 "google.golang.org/api/iterator" 25 ) 26 27 func ExampleNewClient() { 28 ctx := context.Background() 29 // This snippet has been automatically generated and should be regarded as a code template only. 30 // It will require modifications to work: 31 // - It may require correct/in-range values for request initialization. 32 // - It may require specifying regional endpoints when creating the service client as shown in: 33 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 34 c, err := reservation.NewClient(ctx) 35 if err != nil { 36 // TODO: Handle error. 37 } 38 defer c.Close() 39 40 // TODO: Use client. 41 _ = c 42 } 43 44 func ExampleNewRESTClient() { 45 ctx := context.Background() 46 // This snippet has been automatically generated and should be regarded as a code template only. 47 // It will require modifications to work: 48 // - It may require correct/in-range values for request initialization. 49 // - It may require specifying regional endpoints when creating the service client as shown in: 50 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 51 c, err := reservation.NewRESTClient(ctx) 52 if err != nil { 53 // TODO: Handle error. 54 } 55 defer c.Close() 56 57 // TODO: Use client. 58 _ = c 59 } 60 61 func ExampleClient_CreateAssignment() { 62 ctx := context.Background() 63 // This snippet has been automatically generated and should be regarded as a code template only. 64 // It will require modifications to work: 65 // - It may require correct/in-range values for request initialization. 66 // - It may require specifying regional endpoints when creating the service client as shown in: 67 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 68 c, err := reservation.NewClient(ctx) 69 if err != nil { 70 // TODO: Handle error. 71 } 72 defer c.Close() 73 74 req := &reservationpb.CreateAssignmentRequest{ 75 // TODO: Fill request struct fields. 76 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#CreateAssignmentRequest. 77 } 78 resp, err := c.CreateAssignment(ctx, req) 79 if err != nil { 80 // TODO: Handle error. 81 } 82 // TODO: Use resp. 83 _ = resp 84 } 85 86 func ExampleClient_CreateCapacityCommitment() { 87 ctx := context.Background() 88 // This snippet has been automatically generated and should be regarded as a code template only. 89 // It will require modifications to work: 90 // - It may require correct/in-range values for request initialization. 91 // - It may require specifying regional endpoints when creating the service client as shown in: 92 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 93 c, err := reservation.NewClient(ctx) 94 if err != nil { 95 // TODO: Handle error. 96 } 97 defer c.Close() 98 99 req := &reservationpb.CreateCapacityCommitmentRequest{ 100 // TODO: Fill request struct fields. 101 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#CreateCapacityCommitmentRequest. 102 } 103 resp, err := c.CreateCapacityCommitment(ctx, req) 104 if err != nil { 105 // TODO: Handle error. 106 } 107 // TODO: Use resp. 108 _ = resp 109 } 110 111 func ExampleClient_CreateReservation() { 112 ctx := context.Background() 113 // This snippet has been automatically generated and should be regarded as a code template only. 114 // It will require modifications to work: 115 // - It may require correct/in-range values for request initialization. 116 // - It may require specifying regional endpoints when creating the service client as shown in: 117 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 118 c, err := reservation.NewClient(ctx) 119 if err != nil { 120 // TODO: Handle error. 121 } 122 defer c.Close() 123 124 req := &reservationpb.CreateReservationRequest{ 125 // TODO: Fill request struct fields. 126 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#CreateReservationRequest. 127 } 128 resp, err := c.CreateReservation(ctx, req) 129 if err != nil { 130 // TODO: Handle error. 131 } 132 // TODO: Use resp. 133 _ = resp 134 } 135 136 func ExampleClient_DeleteAssignment() { 137 ctx := context.Background() 138 // This snippet has been automatically generated and should be regarded as a code template only. 139 // It will require modifications to work: 140 // - It may require correct/in-range values for request initialization. 141 // - It may require specifying regional endpoints when creating the service client as shown in: 142 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 143 c, err := reservation.NewClient(ctx) 144 if err != nil { 145 // TODO: Handle error. 146 } 147 defer c.Close() 148 149 req := &reservationpb.DeleteAssignmentRequest{ 150 // TODO: Fill request struct fields. 151 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#DeleteAssignmentRequest. 152 } 153 err = c.DeleteAssignment(ctx, req) 154 if err != nil { 155 // TODO: Handle error. 156 } 157 } 158 159 func ExampleClient_DeleteCapacityCommitment() { 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 := reservation.NewClient(ctx) 167 if err != nil { 168 // TODO: Handle error. 169 } 170 defer c.Close() 171 172 req := &reservationpb.DeleteCapacityCommitmentRequest{ 173 // TODO: Fill request struct fields. 174 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#DeleteCapacityCommitmentRequest. 175 } 176 err = c.DeleteCapacityCommitment(ctx, req) 177 if err != nil { 178 // TODO: Handle error. 179 } 180 } 181 182 func ExampleClient_DeleteReservation() { 183 ctx := context.Background() 184 // This snippet has been automatically generated and should be regarded as a code template only. 185 // It will require modifications to work: 186 // - It may require correct/in-range values for request initialization. 187 // - It may require specifying regional endpoints when creating the service client as shown in: 188 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 189 c, err := reservation.NewClient(ctx) 190 if err != nil { 191 // TODO: Handle error. 192 } 193 defer c.Close() 194 195 req := &reservationpb.DeleteReservationRequest{ 196 // TODO: Fill request struct fields. 197 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#DeleteReservationRequest. 198 } 199 err = c.DeleteReservation(ctx, req) 200 if err != nil { 201 // TODO: Handle error. 202 } 203 } 204 205 func ExampleClient_GetBiReservation() { 206 ctx := context.Background() 207 // This snippet has been automatically generated and should be regarded as a code template only. 208 // It will require modifications to work: 209 // - It may require correct/in-range values for request initialization. 210 // - It may require specifying regional endpoints when creating the service client as shown in: 211 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 212 c, err := reservation.NewClient(ctx) 213 if err != nil { 214 // TODO: Handle error. 215 } 216 defer c.Close() 217 218 req := &reservationpb.GetBiReservationRequest{ 219 // TODO: Fill request struct fields. 220 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#GetBiReservationRequest. 221 } 222 resp, err := c.GetBiReservation(ctx, req) 223 if err != nil { 224 // TODO: Handle error. 225 } 226 // TODO: Use resp. 227 _ = resp 228 } 229 230 func ExampleClient_GetCapacityCommitment() { 231 ctx := context.Background() 232 // This snippet has been automatically generated and should be regarded as a code template only. 233 // It will require modifications to work: 234 // - It may require correct/in-range values for request initialization. 235 // - It may require specifying regional endpoints when creating the service client as shown in: 236 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 237 c, err := reservation.NewClient(ctx) 238 if err != nil { 239 // TODO: Handle error. 240 } 241 defer c.Close() 242 243 req := &reservationpb.GetCapacityCommitmentRequest{ 244 // TODO: Fill request struct fields. 245 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#GetCapacityCommitmentRequest. 246 } 247 resp, err := c.GetCapacityCommitment(ctx, req) 248 if err != nil { 249 // TODO: Handle error. 250 } 251 // TODO: Use resp. 252 _ = resp 253 } 254 255 func ExampleClient_GetReservation() { 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 := reservation.NewClient(ctx) 263 if err != nil { 264 // TODO: Handle error. 265 } 266 defer c.Close() 267 268 req := &reservationpb.GetReservationRequest{ 269 // TODO: Fill request struct fields. 270 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#GetReservationRequest. 271 } 272 resp, err := c.GetReservation(ctx, req) 273 if err != nil { 274 // TODO: Handle error. 275 } 276 // TODO: Use resp. 277 _ = resp 278 } 279 280 func ExampleClient_ListAssignments() { 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 := reservation.NewClient(ctx) 288 if err != nil { 289 // TODO: Handle error. 290 } 291 defer c.Close() 292 293 req := &reservationpb.ListAssignmentsRequest{ 294 // TODO: Fill request struct fields. 295 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#ListAssignmentsRequest. 296 } 297 it := c.ListAssignments(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.(*reservationpb.ListAssignmentsResponse) 314 } 315 } 316 317 func ExampleClient_ListCapacityCommitments() { 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 := reservation.NewClient(ctx) 325 if err != nil { 326 // TODO: Handle error. 327 } 328 defer c.Close() 329 330 req := &reservationpb.ListCapacityCommitmentsRequest{ 331 // TODO: Fill request struct fields. 332 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#ListCapacityCommitmentsRequest. 333 } 334 it := c.ListCapacityCommitments(ctx, req) 335 for { 336 resp, err := it.Next() 337 if err == iterator.Done { 338 break 339 } 340 if err != nil { 341 // TODO: Handle error. 342 } 343 // TODO: Use resp. 344 _ = resp 345 346 // If you need to access the underlying RPC response, 347 // you can do so by casting the `Response` as below. 348 // Otherwise, remove this line. Only populated after 349 // first call to Next(). Not safe for concurrent access. 350 _ = it.Response.(*reservationpb.ListCapacityCommitmentsResponse) 351 } 352 } 353 354 func ExampleClient_ListReservations() { 355 ctx := context.Background() 356 // This snippet has been automatically generated and should be regarded as a code template only. 357 // It will require modifications to work: 358 // - It may require correct/in-range values for request initialization. 359 // - It may require specifying regional endpoints when creating the service client as shown in: 360 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 361 c, err := reservation.NewClient(ctx) 362 if err != nil { 363 // TODO: Handle error. 364 } 365 defer c.Close() 366 367 req := &reservationpb.ListReservationsRequest{ 368 // TODO: Fill request struct fields. 369 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#ListReservationsRequest. 370 } 371 it := c.ListReservations(ctx, req) 372 for { 373 resp, err := it.Next() 374 if err == iterator.Done { 375 break 376 } 377 if err != nil { 378 // TODO: Handle error. 379 } 380 // TODO: Use resp. 381 _ = resp 382 383 // If you need to access the underlying RPC response, 384 // you can do so by casting the `Response` as below. 385 // Otherwise, remove this line. Only populated after 386 // first call to Next(). Not safe for concurrent access. 387 _ = it.Response.(*reservationpb.ListReservationsResponse) 388 } 389 } 390 391 func ExampleClient_MergeCapacityCommitments() { 392 ctx := context.Background() 393 // This snippet has been automatically generated and should be regarded as a code template only. 394 // It will require modifications to work: 395 // - It may require correct/in-range values for request initialization. 396 // - It may require specifying regional endpoints when creating the service client as shown in: 397 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 398 c, err := reservation.NewClient(ctx) 399 if err != nil { 400 // TODO: Handle error. 401 } 402 defer c.Close() 403 404 req := &reservationpb.MergeCapacityCommitmentsRequest{ 405 // TODO: Fill request struct fields. 406 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#MergeCapacityCommitmentsRequest. 407 } 408 resp, err := c.MergeCapacityCommitments(ctx, req) 409 if err != nil { 410 // TODO: Handle error. 411 } 412 // TODO: Use resp. 413 _ = resp 414 } 415 416 func ExampleClient_MoveAssignment() { 417 ctx := context.Background() 418 // This snippet has been automatically generated and should be regarded as a code template only. 419 // It will require modifications to work: 420 // - It may require correct/in-range values for request initialization. 421 // - It may require specifying regional endpoints when creating the service client as shown in: 422 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 423 c, err := reservation.NewClient(ctx) 424 if err != nil { 425 // TODO: Handle error. 426 } 427 defer c.Close() 428 429 req := &reservationpb.MoveAssignmentRequest{ 430 // TODO: Fill request struct fields. 431 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#MoveAssignmentRequest. 432 } 433 resp, err := c.MoveAssignment(ctx, req) 434 if err != nil { 435 // TODO: Handle error. 436 } 437 // TODO: Use resp. 438 _ = resp 439 } 440 441 func ExampleClient_SearchAllAssignments() { 442 ctx := context.Background() 443 // This snippet has been automatically generated and should be regarded as a code template only. 444 // It will require modifications to work: 445 // - It may require correct/in-range values for request initialization. 446 // - It may require specifying regional endpoints when creating the service client as shown in: 447 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 448 c, err := reservation.NewClient(ctx) 449 if err != nil { 450 // TODO: Handle error. 451 } 452 defer c.Close() 453 454 req := &reservationpb.SearchAllAssignmentsRequest{ 455 // TODO: Fill request struct fields. 456 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#SearchAllAssignmentsRequest. 457 } 458 it := c.SearchAllAssignments(ctx, req) 459 for { 460 resp, err := it.Next() 461 if err == iterator.Done { 462 break 463 } 464 if err != nil { 465 // TODO: Handle error. 466 } 467 // TODO: Use resp. 468 _ = resp 469 470 // If you need to access the underlying RPC response, 471 // you can do so by casting the `Response` as below. 472 // Otherwise, remove this line. Only populated after 473 // first call to Next(). Not safe for concurrent access. 474 _ = it.Response.(*reservationpb.SearchAllAssignmentsResponse) 475 } 476 } 477 478 func ExampleClient_SearchAssignments() { 479 ctx := context.Background() 480 // This snippet has been automatically generated and should be regarded as a code template only. 481 // It will require modifications to work: 482 // - It may require correct/in-range values for request initialization. 483 // - It may require specifying regional endpoints when creating the service client as shown in: 484 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 485 c, err := reservation.NewClient(ctx) 486 if err != nil { 487 // TODO: Handle error. 488 } 489 defer c.Close() 490 491 req := &reservationpb.SearchAssignmentsRequest{ 492 // TODO: Fill request struct fields. 493 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#SearchAssignmentsRequest. 494 } 495 it := c.SearchAssignments(ctx, req) 496 for { 497 resp, err := it.Next() 498 if err == iterator.Done { 499 break 500 } 501 if err != nil { 502 // TODO: Handle error. 503 } 504 // TODO: Use resp. 505 _ = resp 506 507 // If you need to access the underlying RPC response, 508 // you can do so by casting the `Response` as below. 509 // Otherwise, remove this line. Only populated after 510 // first call to Next(). Not safe for concurrent access. 511 _ = it.Response.(*reservationpb.SearchAssignmentsResponse) 512 } 513 } 514 515 func ExampleClient_SplitCapacityCommitment() { 516 ctx := context.Background() 517 // This snippet has been automatically generated and should be regarded as a code template only. 518 // It will require modifications to work: 519 // - It may require correct/in-range values for request initialization. 520 // - It may require specifying regional endpoints when creating the service client as shown in: 521 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 522 c, err := reservation.NewClient(ctx) 523 if err != nil { 524 // TODO: Handle error. 525 } 526 defer c.Close() 527 528 req := &reservationpb.SplitCapacityCommitmentRequest{ 529 // TODO: Fill request struct fields. 530 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#SplitCapacityCommitmentRequest. 531 } 532 resp, err := c.SplitCapacityCommitment(ctx, req) 533 if err != nil { 534 // TODO: Handle error. 535 } 536 // TODO: Use resp. 537 _ = resp 538 } 539 540 func ExampleClient_UpdateAssignment() { 541 ctx := context.Background() 542 // This snippet has been automatically generated and should be regarded as a code template only. 543 // It will require modifications to work: 544 // - It may require correct/in-range values for request initialization. 545 // - It may require specifying regional endpoints when creating the service client as shown in: 546 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 547 c, err := reservation.NewClient(ctx) 548 if err != nil { 549 // TODO: Handle error. 550 } 551 defer c.Close() 552 553 req := &reservationpb.UpdateAssignmentRequest{ 554 // TODO: Fill request struct fields. 555 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#UpdateAssignmentRequest. 556 } 557 resp, err := c.UpdateAssignment(ctx, req) 558 if err != nil { 559 // TODO: Handle error. 560 } 561 // TODO: Use resp. 562 _ = resp 563 } 564 565 func ExampleClient_UpdateBiReservation() { 566 ctx := context.Background() 567 // This snippet has been automatically generated and should be regarded as a code template only. 568 // It will require modifications to work: 569 // - It may require correct/in-range values for request initialization. 570 // - It may require specifying regional endpoints when creating the service client as shown in: 571 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 572 c, err := reservation.NewClient(ctx) 573 if err != nil { 574 // TODO: Handle error. 575 } 576 defer c.Close() 577 578 req := &reservationpb.UpdateBiReservationRequest{ 579 // TODO: Fill request struct fields. 580 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#UpdateBiReservationRequest. 581 } 582 resp, err := c.UpdateBiReservation(ctx, req) 583 if err != nil { 584 // TODO: Handle error. 585 } 586 // TODO: Use resp. 587 _ = resp 588 } 589 590 func ExampleClient_UpdateCapacityCommitment() { 591 ctx := context.Background() 592 // This snippet has been automatically generated and should be regarded as a code template only. 593 // It will require modifications to work: 594 // - It may require correct/in-range values for request initialization. 595 // - It may require specifying regional endpoints when creating the service client as shown in: 596 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 597 c, err := reservation.NewClient(ctx) 598 if err != nil { 599 // TODO: Handle error. 600 } 601 defer c.Close() 602 603 req := &reservationpb.UpdateCapacityCommitmentRequest{ 604 // TODO: Fill request struct fields. 605 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#UpdateCapacityCommitmentRequest. 606 } 607 resp, err := c.UpdateCapacityCommitment(ctx, req) 608 if err != nil { 609 // TODO: Handle error. 610 } 611 // TODO: Use resp. 612 _ = resp 613 } 614 615 func ExampleClient_UpdateReservation() { 616 ctx := context.Background() 617 // This snippet has been automatically generated and should be regarded as a code template only. 618 // It will require modifications to work: 619 // - It may require correct/in-range values for request initialization. 620 // - It may require specifying regional endpoints when creating the service client as shown in: 621 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 622 c, err := reservation.NewClient(ctx) 623 if err != nil { 624 // TODO: Handle error. 625 } 626 defer c.Close() 627 628 req := &reservationpb.UpdateReservationRequest{ 629 // TODO: Fill request struct fields. 630 // See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#UpdateReservationRequest. 631 } 632 resp, err := c.UpdateReservation(ctx, req) 633 if err != nil { 634 // TODO: Handle error. 635 } 636 // TODO: Use resp. 637 _ = resp 638 } 639