1// +build go1.13 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// Code generated by Microsoft (R) AutoRest Code Generator. 6// Changes may cause incorrect behavior and will be lost if the code is regenerated. 7 8package armcontainerregistry 9 10import ( 11 "context" 12 "github.com/Azure/azure-sdk-for-go/sdk/armcore" 13 "github.com/Azure/azure-sdk-for-go/sdk/azcore" 14 "net/http" 15 "time" 16) 17 18// AgentPoolPoller provides polling facilities until the operation reaches a terminal state. 19type AgentPoolPoller interface { 20 azcore.Poller 21 // FinalResponse performs a final GET to the service and returns the final response 22 // for the polling operation. If there is an error performing the final GET then an error is returned. 23 // If the final GET succeeded then the final AgentPoolResponse will be returned. 24 FinalResponse(ctx context.Context) (AgentPoolResponse, error) 25} 26 27type agentPoolPoller struct { 28 pt *armcore.LROPoller 29} 30 31func (p *agentPoolPoller) Done() bool { 32 return p.pt.Done() 33} 34 35func (p *agentPoolPoller) Poll(ctx context.Context) (*http.Response, error) { 36 return p.pt.Poll(ctx) 37} 38 39func (p *agentPoolPoller) FinalResponse(ctx context.Context) (AgentPoolResponse, error) { 40 respType := AgentPoolResponse{AgentPool: &AgentPool{}} 41 resp, err := p.pt.FinalResponse(ctx, respType.AgentPool) 42 if err != nil { 43 return AgentPoolResponse{}, err 44 } 45 respType.RawResponse = resp 46 return respType, nil 47} 48 49func (p *agentPoolPoller) ResumeToken() (string, error) { 50 return p.pt.ResumeToken() 51} 52 53func (p *agentPoolPoller) pollUntilDone(ctx context.Context, freq time.Duration) (AgentPoolResponse, error) { 54 respType := AgentPoolResponse{AgentPool: &AgentPool{}} 55 resp, err := p.pt.PollUntilDone(ctx, freq, respType.AgentPool) 56 if err != nil { 57 return AgentPoolResponse{}, err 58 } 59 respType.RawResponse = resp 60 return respType, nil 61} 62 63// ConnectedRegistryPoller provides polling facilities until the operation reaches a terminal state. 64type ConnectedRegistryPoller interface { 65 azcore.Poller 66 // FinalResponse performs a final GET to the service and returns the final response 67 // for the polling operation. If there is an error performing the final GET then an error is returned. 68 // If the final GET succeeded then the final ConnectedRegistryResponse will be returned. 69 FinalResponse(ctx context.Context) (ConnectedRegistryResponse, error) 70} 71 72type connectedRegistryPoller struct { 73 pt *armcore.LROPoller 74} 75 76func (p *connectedRegistryPoller) Done() bool { 77 return p.pt.Done() 78} 79 80func (p *connectedRegistryPoller) Poll(ctx context.Context) (*http.Response, error) { 81 return p.pt.Poll(ctx) 82} 83 84func (p *connectedRegistryPoller) FinalResponse(ctx context.Context) (ConnectedRegistryResponse, error) { 85 respType := ConnectedRegistryResponse{ConnectedRegistry: &ConnectedRegistry{}} 86 resp, err := p.pt.FinalResponse(ctx, respType.ConnectedRegistry) 87 if err != nil { 88 return ConnectedRegistryResponse{}, err 89 } 90 respType.RawResponse = resp 91 return respType, nil 92} 93 94func (p *connectedRegistryPoller) ResumeToken() (string, error) { 95 return p.pt.ResumeToken() 96} 97 98func (p *connectedRegistryPoller) pollUntilDone(ctx context.Context, freq time.Duration) (ConnectedRegistryResponse, error) { 99 respType := ConnectedRegistryResponse{ConnectedRegistry: &ConnectedRegistry{}} 100 resp, err := p.pt.PollUntilDone(ctx, freq, respType.ConnectedRegistry) 101 if err != nil { 102 return ConnectedRegistryResponse{}, err 103 } 104 respType.RawResponse = resp 105 return respType, nil 106} 107 108// ExportPipelinePoller provides polling facilities until the operation reaches a terminal state. 109type ExportPipelinePoller interface { 110 azcore.Poller 111 // FinalResponse performs a final GET to the service and returns the final response 112 // for the polling operation. If there is an error performing the final GET then an error is returned. 113 // If the final GET succeeded then the final ExportPipelineResponse will be returned. 114 FinalResponse(ctx context.Context) (ExportPipelineResponse, error) 115} 116 117type exportPipelinePoller struct { 118 pt *armcore.LROPoller 119} 120 121func (p *exportPipelinePoller) Done() bool { 122 return p.pt.Done() 123} 124 125func (p *exportPipelinePoller) Poll(ctx context.Context) (*http.Response, error) { 126 return p.pt.Poll(ctx) 127} 128 129func (p *exportPipelinePoller) FinalResponse(ctx context.Context) (ExportPipelineResponse, error) { 130 respType := ExportPipelineResponse{ExportPipeline: &ExportPipeline{}} 131 resp, err := p.pt.FinalResponse(ctx, respType.ExportPipeline) 132 if err != nil { 133 return ExportPipelineResponse{}, err 134 } 135 respType.RawResponse = resp 136 return respType, nil 137} 138 139func (p *exportPipelinePoller) ResumeToken() (string, error) { 140 return p.pt.ResumeToken() 141} 142 143func (p *exportPipelinePoller) pollUntilDone(ctx context.Context, freq time.Duration) (ExportPipelineResponse, error) { 144 respType := ExportPipelineResponse{ExportPipeline: &ExportPipeline{}} 145 resp, err := p.pt.PollUntilDone(ctx, freq, respType.ExportPipeline) 146 if err != nil { 147 return ExportPipelineResponse{}, err 148 } 149 respType.RawResponse = resp 150 return respType, nil 151} 152 153// GenerateCredentialsResultPoller provides polling facilities until the operation reaches a terminal state. 154type GenerateCredentialsResultPoller interface { 155 azcore.Poller 156 // FinalResponse performs a final GET to the service and returns the final response 157 // for the polling operation. If there is an error performing the final GET then an error is returned. 158 // If the final GET succeeded then the final GenerateCredentialsResultResponse will be returned. 159 FinalResponse(ctx context.Context) (GenerateCredentialsResultResponse, error) 160} 161 162type generateCredentialsResultPoller struct { 163 pt *armcore.LROPoller 164} 165 166func (p *generateCredentialsResultPoller) Done() bool { 167 return p.pt.Done() 168} 169 170func (p *generateCredentialsResultPoller) Poll(ctx context.Context) (*http.Response, error) { 171 return p.pt.Poll(ctx) 172} 173 174func (p *generateCredentialsResultPoller) FinalResponse(ctx context.Context) (GenerateCredentialsResultResponse, error) { 175 respType := GenerateCredentialsResultResponse{GenerateCredentialsResult: &GenerateCredentialsResult{}} 176 resp, err := p.pt.FinalResponse(ctx, respType.GenerateCredentialsResult) 177 if err != nil { 178 return GenerateCredentialsResultResponse{}, err 179 } 180 respType.RawResponse = resp 181 return respType, nil 182} 183 184func (p *generateCredentialsResultPoller) ResumeToken() (string, error) { 185 return p.pt.ResumeToken() 186} 187 188func (p *generateCredentialsResultPoller) pollUntilDone(ctx context.Context, freq time.Duration) (GenerateCredentialsResultResponse, error) { 189 respType := GenerateCredentialsResultResponse{GenerateCredentialsResult: &GenerateCredentialsResult{}} 190 resp, err := p.pt.PollUntilDone(ctx, freq, respType.GenerateCredentialsResult) 191 if err != nil { 192 return GenerateCredentialsResultResponse{}, err 193 } 194 respType.RawResponse = resp 195 return respType, nil 196} 197 198// HTTPPoller provides polling facilities until the operation reaches a terminal state. 199type HTTPPoller interface { 200 azcore.Poller 201 // FinalResponse performs a final GET to the service and returns the final response 202 // for the polling operation. If there is an error performing the final GET then an error is returned. 203 // If the final GET succeeded then the final *http.Response will be returned. 204 FinalResponse(ctx context.Context) (*http.Response, error) 205} 206 207type httpPoller struct { 208 pt *armcore.LROPoller 209} 210 211func (p *httpPoller) Done() bool { 212 return p.pt.Done() 213} 214 215func (p *httpPoller) Poll(ctx context.Context) (*http.Response, error) { 216 return p.pt.Poll(ctx) 217} 218 219func (p *httpPoller) FinalResponse(ctx context.Context) (*http.Response, error) { 220 return p.pt.FinalResponse(ctx, nil) 221} 222 223func (p *httpPoller) ResumeToken() (string, error) { 224 return p.pt.ResumeToken() 225} 226 227func (p *httpPoller) pollUntilDone(ctx context.Context, freq time.Duration) (*http.Response, error) { 228 return p.pt.PollUntilDone(ctx, freq, nil) 229} 230 231// ImportPipelinePoller provides polling facilities until the operation reaches a terminal state. 232type ImportPipelinePoller interface { 233 azcore.Poller 234 // FinalResponse performs a final GET to the service and returns the final response 235 // for the polling operation. If there is an error performing the final GET then an error is returned. 236 // If the final GET succeeded then the final ImportPipelineResponse will be returned. 237 FinalResponse(ctx context.Context) (ImportPipelineResponse, error) 238} 239 240type importPipelinePoller struct { 241 pt *armcore.LROPoller 242} 243 244func (p *importPipelinePoller) Done() bool { 245 return p.pt.Done() 246} 247 248func (p *importPipelinePoller) Poll(ctx context.Context) (*http.Response, error) { 249 return p.pt.Poll(ctx) 250} 251 252func (p *importPipelinePoller) FinalResponse(ctx context.Context) (ImportPipelineResponse, error) { 253 respType := ImportPipelineResponse{ImportPipeline: &ImportPipeline{}} 254 resp, err := p.pt.FinalResponse(ctx, respType.ImportPipeline) 255 if err != nil { 256 return ImportPipelineResponse{}, err 257 } 258 respType.RawResponse = resp 259 return respType, nil 260} 261 262func (p *importPipelinePoller) ResumeToken() (string, error) { 263 return p.pt.ResumeToken() 264} 265 266func (p *importPipelinePoller) pollUntilDone(ctx context.Context, freq time.Duration) (ImportPipelineResponse, error) { 267 respType := ImportPipelineResponse{ImportPipeline: &ImportPipeline{}} 268 resp, err := p.pt.PollUntilDone(ctx, freq, respType.ImportPipeline) 269 if err != nil { 270 return ImportPipelineResponse{}, err 271 } 272 respType.RawResponse = resp 273 return respType, nil 274} 275 276// PipelineRunPoller provides polling facilities until the operation reaches a terminal state. 277type PipelineRunPoller interface { 278 azcore.Poller 279 // FinalResponse performs a final GET to the service and returns the final response 280 // for the polling operation. If there is an error performing the final GET then an error is returned. 281 // If the final GET succeeded then the final PipelineRunResponseType will be returned. 282 FinalResponse(ctx context.Context) (PipelineRunResponseType, error) 283} 284 285type pipelineRunPoller struct { 286 pt *armcore.LROPoller 287} 288 289func (p *pipelineRunPoller) Done() bool { 290 return p.pt.Done() 291} 292 293func (p *pipelineRunPoller) Poll(ctx context.Context) (*http.Response, error) { 294 return p.pt.Poll(ctx) 295} 296 297func (p *pipelineRunPoller) FinalResponse(ctx context.Context) (PipelineRunResponseType, error) { 298 respType := PipelineRunResponseType{PipelineRun: &PipelineRun{}} 299 resp, err := p.pt.FinalResponse(ctx, respType.PipelineRun) 300 if err != nil { 301 return PipelineRunResponseType{}, err 302 } 303 respType.RawResponse = resp 304 return respType, nil 305} 306 307func (p *pipelineRunPoller) ResumeToken() (string, error) { 308 return p.pt.ResumeToken() 309} 310 311func (p *pipelineRunPoller) pollUntilDone(ctx context.Context, freq time.Duration) (PipelineRunResponseType, error) { 312 respType := PipelineRunResponseType{PipelineRun: &PipelineRun{}} 313 resp, err := p.pt.PollUntilDone(ctx, freq, respType.PipelineRun) 314 if err != nil { 315 return PipelineRunResponseType{}, err 316 } 317 respType.RawResponse = resp 318 return respType, nil 319} 320 321// PrivateEndpointConnectionPoller provides polling facilities until the operation reaches a terminal state. 322type PrivateEndpointConnectionPoller interface { 323 azcore.Poller 324 // FinalResponse performs a final GET to the service and returns the final response 325 // for the polling operation. If there is an error performing the final GET then an error is returned. 326 // If the final GET succeeded then the final PrivateEndpointConnectionResponse will be returned. 327 FinalResponse(ctx context.Context) (PrivateEndpointConnectionResponse, error) 328} 329 330type privateEndpointConnectionPoller struct { 331 pt *armcore.LROPoller 332} 333 334func (p *privateEndpointConnectionPoller) Done() bool { 335 return p.pt.Done() 336} 337 338func (p *privateEndpointConnectionPoller) Poll(ctx context.Context) (*http.Response, error) { 339 return p.pt.Poll(ctx) 340} 341 342func (p *privateEndpointConnectionPoller) FinalResponse(ctx context.Context) (PrivateEndpointConnectionResponse, error) { 343 respType := PrivateEndpointConnectionResponse{PrivateEndpointConnection: &PrivateEndpointConnection{}} 344 resp, err := p.pt.FinalResponse(ctx, respType.PrivateEndpointConnection) 345 if err != nil { 346 return PrivateEndpointConnectionResponse{}, err 347 } 348 respType.RawResponse = resp 349 return respType, nil 350} 351 352func (p *privateEndpointConnectionPoller) ResumeToken() (string, error) { 353 return p.pt.ResumeToken() 354} 355 356func (p *privateEndpointConnectionPoller) pollUntilDone(ctx context.Context, freq time.Duration) (PrivateEndpointConnectionResponse, error) { 357 respType := PrivateEndpointConnectionResponse{PrivateEndpointConnection: &PrivateEndpointConnection{}} 358 resp, err := p.pt.PollUntilDone(ctx, freq, respType.PrivateEndpointConnection) 359 if err != nil { 360 return PrivateEndpointConnectionResponse{}, err 361 } 362 respType.RawResponse = resp 363 return respType, nil 364} 365 366// RegistryPoller provides polling facilities until the operation reaches a terminal state. 367type RegistryPoller interface { 368 azcore.Poller 369 // FinalResponse performs a final GET to the service and returns the final response 370 // for the polling operation. If there is an error performing the final GET then an error is returned. 371 // If the final GET succeeded then the final RegistryResponse will be returned. 372 FinalResponse(ctx context.Context) (RegistryResponse, error) 373} 374 375type registryPoller struct { 376 pt *armcore.LROPoller 377} 378 379func (p *registryPoller) Done() bool { 380 return p.pt.Done() 381} 382 383func (p *registryPoller) Poll(ctx context.Context) (*http.Response, error) { 384 return p.pt.Poll(ctx) 385} 386 387func (p *registryPoller) FinalResponse(ctx context.Context) (RegistryResponse, error) { 388 respType := RegistryResponse{Registry: &Registry{}} 389 resp, err := p.pt.FinalResponse(ctx, respType.Registry) 390 if err != nil { 391 return RegistryResponse{}, err 392 } 393 respType.RawResponse = resp 394 return respType, nil 395} 396 397func (p *registryPoller) ResumeToken() (string, error) { 398 return p.pt.ResumeToken() 399} 400 401func (p *registryPoller) pollUntilDone(ctx context.Context, freq time.Duration) (RegistryResponse, error) { 402 respType := RegistryResponse{Registry: &Registry{}} 403 resp, err := p.pt.PollUntilDone(ctx, freq, respType.Registry) 404 if err != nil { 405 return RegistryResponse{}, err 406 } 407 respType.RawResponse = resp 408 return respType, nil 409} 410 411// ReplicationPoller provides polling facilities until the operation reaches a terminal state. 412type ReplicationPoller interface { 413 azcore.Poller 414 // FinalResponse performs a final GET to the service and returns the final response 415 // for the polling operation. If there is an error performing the final GET then an error is returned. 416 // If the final GET succeeded then the final ReplicationResponse will be returned. 417 FinalResponse(ctx context.Context) (ReplicationResponse, error) 418} 419 420type replicationPoller struct { 421 pt *armcore.LROPoller 422} 423 424func (p *replicationPoller) Done() bool { 425 return p.pt.Done() 426} 427 428func (p *replicationPoller) Poll(ctx context.Context) (*http.Response, error) { 429 return p.pt.Poll(ctx) 430} 431 432func (p *replicationPoller) FinalResponse(ctx context.Context) (ReplicationResponse, error) { 433 respType := ReplicationResponse{Replication: &Replication{}} 434 resp, err := p.pt.FinalResponse(ctx, respType.Replication) 435 if err != nil { 436 return ReplicationResponse{}, err 437 } 438 respType.RawResponse = resp 439 return respType, nil 440} 441 442func (p *replicationPoller) ResumeToken() (string, error) { 443 return p.pt.ResumeToken() 444} 445 446func (p *replicationPoller) pollUntilDone(ctx context.Context, freq time.Duration) (ReplicationResponse, error) { 447 respType := ReplicationResponse{Replication: &Replication{}} 448 resp, err := p.pt.PollUntilDone(ctx, freq, respType.Replication) 449 if err != nil { 450 return ReplicationResponse{}, err 451 } 452 respType.RawResponse = resp 453 return respType, nil 454} 455 456// RunPoller provides polling facilities until the operation reaches a terminal state. 457type RunPoller interface { 458 azcore.Poller 459 // FinalResponse performs a final GET to the service and returns the final response 460 // for the polling operation. If there is an error performing the final GET then an error is returned. 461 // If the final GET succeeded then the final RunResponse will be returned. 462 FinalResponse(ctx context.Context) (RunResponse, error) 463} 464 465type runPoller struct { 466 pt *armcore.LROPoller 467} 468 469func (p *runPoller) Done() bool { 470 return p.pt.Done() 471} 472 473func (p *runPoller) Poll(ctx context.Context) (*http.Response, error) { 474 return p.pt.Poll(ctx) 475} 476 477func (p *runPoller) FinalResponse(ctx context.Context) (RunResponse, error) { 478 respType := RunResponse{Run: &Run{}} 479 resp, err := p.pt.FinalResponse(ctx, respType.Run) 480 if err != nil { 481 return RunResponse{}, err 482 } 483 respType.RawResponse = resp 484 return respType, nil 485} 486 487func (p *runPoller) ResumeToken() (string, error) { 488 return p.pt.ResumeToken() 489} 490 491func (p *runPoller) pollUntilDone(ctx context.Context, freq time.Duration) (RunResponse, error) { 492 respType := RunResponse{Run: &Run{}} 493 resp, err := p.pt.PollUntilDone(ctx, freq, respType.Run) 494 if err != nil { 495 return RunResponse{}, err 496 } 497 respType.RawResponse = resp 498 return respType, nil 499} 500 501// ScopeMapPoller provides polling facilities until the operation reaches a terminal state. 502type ScopeMapPoller interface { 503 azcore.Poller 504 // FinalResponse performs a final GET to the service and returns the final response 505 // for the polling operation. If there is an error performing the final GET then an error is returned. 506 // If the final GET succeeded then the final ScopeMapResponse will be returned. 507 FinalResponse(ctx context.Context) (ScopeMapResponse, error) 508} 509 510type scopeMapPoller struct { 511 pt *armcore.LROPoller 512} 513 514func (p *scopeMapPoller) Done() bool { 515 return p.pt.Done() 516} 517 518func (p *scopeMapPoller) Poll(ctx context.Context) (*http.Response, error) { 519 return p.pt.Poll(ctx) 520} 521 522func (p *scopeMapPoller) FinalResponse(ctx context.Context) (ScopeMapResponse, error) { 523 respType := ScopeMapResponse{ScopeMap: &ScopeMap{}} 524 resp, err := p.pt.FinalResponse(ctx, respType.ScopeMap) 525 if err != nil { 526 return ScopeMapResponse{}, err 527 } 528 respType.RawResponse = resp 529 return respType, nil 530} 531 532func (p *scopeMapPoller) ResumeToken() (string, error) { 533 return p.pt.ResumeToken() 534} 535 536func (p *scopeMapPoller) pollUntilDone(ctx context.Context, freq time.Duration) (ScopeMapResponse, error) { 537 respType := ScopeMapResponse{ScopeMap: &ScopeMap{}} 538 resp, err := p.pt.PollUntilDone(ctx, freq, respType.ScopeMap) 539 if err != nil { 540 return ScopeMapResponse{}, err 541 } 542 respType.RawResponse = resp 543 return respType, nil 544} 545 546// TaskPoller provides polling facilities until the operation reaches a terminal state. 547type TaskPoller interface { 548 azcore.Poller 549 // FinalResponse performs a final GET to the service and returns the final response 550 // for the polling operation. If there is an error performing the final GET then an error is returned. 551 // If the final GET succeeded then the final TaskResponse will be returned. 552 FinalResponse(ctx context.Context) (TaskResponse, error) 553} 554 555type taskPoller struct { 556 pt *armcore.LROPoller 557} 558 559func (p *taskPoller) Done() bool { 560 return p.pt.Done() 561} 562 563func (p *taskPoller) Poll(ctx context.Context) (*http.Response, error) { 564 return p.pt.Poll(ctx) 565} 566 567func (p *taskPoller) FinalResponse(ctx context.Context) (TaskResponse, error) { 568 respType := TaskResponse{Task: &Task{}} 569 resp, err := p.pt.FinalResponse(ctx, respType.Task) 570 if err != nil { 571 return TaskResponse{}, err 572 } 573 respType.RawResponse = resp 574 return respType, nil 575} 576 577func (p *taskPoller) ResumeToken() (string, error) { 578 return p.pt.ResumeToken() 579} 580 581func (p *taskPoller) pollUntilDone(ctx context.Context, freq time.Duration) (TaskResponse, error) { 582 respType := TaskResponse{Task: &Task{}} 583 resp, err := p.pt.PollUntilDone(ctx, freq, respType.Task) 584 if err != nil { 585 return TaskResponse{}, err 586 } 587 respType.RawResponse = resp 588 return respType, nil 589} 590 591// TaskRunPoller provides polling facilities until the operation reaches a terminal state. 592type TaskRunPoller interface { 593 azcore.Poller 594 // FinalResponse performs a final GET to the service and returns the final response 595 // for the polling operation. If there is an error performing the final GET then an error is returned. 596 // If the final GET succeeded then the final TaskRunResponse will be returned. 597 FinalResponse(ctx context.Context) (TaskRunResponse, error) 598} 599 600type taskRunPoller struct { 601 pt *armcore.LROPoller 602} 603 604func (p *taskRunPoller) Done() bool { 605 return p.pt.Done() 606} 607 608func (p *taskRunPoller) Poll(ctx context.Context) (*http.Response, error) { 609 return p.pt.Poll(ctx) 610} 611 612func (p *taskRunPoller) FinalResponse(ctx context.Context) (TaskRunResponse, error) { 613 respType := TaskRunResponse{TaskRun: &TaskRun{}} 614 resp, err := p.pt.FinalResponse(ctx, respType.TaskRun) 615 if err != nil { 616 return TaskRunResponse{}, err 617 } 618 respType.RawResponse = resp 619 return respType, nil 620} 621 622func (p *taskRunPoller) ResumeToken() (string, error) { 623 return p.pt.ResumeToken() 624} 625 626func (p *taskRunPoller) pollUntilDone(ctx context.Context, freq time.Duration) (TaskRunResponse, error) { 627 respType := TaskRunResponse{TaskRun: &TaskRun{}} 628 resp, err := p.pt.PollUntilDone(ctx, freq, respType.TaskRun) 629 if err != nil { 630 return TaskRunResponse{}, err 631 } 632 respType.RawResponse = resp 633 return respType, nil 634} 635 636// TokenPoller provides polling facilities until the operation reaches a terminal state. 637type TokenPoller interface { 638 azcore.Poller 639 // FinalResponse performs a final GET to the service and returns the final response 640 // for the polling operation. If there is an error performing the final GET then an error is returned. 641 // If the final GET succeeded then the final TokenResponse will be returned. 642 FinalResponse(ctx context.Context) (TokenResponse, error) 643} 644 645type tokenPoller struct { 646 pt *armcore.LROPoller 647} 648 649func (p *tokenPoller) Done() bool { 650 return p.pt.Done() 651} 652 653func (p *tokenPoller) Poll(ctx context.Context) (*http.Response, error) { 654 return p.pt.Poll(ctx) 655} 656 657func (p *tokenPoller) FinalResponse(ctx context.Context) (TokenResponse, error) { 658 respType := TokenResponse{Token: &Token{}} 659 resp, err := p.pt.FinalResponse(ctx, respType.Token) 660 if err != nil { 661 return TokenResponse{}, err 662 } 663 respType.RawResponse = resp 664 return respType, nil 665} 666 667func (p *tokenPoller) ResumeToken() (string, error) { 668 return p.pt.ResumeToken() 669} 670 671func (p *tokenPoller) pollUntilDone(ctx context.Context, freq time.Duration) (TokenResponse, error) { 672 respType := TokenResponse{Token: &Token{}} 673 resp, err := p.pt.PollUntilDone(ctx, freq, respType.Token) 674 if err != nil { 675 return TokenResponse{}, err 676 } 677 respType.RawResponse = resp 678 return respType, nil 679} 680 681// WebhookPoller provides polling facilities until the operation reaches a terminal state. 682type WebhookPoller interface { 683 azcore.Poller 684 // FinalResponse performs a final GET to the service and returns the final response 685 // for the polling operation. If there is an error performing the final GET then an error is returned. 686 // If the final GET succeeded then the final WebhookResponse will be returned. 687 FinalResponse(ctx context.Context) (WebhookResponse, error) 688} 689 690type webhookPoller struct { 691 pt *armcore.LROPoller 692} 693 694func (p *webhookPoller) Done() bool { 695 return p.pt.Done() 696} 697 698func (p *webhookPoller) Poll(ctx context.Context) (*http.Response, error) { 699 return p.pt.Poll(ctx) 700} 701 702func (p *webhookPoller) FinalResponse(ctx context.Context) (WebhookResponse, error) { 703 respType := WebhookResponse{Webhook: &Webhook{}} 704 resp, err := p.pt.FinalResponse(ctx, respType.Webhook) 705 if err != nil { 706 return WebhookResponse{}, err 707 } 708 respType.RawResponse = resp 709 return respType, nil 710} 711 712func (p *webhookPoller) ResumeToken() (string, error) { 713 return p.pt.ResumeToken() 714} 715 716func (p *webhookPoller) pollUntilDone(ctx context.Context, freq time.Duration) (WebhookResponse, error) { 717 respType := WebhookResponse{Webhook: &Webhook{}} 718 resp, err := p.pt.PollUntilDone(ctx, freq, respType.Webhook) 719 if err != nil { 720 return WebhookResponse{}, err 721 } 722 respType.RawResponse = resp 723 return respType, nil 724} 725