Skip to content

Commit 41a7c38

Browse files
authored
[Az.RecoveryServices.Backup] Added support for Private Endpoints and Immutable Vaults (#20741)
* Added support for enable/disable Public Network Access and PrivateEndpoints Added support for Immutable Vaults Added support for RetainRecoveryPointsAsPerPolicy in Disable-AzRecoveryServicesBackupProtection cmdlet. Now user can suspend backups and retain RPs as per policy Added List RP expiry time Added RecoveryServices, RecoveryServices.Backup, RecoveryServices.Backup.CrossRegionRestore management SDK Added changeLog * re-recorded failed tests Updated help files * re-record failed tests * added new tests and examples * resolved review comments
1 parent 71cf922 commit 41a7c38

File tree

1,005 files changed

+397733
-287279
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,005 files changed

+397733
-287279
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
// <auto-generated>
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT License. See License.txt in the project root for
4+
// license information.
5+
//
6+
// Code generated by Microsoft (R) AutoRest Code Generator.
7+
// Changes may cause incorrect behavior and will be lost if the code is
8+
// regenerated.
9+
// </auto-generated>
10+
11+
namespace Microsoft.Azure.Management.RecoveryServices.Backup.CrossRegionRestore
12+
{
13+
using Microsoft.Rest;
14+
using Microsoft.Rest.Azure;
15+
using Microsoft.Rest.Azure.OData;
16+
using Models;
17+
using Newtonsoft.Json;
18+
using System.Collections;
19+
using System.Collections.Generic;
20+
using System.Linq;
21+
using System.Net;
22+
using System.Net.Http;
23+
using System.Threading;
24+
using System.Threading.Tasks;
25+
26+
/// <summary>
27+
/// AadPropertiesOperations operations.
28+
/// </summary>
29+
internal partial class AadPropertiesOperations : IServiceOperations<RecoveryServicesBackupClient>, IAadPropertiesOperations
30+
{
31+
/// <summary>
32+
/// Initializes a new instance of the AadPropertiesOperations class.
33+
/// </summary>
34+
/// <param name='client'>
35+
/// Reference to the service client.
36+
/// </param>
37+
/// <exception cref="System.ArgumentNullException">
38+
/// Thrown when a required parameter is null
39+
/// </exception>
40+
internal AadPropertiesOperations(RecoveryServicesBackupClient client)
41+
{
42+
if (client == null)
43+
{
44+
throw new System.ArgumentNullException("client");
45+
}
46+
Client = client;
47+
}
48+
49+
/// <summary>
50+
/// Gets a reference to the RecoveryServicesBackupClient
51+
/// </summary>
52+
public RecoveryServicesBackupClient Client { get; private set; }
53+
54+
/// <summary>
55+
/// Fetches the AAD properties from target region BCM stamp.
56+
/// </summary>
57+
/// <param name='azureRegion'>
58+
/// Azure region to hit Api
59+
/// </param>
60+
/// <param name='odataQuery'>
61+
/// OData parameters to apply to the operation.
62+
/// </param>
63+
/// <param name='customHeaders'>
64+
/// Headers that will be added to request.
65+
/// </param>
66+
/// <param name='cancellationToken'>
67+
/// The cancellation token.
68+
/// </param>
69+
/// <exception cref="NewErrorResponseException">
70+
/// Thrown when the operation returned an invalid status code
71+
/// </exception>
72+
/// <exception cref="SerializationException">
73+
/// Thrown when unable to deserialize the response
74+
/// </exception>
75+
/// <exception cref="ValidationException">
76+
/// Thrown when a required parameter is null
77+
/// </exception>
78+
/// <exception cref="System.ArgumentNullException">
79+
/// Thrown when a required parameter is null
80+
/// </exception>
81+
/// <return>
82+
/// A response object containing the response body and response headers.
83+
/// </return>
84+
public async Task<AzureOperationResponse<AADPropertiesResource>> GetWithHttpMessagesAsync(string azureRegion, ODataQuery<BMSAADPropertiesQueryObject> odataQuery = default(ODataQuery<BMSAADPropertiesQueryObject>), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
85+
{
86+
if (Client.ApiVersion == null)
87+
{
88+
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
89+
}
90+
if (azureRegion == null)
91+
{
92+
throw new ValidationException(ValidationRules.CannotBeNull, "azureRegion");
93+
}
94+
if (Client.SubscriptionId == null)
95+
{
96+
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
97+
}
98+
// Tracing
99+
bool _shouldTrace = ServiceClientTracing.IsEnabled;
100+
string _invocationId = null;
101+
if (_shouldTrace)
102+
{
103+
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
104+
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
105+
tracingParameters.Add("odataQuery", odataQuery);
106+
tracingParameters.Add("azureRegion", azureRegion);
107+
tracingParameters.Add("cancellationToken", cancellationToken);
108+
ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
109+
}
110+
// Construct URL
111+
var _baseUrl = Client.BaseUri.AbsoluteUri;
112+
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.RecoveryServices/locations/{azureRegion}/backupAadProperties").ToString();
113+
_url = _url.Replace("{azureRegion}", System.Uri.EscapeDataString(azureRegion));
114+
_url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
115+
List<string> _queryParameters = new List<string>();
116+
if (odataQuery != null)
117+
{
118+
var _odataFilter = odataQuery.ToString();
119+
if (!string.IsNullOrEmpty(_odataFilter))
120+
{
121+
_queryParameters.Add(_odataFilter);
122+
}
123+
}
124+
if (Client.ApiVersion != null)
125+
{
126+
_queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
127+
}
128+
if (_queryParameters.Count > 0)
129+
{
130+
_url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
131+
}
132+
// Create HTTP transport objects
133+
var _httpRequest = new HttpRequestMessage();
134+
HttpResponseMessage _httpResponse = null;
135+
_httpRequest.Method = new HttpMethod("GET");
136+
_httpRequest.RequestUri = new System.Uri(_url);
137+
// Set Headers
138+
if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
139+
{
140+
_httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
141+
}
142+
if (Client.AcceptLanguage != null)
143+
{
144+
if (_httpRequest.Headers.Contains("accept-language"))
145+
{
146+
_httpRequest.Headers.Remove("accept-language");
147+
}
148+
_httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
149+
}
150+
151+
152+
if (customHeaders != null)
153+
{
154+
foreach(var _header in customHeaders)
155+
{
156+
if (_httpRequest.Headers.Contains(_header.Key))
157+
{
158+
_httpRequest.Headers.Remove(_header.Key);
159+
}
160+
_httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
161+
}
162+
}
163+
164+
// Serialize Request
165+
string _requestContent = null;
166+
// Set Credentials
167+
if (Client.Credentials != null)
168+
{
169+
cancellationToken.ThrowIfCancellationRequested();
170+
await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
171+
}
172+
// Send Request
173+
if (_shouldTrace)
174+
{
175+
ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
176+
}
177+
cancellationToken.ThrowIfCancellationRequested();
178+
_httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
179+
if (_shouldTrace)
180+
{
181+
ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
182+
}
183+
HttpStatusCode _statusCode = _httpResponse.StatusCode;
184+
cancellationToken.ThrowIfCancellationRequested();
185+
string _responseContent = null;
186+
if ((int)_statusCode != 200)
187+
{
188+
var ex = new NewErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
189+
try
190+
{
191+
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
192+
NewErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<NewErrorResponse>(_responseContent, Client.DeserializationSettings);
193+
if (_errorBody != null)
194+
{
195+
ex.Body = _errorBody;
196+
}
197+
}
198+
catch (JsonException)
199+
{
200+
// Ignore the exception
201+
}
202+
ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
203+
ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
204+
if (_shouldTrace)
205+
{
206+
ServiceClientTracing.Error(_invocationId, ex);
207+
}
208+
_httpRequest.Dispose();
209+
if (_httpResponse != null)
210+
{
211+
_httpResponse.Dispose();
212+
}
213+
throw ex;
214+
}
215+
// Create Result
216+
var _result = new AzureOperationResponse<AADPropertiesResource>();
217+
_result.Request = _httpRequest;
218+
_result.Response = _httpResponse;
219+
if (_httpResponse.Headers.Contains("x-ms-request-id"))
220+
{
221+
_result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
222+
}
223+
// Deserialize Response
224+
if ((int)_statusCode == 200)
225+
{
226+
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
227+
try
228+
{
229+
_result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<AADPropertiesResource>(_responseContent, Client.DeserializationSettings);
230+
}
231+
catch (JsonException ex)
232+
{
233+
_httpRequest.Dispose();
234+
if (_httpResponse != null)
235+
{
236+
_httpResponse.Dispose();
237+
}
238+
throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
239+
}
240+
}
241+
if (_shouldTrace)
242+
{
243+
ServiceClientTracing.Exit(_invocationId, _result);
244+
}
245+
return _result;
246+
}
247+
248+
}
249+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// <auto-generated>
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT License. See License.txt in the project root for
4+
// license information.
5+
//
6+
// Code generated by Microsoft (R) AutoRest Code Generator.
7+
// Changes may cause incorrect behavior and will be lost if the code is
8+
// regenerated.
9+
// </auto-generated>
10+
11+
namespace Microsoft.Azure.Management.RecoveryServices.Backup.CrossRegionRestore
12+
{
13+
using Microsoft.Rest;
14+
using Microsoft.Rest.Azure;
15+
using Microsoft.Rest.Azure.OData;
16+
using Models;
17+
using System.Threading;
18+
using System.Threading.Tasks;
19+
20+
/// <summary>
21+
/// Extension methods for AadPropertiesOperations.
22+
/// </summary>
23+
public static partial class AadPropertiesOperationsExtensions
24+
{
25+
/// <summary>
26+
/// Fetches the AAD properties from target region BCM stamp.
27+
/// </summary>
28+
/// <param name='operations'>
29+
/// The operations group for this extension method.
30+
/// </param>
31+
/// <param name='azureRegion'>
32+
/// Azure region to hit Api
33+
/// </param>
34+
/// <param name='odataQuery'>
35+
/// OData parameters to apply to the operation.
36+
/// </param>
37+
public static AADPropertiesResource Get(this IAadPropertiesOperations operations, string azureRegion, ODataQuery<BMSAADPropertiesQueryObject> odataQuery = default(ODataQuery<BMSAADPropertiesQueryObject>))
38+
{
39+
return operations.GetAsync(azureRegion, odataQuery).GetAwaiter().GetResult();
40+
}
41+
42+
/// <summary>
43+
/// Fetches the AAD properties from target region BCM stamp.
44+
/// </summary>
45+
/// <param name='operations'>
46+
/// The operations group for this extension method.
47+
/// </param>
48+
/// <param name='azureRegion'>
49+
/// Azure region to hit Api
50+
/// </param>
51+
/// <param name='odataQuery'>
52+
/// OData parameters to apply to the operation.
53+
/// </param>
54+
/// <param name='cancellationToken'>
55+
/// The cancellation token.
56+
/// </param>
57+
public static async Task<AADPropertiesResource> GetAsync(this IAadPropertiesOperations operations, string azureRegion, ODataQuery<BMSAADPropertiesQueryObject> odataQuery = default(ODataQuery<BMSAADPropertiesQueryObject>), CancellationToken cancellationToken = default(CancellationToken))
58+
{
59+
using (var _result = await operations.GetWithHttpMessagesAsync(azureRegion, odataQuery, null, cancellationToken).ConfigureAwait(false))
60+
{
61+
return _result.Body;
62+
}
63+
}
64+
65+
}
66+
}

0 commit comments

Comments
 (0)