Skip to content

Commit 9c277b0

Browse files
committed
changed operation result call for initialize cmdlet
1 parent 2b5dc2c commit 9c277b0

File tree

4 files changed

+18024
-22246
lines changed

4 files changed

+18024
-22246
lines changed

src/RecoveryServices/RecoveryServices.Backup.Helpers/TrackingHelpers.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,34 @@ public static RestAzureNS.AzureOperationResponse GetOperationResult(
110110
return opStatusResponse;
111111
}
112112

113+
/// <summary>
114+
/// Block to track the operation to completion.
115+
/// Waits till the HTTP status code of the operation becomes something other than Accepted.
116+
/// </summary>
117+
/// <param name="response">Response of the operation returned by the service.</param>
118+
/// <param name="getOpStatus">Delegate method to fetch the operation status of the operation.</param>
119+
/// <returns>Result of the operation once it completes.</returns>
120+
public static RestAzureNS.AzureOperationResponse<T> GetOperationResult<T>(
121+
RestAzureNS.AzureOperationResponse response,
122+
Func<string, RestAzureNS.AzureOperationResponse<T>> getOpStatus)
123+
where T: ServiceClientModel.ProtectionContainerResource
124+
{
125+
var operationId = response.Response.Headers.GetOperationResultId();
126+
127+
var opStatusResponse = getOpStatus(operationId);
128+
129+
while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
130+
{
131+
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
132+
133+
opStatusResponse = getOpStatus(operationId);
134+
}
135+
136+
opStatusResponse = getOpStatus(operationId);
137+
138+
return opStatusResponse;
139+
}
140+
113141
/// <summary>
114142
/// Block to track the operation to completion.
115143
/// Waits till the HTTP status code of the operation becomes something other than Accepted.

0 commit comments

Comments
 (0)