diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/BackupServicesManagement.csproj b/src/ResourceManagement/AzureBackup/BackupServicesManagement/BackupServicesManagement.csproj index 0153c05eb315..d64426eb8b23 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/BackupServicesManagement.csproj +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/BackupServicesManagement.csproj @@ -77,6 +77,7 @@ + diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IRecoveryPointOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IRecoveryPointOperations.cs index ed7c20917150..07e2631f67c6 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IRecoveryPointOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IRecoveryPointOperations.cs @@ -33,8 +33,21 @@ namespace Microsoft.Azure.Management.BackupServices public partial interface IRecoveryPointOperations { /// - /// Get the list of all container based on the given query filter - /// string. + /// Get the recovery point. + /// + /// + /// Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a CSMRecoveryPointOperationResponse. + /// + Task GetAsync(CustomRequestHeaders customRequestHeaders, string containerName, string itemName, string recoveryPointName, CancellationToken cancellationToken); + + /// + /// Get the list of all recovery points. /// /// /// Request header parameters. diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/RecoveryPointOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/RecoveryPointOperations.cs index 2507b13168d7..9bc2064bb948 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/RecoveryPointOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/RecoveryPointOperations.cs @@ -61,8 +61,239 @@ public BackupServicesManagementClient Client } /// - /// Get the list of all container based on the given query filter - /// string. + /// Get the recovery point. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a CSMRecoveryPointOperationResponse. + /// + public async Task GetAsync(CustomRequestHeaders customRequestHeaders, string containerName, string itemName, string recoveryPointName, CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("customRequestHeaders", customRequestHeaders); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("itemName", itemName); + tracingParameters.Add("recoveryPointName", recoveryPointName); + TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/Subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourceGroups/"; + url = url + Uri.EscapeDataString(this.Client.ResourceGroupName); + url = url + "/providers/"; + url = url + "Microsoft.Backup"; + url = url + "/"; + url = url + "BackupVault"; + url = url + "/"; + url = url + Uri.EscapeDataString(this.Client.ResourceName); + url = url + "/registeredContainers/"; + if (containerName != null) + { + url = url + Uri.EscapeDataString(containerName); + } + url = url + "/protectedItems/"; + if (itemName != null) + { + url = url + Uri.EscapeDataString(itemName); + } + url = url + "/recoveryPoints/"; + if (recoveryPointName != null) + { + url = url + Uri.EscapeDataString(recoveryPointName); + } + List queryParameters = new List(); + queryParameters.Add("api-version=2014-09-01"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + httpRequest.Headers.Add("Accept-Language", "en-us"); + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + CSMRecoveryPointOperationResponse result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new CSMRecoveryPointOperationResponse(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken cSMRecoveryPointResponseValue = responseDoc["CSMRecoveryPointResponse"]; + if (cSMRecoveryPointResponseValue != null && cSMRecoveryPointResponseValue.Type != JTokenType.Null) + { + CSMRecoveryPointResponse cSMRecoveryPointResponseInstance = new CSMRecoveryPointResponse(); + result.Value = cSMRecoveryPointResponseInstance; + + JToken propertiesValue = cSMRecoveryPointResponseValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + CSMRecoveryPointProperties propertiesInstance = new CSMRecoveryPointProperties(); + cSMRecoveryPointResponseInstance.Properties = propertiesInstance; + + JToken recoveryPointTypeValue = propertiesValue["recoveryPointType"]; + if (recoveryPointTypeValue != null && recoveryPointTypeValue.Type != JTokenType.Null) + { + string recoveryPointTypeInstance = ((string)recoveryPointTypeValue); + propertiesInstance.RecoveryPointType = recoveryPointTypeInstance; + } + + JToken recoveryPointTimeValue = propertiesValue["recoveryPointTime"]; + if (recoveryPointTimeValue != null && recoveryPointTimeValue.Type != JTokenType.Null) + { + DateTime recoveryPointTimeInstance = ((DateTime)recoveryPointTimeValue); + propertiesInstance.RecoveryPointTime = recoveryPointTimeInstance; + } + + JToken recoveryPointAdditionalInfoValue = propertiesValue["recoveryPointAdditionalInfo"]; + if (recoveryPointAdditionalInfoValue != null && recoveryPointAdditionalInfoValue.Type != JTokenType.Null) + { + string recoveryPointAdditionalInfoInstance = ((string)recoveryPointAdditionalInfoValue); + propertiesInstance.RecoveryPointAdditionalInfo = recoveryPointAdditionalInfoInstance; + } + } + + JToken idValue = cSMRecoveryPointResponseValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + cSMRecoveryPointResponseInstance.Id = idInstance; + } + + JToken nameValue = cSMRecoveryPointResponseValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + cSMRecoveryPointResponseInstance.Name = nameInstance; + } + + JToken typeValue = cSMRecoveryPointResponseValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + cSMRecoveryPointResponseInstance.Type = typeInstance; + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-client-request-id")) + { + customRequestHeaders.ClientRequestId = httpResponse.Headers.GetValues("x-ms-client-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Get the list of all recovery points. /// /// /// Optional. Request header parameters. diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/RecoveryPointOperationsExtensions.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/RecoveryPointOperationsExtensions.cs index 8a0b5b1745b2..4833a374a314 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/RecoveryPointOperationsExtensions.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/RecoveryPointOperationsExtensions.cs @@ -31,8 +31,65 @@ namespace Microsoft.Azure.Management.BackupServices public static partial class RecoveryPointOperationsExtensions { /// - /// Get the list of all container based on the given query filter - /// string. + /// Get the recovery point. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IRecoveryPointOperations. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// The definition of a CSMRecoveryPointOperationResponse. + /// + public static CSMRecoveryPointOperationResponse Get(this IRecoveryPointOperations operations, CustomRequestHeaders customRequestHeaders, string containerName, string itemName, string recoveryPointName) + { + return Task.Factory.StartNew((object s) => + { + return ((IRecoveryPointOperations)s).GetAsync(customRequestHeaders, containerName, itemName, recoveryPointName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get the recovery point. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IRecoveryPointOperations. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// The definition of a CSMRecoveryPointOperationResponse. + /// + public static Task GetAsync(this IRecoveryPointOperations operations, CustomRequestHeaders customRequestHeaders, string containerName, string itemName, string recoveryPointName) + { + return operations.GetAsync(customRequestHeaders, containerName, itemName, recoveryPointName, CancellationToken.None); + } + + /// + /// Get the list of all recovery points. /// /// /// Reference to the @@ -60,8 +117,7 @@ public static CSMRecoveryPointListOperationResponse List(this IRecoveryPointOper } /// - /// Get the list of all container based on the given query filter - /// string. + /// Get the list of all recovery points. /// /// /// Reference to the