@@ -17,6 +17,7 @@ import (
1717 "net/http"
1818
1919 "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
20+ "github.com/Azure/azure-sdk-for-go/sdk/internal/poller"
2021)
2122
2223func pollHelper (ctx context.Context , endpoint string , pl runtime.Pipeline , update func (resp * http.Response ) (string , error )) error {
@@ -43,7 +44,7 @@ func resultHelper[T any](resp *http.Response, failed bool, out *T) error {
4344 }
4445
4546 defer resp .Body .Close ()
46- if ! statusCodeValid (resp ) || failed {
47+ if ! poller . StatusCodeValid (resp ) || failed {
4748 // the LRO failed. unmarshall the error and update state
4849 return runtime .NewResponseError (resp )
4950 }
@@ -99,15 +100,15 @@ func NewRestorePoller[T any](pl runtime.Pipeline, resp *http.Response, finalStat
99100 if asyncURL == "" {
100101 return nil , errors .New ("response is missing Azure-AsyncOperation header" )
101102 }
102- if ! isValidURL (asyncURL ) {
103+ if ! poller . IsValidURL (asyncURL ) {
103104 return nil , fmt .Errorf ("invalid polling URL %s" , asyncURL )
104105 }
105106 // check for provisioning state. if the operation is a RELO
106107 // and terminates synchronously this will prevent extra polling.
107108 // it's ok if there's no provisioning state.
108- state , _ := getProvisioningState (resp )
109+ state , _ := poller . GetProvisioningState (resp )
109110 if state == "" {
110- state = statusInProgress
111+ state = poller . StatusInProgress
111112 }
112113 p := & restorePoller [T ]{
113114 pl : pl ,
@@ -124,17 +125,17 @@ func NewRestorePoller[T any](pl runtime.Pipeline, resp *http.Response, finalStat
124125
125126// Done returns true if the LRO is in a terminal state.
126127func (p * restorePoller [T ]) Done () bool {
127- return isTerminalState (p .CurState )
128+ return poller . IsTerminalState (p .CurState )
128129}
129130
130131// Poll retrieves the current state of the LRO.
131132func (p * restorePoller [T ]) Poll (ctx context.Context ) (* http.Response , error ) {
132133 err := pollHelper (ctx , p .AsyncURL , p .pl , func (resp * http.Response ) (string , error ) {
133- if ! statusCodeValid (resp ) {
134+ if ! poller . StatusCodeValid (resp ) {
134135 p .resp = resp
135136 return "" , runtime .NewResponseError (resp )
136137 }
137- state , err := getStatus (resp )
138+ state , err := poller . GetStatus (resp )
138139 if err != nil {
139140 return "" , err
140141 } else if state == "" {
@@ -153,9 +154,9 @@ func (p *restorePoller[T]) Poll(ctx context.Context) (*http.Response, error) {
153154func (p * restorePoller [T ]) Result (ctx context.Context , out * T ) error {
154155 if p .resp .StatusCode == http .StatusNoContent {
155156 return nil
156- } else if failed (p .CurState ) {
157+ } else if poller . Failed (p .CurState ) {
157158 return runtime .NewResponseError (p .resp )
158159 }
159160
160- return resultHelper (p .resp , failed (p .CurState ), out )
161+ return resultHelper (p .resp , poller . Failed (p .CurState ), out )
161162}
0 commit comments