Skip to content

Commit 3be2043

Browse files
authored
[Az.RecoveryServices.Backup] Fixed bugs, added documentation and examples (#22159)
* Regenerated CRR SDK. Fixed issues with SQL CRR. Fixed bug with rp expiry time, making 30 days expiry time for adhoc backup as default from client side. Added example to fetch pruned recovery points after modify policy. Fixed the documentation for suspend backups with immutability. Updated changelog * Regenerated help * Added test case and final fixes. * Update GetAzureRmRecoveryServicesBackupJob.cs * Update GetAzureRmRecoveryServicesBackupJobDetails.cs
1 parent e760e8f commit 3be2043

File tree

24 files changed

+3006
-61
lines changed

24 files changed

+3006
-61
lines changed

src/RecoveryServices/RecoveryServices.Backup.CrossRegionRestore.Management.Sdk/Generated/IRecoveryPointsCrrOperations.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,45 @@ public partial interface IRecoveryPointsCrrOperations
6363
/// </exception>
6464
Task<AzureOperationResponse<IPage<RecoveryPointResource>>> ListWithHttpMessagesAsync(string vaultName, string resourceGroupName, string fabricName, string containerName, string protectedItemName, ODataQuery<BMSRPQueryObject> odataQuery = default(ODataQuery<BMSRPQueryObject>), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
6565
/// <summary>
66+
/// Provides the information of the backed up data identified using
67+
/// RecoveryPointID.
68+
/// </summary>
69+
/// <param name='vaultName'>
70+
/// The name of the recovery services vault.
71+
/// </param>
72+
/// <param name='resourceGroupName'>
73+
/// The name of the resource group where the recovery services vault is
74+
/// present.
75+
/// </param>
76+
/// <param name='fabricName'>
77+
/// Fabric name associated with backed up item.
78+
/// </param>
79+
/// <param name='containerName'>
80+
/// Container name associated with backed up item.
81+
/// </param>
82+
/// <param name='protectedItemName'>
83+
/// Backed up item name whose backup data needs to be fetched.
84+
/// </param>
85+
/// <param name='recoveryPointId'>
86+
/// RecoveryPointID represents the backed up data to be fetched.
87+
/// </param>
88+
/// <param name='customHeaders'>
89+
/// The headers that will be added to request.
90+
/// </param>
91+
/// <param name='cancellationToken'>
92+
/// The cancellation token.
93+
/// </param>
94+
/// <exception cref="NewErrorResponseException">
95+
/// Thrown when the operation returned an invalid status code
96+
/// </exception>
97+
/// <exception cref="Microsoft.Rest.SerializationException">
98+
/// Thrown when unable to deserialize the response
99+
/// </exception>
100+
/// <exception cref="Microsoft.Rest.ValidationException">
101+
/// Thrown when a required parameter is null
102+
/// </exception>
103+
Task<AzureOperationResponse<RecoveryPointResource>> GetWithHttpMessagesAsync(string vaultName, string resourceGroupName, string fabricName, string containerName, string protectedItemName, string recoveryPointId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
104+
/// <summary>
66105
/// Lists the backup copies for the backed up item.
67106
/// </summary>
68107
/// <param name='nextPageLink'>

src/RecoveryServices/RecoveryServices.Backup.CrossRegionRestore.Management.Sdk/Generated/RecoveryPointsCrrOperations.cs

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,235 @@ internal RecoveryPointsCrrOperations(RecoveryServicesBackupClient client)
282282
return _result;
283283
}
284284

285+
/// <summary>
286+
/// Provides the information of the backed up data identified using
287+
/// RecoveryPointID.
288+
/// </summary>
289+
/// <param name='vaultName'>
290+
/// The name of the recovery services vault.
291+
/// </param>
292+
/// <param name='resourceGroupName'>
293+
/// The name of the resource group where the recovery services vault is
294+
/// present.
295+
/// </param>
296+
/// <param name='fabricName'>
297+
/// Fabric name associated with backed up item.
298+
/// </param>
299+
/// <param name='containerName'>
300+
/// Container name associated with backed up item.
301+
/// </param>
302+
/// <param name='protectedItemName'>
303+
/// Backed up item name whose backup data needs to be fetched.
304+
/// </param>
305+
/// <param name='recoveryPointId'>
306+
/// RecoveryPointID represents the backed up data to be fetched.
307+
/// </param>
308+
/// <param name='customHeaders'>
309+
/// Headers that will be added to request.
310+
/// </param>
311+
/// <param name='cancellationToken'>
312+
/// The cancellation token.
313+
/// </param>
314+
/// <exception cref="NewErrorResponseException">
315+
/// Thrown when the operation returned an invalid status code
316+
/// </exception>
317+
/// <exception cref="SerializationException">
318+
/// Thrown when unable to deserialize the response
319+
/// </exception>
320+
/// <exception cref="ValidationException">
321+
/// Thrown when a required parameter is null
322+
/// </exception>
323+
/// <exception cref="System.ArgumentNullException">
324+
/// Thrown when a required parameter is null
325+
/// </exception>
326+
/// <return>
327+
/// A response object containing the response body and response headers.
328+
/// </return>
329+
public async Task<AzureOperationResponse<RecoveryPointResource>> GetWithHttpMessagesAsync(string vaultName, string resourceGroupName, string fabricName, string containerName, string protectedItemName, string recoveryPointId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
330+
{
331+
if (Client.ApiVersion == null)
332+
{
333+
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
334+
}
335+
if (vaultName == null)
336+
{
337+
throw new ValidationException(ValidationRules.CannotBeNull, "vaultName");
338+
}
339+
if (resourceGroupName == null)
340+
{
341+
throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
342+
}
343+
if (Client.SubscriptionId == null)
344+
{
345+
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
346+
}
347+
if (fabricName == null)
348+
{
349+
throw new ValidationException(ValidationRules.CannotBeNull, "fabricName");
350+
}
351+
if (containerName == null)
352+
{
353+
throw new ValidationException(ValidationRules.CannotBeNull, "containerName");
354+
}
355+
if (protectedItemName == null)
356+
{
357+
throw new ValidationException(ValidationRules.CannotBeNull, "protectedItemName");
358+
}
359+
if (recoveryPointId == null)
360+
{
361+
throw new ValidationException(ValidationRules.CannotBeNull, "recoveryPointId");
362+
}
363+
// Tracing
364+
bool _shouldTrace = ServiceClientTracing.IsEnabled;
365+
string _invocationId = null;
366+
if (_shouldTrace)
367+
{
368+
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
369+
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
370+
tracingParameters.Add("vaultName", vaultName);
371+
tracingParameters.Add("resourceGroupName", resourceGroupName);
372+
tracingParameters.Add("fabricName", fabricName);
373+
tracingParameters.Add("containerName", containerName);
374+
tracingParameters.Add("protectedItemName", protectedItemName);
375+
tracingParameters.Add("recoveryPointId", recoveryPointId);
376+
tracingParameters.Add("cancellationToken", cancellationToken);
377+
ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
378+
}
379+
// Construct URL
380+
var _baseUrl = Client.BaseUri.AbsoluteUri;
381+
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupFabrics/{fabricName}/protectionContainers/{containerName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointId}").ToString();
382+
_url = _url.Replace("{vaultName}", System.Uri.EscapeDataString(vaultName));
383+
_url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
384+
_url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
385+
_url = _url.Replace("{fabricName}", System.Uri.EscapeDataString(fabricName));
386+
_url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName));
387+
_url = _url.Replace("{protectedItemName}", System.Uri.EscapeDataString(protectedItemName));
388+
_url = _url.Replace("{recoveryPointId}", System.Uri.EscapeDataString(recoveryPointId));
389+
List<string> _queryParameters = new List<string>();
390+
if (Client.ApiVersion != null)
391+
{
392+
_queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
393+
}
394+
if (_queryParameters.Count > 0)
395+
{
396+
_url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
397+
}
398+
// Create HTTP transport objects
399+
var _httpRequest = new HttpRequestMessage();
400+
HttpResponseMessage _httpResponse = null;
401+
_httpRequest.Method = new HttpMethod("GET");
402+
_httpRequest.RequestUri = new System.Uri(_url);
403+
// Set Headers
404+
if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
405+
{
406+
_httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
407+
}
408+
if (Client.AcceptLanguage != null)
409+
{
410+
if (_httpRequest.Headers.Contains("accept-language"))
411+
{
412+
_httpRequest.Headers.Remove("accept-language");
413+
}
414+
_httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
415+
}
416+
417+
418+
if (customHeaders != null)
419+
{
420+
foreach(var _header in customHeaders)
421+
{
422+
if (_httpRequest.Headers.Contains(_header.Key))
423+
{
424+
_httpRequest.Headers.Remove(_header.Key);
425+
}
426+
_httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
427+
}
428+
}
429+
430+
// Serialize Request
431+
string _requestContent = null;
432+
// Set Credentials
433+
if (Client.Credentials != null)
434+
{
435+
cancellationToken.ThrowIfCancellationRequested();
436+
await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
437+
}
438+
// Send Request
439+
if (_shouldTrace)
440+
{
441+
ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
442+
}
443+
cancellationToken.ThrowIfCancellationRequested();
444+
_httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
445+
if (_shouldTrace)
446+
{
447+
ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
448+
}
449+
HttpStatusCode _statusCode = _httpResponse.StatusCode;
450+
cancellationToken.ThrowIfCancellationRequested();
451+
string _responseContent = null;
452+
if ((int)_statusCode != 200)
453+
{
454+
var ex = new NewErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
455+
try
456+
{
457+
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
458+
NewErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<NewErrorResponse>(_responseContent, Client.DeserializationSettings);
459+
if (_errorBody != null)
460+
{
461+
ex.Body = _errorBody;
462+
}
463+
}
464+
catch (JsonException)
465+
{
466+
// Ignore the exception
467+
}
468+
ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
469+
ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
470+
if (_shouldTrace)
471+
{
472+
ServiceClientTracing.Error(_invocationId, ex);
473+
}
474+
_httpRequest.Dispose();
475+
if (_httpResponse != null)
476+
{
477+
_httpResponse.Dispose();
478+
}
479+
throw ex;
480+
}
481+
// Create Result
482+
var _result = new AzureOperationResponse<RecoveryPointResource>();
483+
_result.Request = _httpRequest;
484+
_result.Response = _httpResponse;
485+
if (_httpResponse.Headers.Contains("x-ms-request-id"))
486+
{
487+
_result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
488+
}
489+
// Deserialize Response
490+
if ((int)_statusCode == 200)
491+
{
492+
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
493+
try
494+
{
495+
_result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<RecoveryPointResource>(_responseContent, Client.DeserializationSettings);
496+
}
497+
catch (JsonException ex)
498+
{
499+
_httpRequest.Dispose();
500+
if (_httpResponse != null)
501+
{
502+
_httpResponse.Dispose();
503+
}
504+
throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
505+
}
506+
}
507+
if (_shouldTrace)
508+
{
509+
ServiceClientTracing.Exit(_invocationId, _result);
510+
}
511+
return _result;
512+
}
513+
285514
/// <summary>
286515
/// Lists the backup copies for the backed up item.
287516
/// </summary>

src/RecoveryServices/RecoveryServices.Backup.CrossRegionRestore.Management.Sdk/Generated/RecoveryPointsCrrOperationsExtensions.cs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,74 @@ public static partial class RecoveryPointsCrrOperationsExtensions
8888
}
8989
}
9090

91+
/// <summary>
92+
/// Provides the information of the backed up data identified using
93+
/// RecoveryPointID.
94+
/// </summary>
95+
/// <param name='operations'>
96+
/// The operations group for this extension method.
97+
/// </param>
98+
/// <param name='vaultName'>
99+
/// The name of the recovery services vault.
100+
/// </param>
101+
/// <param name='resourceGroupName'>
102+
/// The name of the resource group where the recovery services vault is
103+
/// present.
104+
/// </param>
105+
/// <param name='fabricName'>
106+
/// Fabric name associated with backed up item.
107+
/// </param>
108+
/// <param name='containerName'>
109+
/// Container name associated with backed up item.
110+
/// </param>
111+
/// <param name='protectedItemName'>
112+
/// Backed up item name whose backup data needs to be fetched.
113+
/// </param>
114+
/// <param name='recoveryPointId'>
115+
/// RecoveryPointID represents the backed up data to be fetched.
116+
/// </param>
117+
public static RecoveryPointResource Get(this IRecoveryPointsCrrOperations operations, string vaultName, string resourceGroupName, string fabricName, string containerName, string protectedItemName, string recoveryPointId)
118+
{
119+
return operations.GetAsync(vaultName, resourceGroupName, fabricName, containerName, protectedItemName, recoveryPointId).GetAwaiter().GetResult();
120+
}
121+
122+
/// <summary>
123+
/// Provides the information of the backed up data identified using
124+
/// RecoveryPointID.
125+
/// </summary>
126+
/// <param name='operations'>
127+
/// The operations group for this extension method.
128+
/// </param>
129+
/// <param name='vaultName'>
130+
/// The name of the recovery services vault.
131+
/// </param>
132+
/// <param name='resourceGroupName'>
133+
/// The name of the resource group where the recovery services vault is
134+
/// present.
135+
/// </param>
136+
/// <param name='fabricName'>
137+
/// Fabric name associated with backed up item.
138+
/// </param>
139+
/// <param name='containerName'>
140+
/// Container name associated with backed up item.
141+
/// </param>
142+
/// <param name='protectedItemName'>
143+
/// Backed up item name whose backup data needs to be fetched.
144+
/// </param>
145+
/// <param name='recoveryPointId'>
146+
/// RecoveryPointID represents the backed up data to be fetched.
147+
/// </param>
148+
/// <param name='cancellationToken'>
149+
/// The cancellation token.
150+
/// </param>
151+
public static async Task<RecoveryPointResource> GetAsync(this IRecoveryPointsCrrOperations operations, string vaultName, string resourceGroupName, string fabricName, string containerName, string protectedItemName, string recoveryPointId, CancellationToken cancellationToken = default(CancellationToken))
152+
{
153+
using (var _result = await operations.GetWithHttpMessagesAsync(vaultName, resourceGroupName, fabricName, containerName, protectedItemName, recoveryPointId, null, cancellationToken).ConfigureAwait(false))
154+
{
155+
return _result.Body;
156+
}
157+
}
158+
91159
/// <summary>
92160
/// Lists the backup copies for the backed up item.
93161
/// </summary>

src/RecoveryServices/RecoveryServices.Backup.CrossRegionRestore.Management.Sdk/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ payload-flattening-threshold: 2
2424
2525
###
2626
``` yaml
27-
commit: 0e20dd2e4e2a40e83840c30cce2efc4847fd9cb9
27+
commit: 1f9b94d9f01369d1438a80aaf6a658e27209c594
2828
input-file:
2929
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2021-11-15/bms.json
3030

0 commit comments

Comments
 (0)