From 5d6c78ed3d148ea256b613565bf72e886ee1f62e Mon Sep 17 00:00:00 2001 From: dragonfly91 Date: Wed, 10 Jun 2015 16:02:25 +0530 Subject: [PATCH 1/2] Fixes for build break --- .../BackupServicesManagment.csproj | 2 + .../Generated/BackUpOperations.cs | 15 +- .../Generated/ContainerOperation.cs | 33 +- .../Generated/IProtectionPolicyOperations.cs | 55 ++ .../Generated/ProtectionPolicyOperations.cs | 633 ++++++++++++++++++ .../ProtectionPolicyOperationsExtensions.cs | 144 ++++ 6 files changed, 840 insertions(+), 42 deletions(-) diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj b/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj index c38051d1df88..1e2a4b23289a 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj @@ -33,6 +33,7 @@ + @@ -67,6 +68,7 @@ + diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperations.cs index bd068a4d8d3b..8891000ff7b5 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperations.cs @@ -179,7 +179,7 @@ public async Task TriggerBackUpAsync(CustomRequestHeaders cus TracingAdapter.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; - if (statusCode != HttpStatusCode.OK) + if (statusCode != HttpStatusCode.Accepted) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); @@ -193,7 +193,7 @@ public async Task TriggerBackUpAsync(CustomRequestHeaders cus // Create Result OperationResponse result = null; // Deserialize Response - if (statusCode == HttpStatusCode.OK) + if (statusCode == HttpStatusCode.Accepted) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); @@ -204,17 +204,8 @@ public async Task TriggerBackUpAsync(CustomRequestHeaders cus responseDoc = JToken.Parse(responseContent); } - JToken operationResponseValue = responseDoc["OperationResponse"]; - if (operationResponseValue != null && operationResponseValue.Type != JTokenType.Null) + if (responseDoc != null && responseDoc.Type != JTokenType.Null) { - OperationResponse operationResponseInstance = new OperationResponse(); - - JToken operationIdValue = operationResponseValue["OperationId"]; - if (operationIdValue != null && operationIdValue.Type != JTokenType.Null) - { - Guid operationIdInstance = Guid.Parse(((string)operationIdValue)); - operationResponseInstance.OperationId = operationIdInstance; - } } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ContainerOperation.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ContainerOperation.cs index a5cf38a6928a..d1381fc378bc 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ContainerOperation.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ContainerOperation.cs @@ -444,17 +444,8 @@ public async Task RefreshAsync(CustomRequestHeaders customReq responseDoc = JToken.Parse(responseContent); } - JToken operationResponseValue = responseDoc["OperationResponse"]; - if (operationResponseValue != null && operationResponseValue.Type != JTokenType.Null) + if (responseDoc != null && responseDoc.Type != JTokenType.Null) { - OperationResponse operationResponseInstance = new OperationResponse(); - - JToken operationIdValue = operationResponseValue["OperationId"]; - if (operationIdValue != null && operationIdValue.Type != JTokenType.Null) - { - Guid operationIdInstance = Guid.Parse(((string)operationIdValue)); - operationResponseInstance.OperationId = operationIdInstance; - } } } @@ -647,17 +638,8 @@ public async Task RegisterAsync(RegisterContainerRequest para responseDoc = JToken.Parse(responseContent); } - JToken operationResponseValue = responseDoc["OperationResponse"]; - if (operationResponseValue != null && operationResponseValue.Type != JTokenType.Null) + if (responseDoc != null && responseDoc.Type != JTokenType.Null) { - OperationResponse operationResponseInstance = new OperationResponse(); - - JToken operationIdValue = operationResponseValue["OperationId"]; - if (operationIdValue != null && operationIdValue.Type != JTokenType.Null) - { - Guid operationIdInstance = Guid.Parse(((string)operationIdValue)); - operationResponseInstance.OperationId = operationIdInstance; - } } } @@ -842,17 +824,8 @@ public async Task UnregisterAsync(UnregisterContainerRequest responseDoc = JToken.Parse(responseContent); } - JToken operationResponseValue = responseDoc["OperationResponse"]; - if (operationResponseValue != null && operationResponseValue.Type != JTokenType.Null) + if (responseDoc != null && responseDoc.Type != JTokenType.Null) { - OperationResponse operationResponseInstance = new OperationResponse(); - - JToken operationIdValue = operationResponseValue["OperationId"]; - if (operationIdValue != null && operationIdValue.Type != JTokenType.Null) - { - Guid operationIdInstance = Guid.Parse(((string)operationIdValue)); - operationResponseInstance.OperationId = operationIdInstance; - } } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IProtectionPolicyOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IProtectionPolicyOperations.cs index 9a0ed4555713..4d86e5cdc12b 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IProtectionPolicyOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IProtectionPolicyOperations.cs @@ -23,6 +23,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using Microsoft.Azure.Management.BackupServices; using Microsoft.Azure.Management.BackupServices.Models; namespace Microsoft.Azure.Management.BackupServices @@ -33,6 +34,40 @@ namespace Microsoft.Azure.Management.BackupServices /// public partial interface IProtectionPolicyOperations { + /// + /// Create new Protection Policy. + /// + /// + /// The protection policy creation request. + /// + /// + /// Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + Task AddAsync(AddProtectionPolicyRequest addProtectionPolicyRequest, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); + + /// + /// Create new Protection Policy. + /// + /// + /// The protection policy ID to be deleted. + /// + /// + /// Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + Task DeleteAsync(string protectionPolicyId, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); + /// /// Get the list of all Protection Policy. /// @@ -63,5 +98,25 @@ public partial interface IProtectionPolicyOperations /// The response model for the list ProtectionPolicies operation. /// Task ListAsync(CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); + + /// + /// Update Protection Policy. + /// + /// + /// The protection policy ID to be updated. + /// + /// + /// The protection policy creation request. + /// + /// + /// Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + Task UpdateAsync(string protectionPolicyId, UpdateProtectionPolicyRequest updateProtectionPolicyRequest, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs index 52406d5b3fad..b4e26a77cbce 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs @@ -25,6 +25,8 @@ using System.Linq; using System.Net; using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; using System.Threading; using System.Threading.Tasks; using Hyak.Common; @@ -62,6 +64,398 @@ public BackupServicesManagementClient Client get { return this._client; } } + /// + /// Create new Protection Policy. + /// + /// + /// Required. The protection policy creation request. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + public async Task AddAsync(AddProtectionPolicyRequest addProtectionPolicyRequest, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) + { + // Validate + if (addProtectionPolicyRequest == null) + { + throw new ArgumentNullException("addProtectionPolicyRequest"); + } + if (addProtectionPolicyRequest.Schedule != null) + { + if (addProtectionPolicyRequest.Schedule.BackupType == null) + { + throw new ArgumentNullException("addProtectionPolicyRequest.Schedule.BackupType"); + } + if (addProtectionPolicyRequest.Schedule.RetentionPolicy == null) + { + throw new ArgumentNullException("addProtectionPolicyRequest.Schedule.RetentionPolicy"); + } + if (addProtectionPolicyRequest.Schedule.ScheduleRun == null) + { + throw new ArgumentNullException("addProtectionPolicyRequest.Schedule.ScheduleRun"); + } + if (addProtectionPolicyRequest.Schedule.ScheduleRunTimes == null) + { + throw new ArgumentNullException("addProtectionPolicyRequest.Schedule.ScheduleRunTimes"); + } + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("addProtectionPolicyRequest", addProtectionPolicyRequest); + tracingParameters.Add("customRequestHeaders", customRequestHeaders); + TracingAdapter.Enter(invocationId, this, "AddAsync", 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.Backupseadev01"; + url = url + "/"; + url = url + "BackupVault"; + url = url + "/"; + url = url + Uri.EscapeDataString(this.Client.ResourceName); + url = url + "/protectionpolicies"; + 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.Post; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + httpRequest.Headers.Add("Accept-Language", "en-us"); + httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Serialize Request + string requestContent = null; + JToken requestDoc = null; + + JObject addProtectionPolicyRequestValue = new JObject(); + requestDoc = addProtectionPolicyRequestValue; + + if (addProtectionPolicyRequest.WorkloadType != null) + { + addProtectionPolicyRequestValue["workloadtype"] = addProtectionPolicyRequest.WorkloadType; + } + + if (addProtectionPolicyRequest.PolicyName != null) + { + addProtectionPolicyRequestValue["policyname"] = addProtectionPolicyRequest.PolicyName; + } + + if (addProtectionPolicyRequest.Schedule != null) + { + JObject scheduleValue = new JObject(); + addProtectionPolicyRequestValue["schedule"] = scheduleValue; + + scheduleValue["BackupType"] = addProtectionPolicyRequest.Schedule.BackupType; + + scheduleValue["ScheduleRun"] = addProtectionPolicyRequest.Schedule.ScheduleRun; + + scheduleValue["ScheduleStartTime"] = addProtectionPolicyRequest.Schedule.ScheduleStartTime; + + if (addProtectionPolicyRequest.Schedule.ScheduleRunDays != null) + { + JArray scheduleRunDaysArray = new JArray(); + foreach (DayOfWeek scheduleRunDaysItem in addProtectionPolicyRequest.Schedule.ScheduleRunDays) + { + scheduleRunDaysArray.Add(scheduleRunDaysItem.ToString()); + } + scheduleValue["ScheduleRunDays"] = scheduleRunDaysArray; + } + + if (addProtectionPolicyRequest.Schedule.ScheduleRunTimes != null) + { + JArray scheduleRunTimesArray = new JArray(); + foreach (DateTime scheduleRunTimesItem in addProtectionPolicyRequest.Schedule.ScheduleRunTimes) + { + scheduleRunTimesArray.Add(scheduleRunTimesItem); + } + scheduleValue["ScheduleRunTimes"] = scheduleRunTimesArray; + } + + JObject retentionPolicyValue = new JObject(); + scheduleValue["RetentionPolicy"] = retentionPolicyValue; + + retentionPolicyValue["RetentionType"] = addProtectionPolicyRequest.Schedule.RetentionPolicy.RetentionType.ToString(); + + retentionPolicyValue["Schedule"] = addProtectionPolicyRequest.Schedule.RetentionPolicy.RetentionDuration; + } + + requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented); + httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); + + // 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 && statusCode != HttpStatusCode.Accepted) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + OperationResponse result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Accepted) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new OperationResponse(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + } + + } + result.StatusCode = statusCode; + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Create new Protection Policy. + /// + /// + /// Required. The protection policy ID to be deleted. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + public async Task DeleteAsync(string protectionPolicyId, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) + { + // Validate + if (protectionPolicyId == null) + { + throw new ArgumentNullException("protectionPolicyId"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("protectionPolicyId", protectionPolicyId); + tracingParameters.Add("customRequestHeaders", customRequestHeaders); + TracingAdapter.Enter(invocationId, this, "DeleteAsync", 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.Backupseadev01"; + url = url + "/"; + url = url + "BackupVault"; + url = url + "/"; + url = url + Uri.EscapeDataString(this.Client.ResourceName); + url = url + "/protectionpolicies/"; + url = url + Uri.EscapeDataString(protectionPolicyId); + 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"); + httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); + + // 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 + OperationResponse result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new OperationResponse(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + } + + } + result.StatusCode = statusCode; + + 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 Protection Policy. /// @@ -644,5 +1038,244 @@ public async Task ListAsync(CustomRequestHeaders c } } } + + /// + /// Update Protection Policy. + /// + /// + /// Required. The protection policy ID to be updated. + /// + /// + /// Required. The protection policy creation request. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + public async Task UpdateAsync(string protectionPolicyId, UpdateProtectionPolicyRequest updateProtectionPolicyRequest, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) + { + // Validate + if (protectionPolicyId == null) + { + throw new ArgumentNullException("protectionPolicyId"); + } + if (updateProtectionPolicyRequest == null) + { + throw new ArgumentNullException("updateProtectionPolicyRequest"); + } + if (updateProtectionPolicyRequest.Schedule != null) + { + if (updateProtectionPolicyRequest.Schedule.BackupType == null) + { + throw new ArgumentNullException("updateProtectionPolicyRequest.Schedule.BackupType"); + } + if (updateProtectionPolicyRequest.Schedule.RetentionPolicy == null) + { + throw new ArgumentNullException("updateProtectionPolicyRequest.Schedule.RetentionPolicy"); + } + if (updateProtectionPolicyRequest.Schedule.ScheduleRun == null) + { + throw new ArgumentNullException("updateProtectionPolicyRequest.Schedule.ScheduleRun"); + } + if (updateProtectionPolicyRequest.Schedule.ScheduleRunTimes == null) + { + throw new ArgumentNullException("updateProtectionPolicyRequest.Schedule.ScheduleRunTimes"); + } + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("protectionPolicyId", protectionPolicyId); + tracingParameters.Add("updateProtectionPolicyRequest", updateProtectionPolicyRequest); + tracingParameters.Add("customRequestHeaders", customRequestHeaders); + TracingAdapter.Enter(invocationId, this, "UpdateAsync", 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.Backupseadev01"; + url = url + "/"; + url = url + "BackupVault"; + url = url + "/"; + url = url + Uri.EscapeDataString(this.Client.ResourceName); + url = url + "/protectionpolicies/"; + url = url + Uri.EscapeDataString(protectionPolicyId); + 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.Post; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + httpRequest.Headers.Add("Accept-Language", "en-us"); + httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Serialize Request + string requestContent = null; + JToken requestDoc = null; + + JObject updateProtectionPolicyRequestValue = new JObject(); + requestDoc = updateProtectionPolicyRequestValue; + + if (updateProtectionPolicyRequest.PolicyName != null) + { + updateProtectionPolicyRequestValue["policyname"] = updateProtectionPolicyRequest.PolicyName; + } + + if (updateProtectionPolicyRequest.Schedule != null) + { + JObject scheduleValue = new JObject(); + updateProtectionPolicyRequestValue["schedule"] = scheduleValue; + + scheduleValue["BackupType"] = updateProtectionPolicyRequest.Schedule.BackupType; + + scheduleValue["ScheduleRun"] = updateProtectionPolicyRequest.Schedule.ScheduleRun; + + scheduleValue["ScheduleStartTime"] = updateProtectionPolicyRequest.Schedule.ScheduleStartTime; + + if (updateProtectionPolicyRequest.Schedule.ScheduleRunDays != null) + { + JArray scheduleRunDaysArray = new JArray(); + foreach (DayOfWeek scheduleRunDaysItem in updateProtectionPolicyRequest.Schedule.ScheduleRunDays) + { + scheduleRunDaysArray.Add(scheduleRunDaysItem.ToString()); + } + scheduleValue["ScheduleRunDays"] = scheduleRunDaysArray; + } + + if (updateProtectionPolicyRequest.Schedule.ScheduleRunTimes != null) + { + JArray scheduleRunTimesArray = new JArray(); + foreach (DateTime scheduleRunTimesItem in updateProtectionPolicyRequest.Schedule.ScheduleRunTimes) + { + scheduleRunTimesArray.Add(scheduleRunTimesItem); + } + scheduleValue["ScheduleRunTimes"] = scheduleRunTimesArray; + } + + JObject retentionPolicyValue = new JObject(); + scheduleValue["RetentionPolicy"] = retentionPolicyValue; + + retentionPolicyValue["RetentionType"] = updateProtectionPolicyRequest.Schedule.RetentionPolicy.RetentionType.ToString(); + + retentionPolicyValue["Schedule"] = updateProtectionPolicyRequest.Schedule.RetentionPolicy.RetentionDuration; + } + + requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented); + httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); + + // 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 && statusCode != HttpStatusCode.Accepted) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + OperationResponse result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Accepted) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new OperationResponse(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + } + + } + result.StatusCode = statusCode; + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperationsExtensions.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperationsExtensions.cs index 68adeb646b00..8fe376fe5bff 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperationsExtensions.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperationsExtensions.cs @@ -30,6 +30,98 @@ namespace Microsoft.Azure.Management.BackupServices { public static partial class ProtectionPolicyOperationsExtensions { + /// + /// Create new Protection Policy. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IProtectionPolicyOperations. + /// + /// + /// Required. The protection policy creation request. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a Operation Response. + /// + public static OperationResponse Add(this IProtectionPolicyOperations operations, AddProtectionPolicyRequest addProtectionPolicyRequest, CustomRequestHeaders customRequestHeaders) + { + return Task.Factory.StartNew((object s) => + { + return ((IProtectionPolicyOperations)s).AddAsync(addProtectionPolicyRequest, customRequestHeaders); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Create new Protection Policy. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IProtectionPolicyOperations. + /// + /// + /// Required. The protection policy creation request. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a Operation Response. + /// + public static Task AddAsync(this IProtectionPolicyOperations operations, AddProtectionPolicyRequest addProtectionPolicyRequest, CustomRequestHeaders customRequestHeaders) + { + return operations.AddAsync(addProtectionPolicyRequest, customRequestHeaders, CancellationToken.None); + } + + /// + /// Create new Protection Policy. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IProtectionPolicyOperations. + /// + /// + /// Required. The protection policy ID to be deleted. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a Operation Response. + /// + public static OperationResponse Delete(this IProtectionPolicyOperations operations, string protectionPolicyId, CustomRequestHeaders customRequestHeaders) + { + return Task.Factory.StartNew((object s) => + { + return ((IProtectionPolicyOperations)s).DeleteAsync(protectionPolicyId, customRequestHeaders); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Create new Protection Policy. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IProtectionPolicyOperations. + /// + /// + /// Required. The protection policy ID to be deleted. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a Operation Response. + /// + public static Task DeleteAsync(this IProtectionPolicyOperations operations, string protectionPolicyId, CustomRequestHeaders customRequestHeaders) + { + return operations.DeleteAsync(protectionPolicyId, customRequestHeaders, CancellationToken.None); + } + /// /// Get the list of all Protection Policy. /// @@ -115,5 +207,57 @@ public static Task ListAsync(this IProtectionPolic { return operations.ListAsync(customRequestHeaders, CancellationToken.None); } + + /// + /// Update Protection Policy. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IProtectionPolicyOperations. + /// + /// + /// Required. The protection policy ID to be updated. + /// + /// + /// Required. The protection policy creation request. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a Operation Response. + /// + public static OperationResponse Update(this IProtectionPolicyOperations operations, string protectionPolicyId, UpdateProtectionPolicyRequest updateProtectionPolicyRequest, CustomRequestHeaders customRequestHeaders) + { + return Task.Factory.StartNew((object s) => + { + return ((IProtectionPolicyOperations)s).UpdateAsync(protectionPolicyId, updateProtectionPolicyRequest, customRequestHeaders); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Update Protection Policy. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IProtectionPolicyOperations. + /// + /// + /// Required. The protection policy ID to be updated. + /// + /// + /// Required. The protection policy creation request. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a Operation Response. + /// + public static Task UpdateAsync(this IProtectionPolicyOperations operations, string protectionPolicyId, UpdateProtectionPolicyRequest updateProtectionPolicyRequest, CustomRequestHeaders customRequestHeaders) + { + return operations.UpdateAsync(protectionPolicyId, updateProtectionPolicyRequest, customRequestHeaders, CancellationToken.None); + } } } From 536e4ad58e7a63d5ee77a9ed5f464e5c6bbb2675 Mon Sep 17 00:00:00 2001 From: dragonfly91 Date: Wed, 10 Jun 2015 16:04:51 +0530 Subject: [PATCH 2/2] Fixes for build break part 2 --- .../Models/AddProtectionPolicyRequest.cs | 73 +++++++++++++++++++ .../Models/DataSourceQueryParameter.cs | 61 ++++++++++++++++ .../Generated/Models/POQueryParameter.cs | 50 +++++++++++++ .../Models/UpdateProtectionPolicyRequest.cs | 63 ++++++++++++++++ 4 files changed, 247 insertions(+) create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/AddProtectionPolicyRequest.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/DataSourceQueryParameter.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/POQueryParameter.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/UpdateProtectionPolicyRequest.cs diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/AddProtectionPolicyRequest.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/AddProtectionPolicyRequest.cs new file mode 100644 index 000000000000..71cc652a5d82 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/AddProtectionPolicyRequest.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices.Models +{ + /// + /// The definition of a Management List Response. + /// + public partial class AddProtectionPolicyRequest : ManagementBaseObject + { + private string _policyName; + + /// + /// Optional. Protection policy name. + /// + public string PolicyName + { + get { return this._policyName; } + set { this._policyName = value; } + } + + private BackupSchedule _schedule; + + /// + /// Optional. Schedule of ProtectionPolicy. + /// + public BackupSchedule Schedule + { + get { return this._schedule; } + set { this._schedule = value; } + } + + private string _workloadType; + + /// + /// Optional. WorkloadType of protection policy. + /// + public string WorkloadType + { + get { return this._workloadType; } + set { this._workloadType = value; } + } + + /// + /// Initializes a new instance of the AddProtectionPolicyRequest class. + /// + public AddProtectionPolicyRequest() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/DataSourceQueryParameter.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/DataSourceQueryParameter.cs new file mode 100644 index 000000000000..e1cc98a491a5 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/DataSourceQueryParameter.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; + +namespace Microsoft.Azure.Management.BackupServices.Models +{ + /// + /// The definition of a DataSourceQueryParameter object. + /// + public partial class DataSourceQueryParameter + { + private string _containerName; + + /// + /// Optional. ContainerName of item. + /// + public string ContainerName + { + get { return this._containerName; } + set { this._containerName = value; } + } + + private string _protectionStatus; + + /// + /// Optional. Protection Status of item. + /// + public string ProtectionStatus + { + get { return this._protectionStatus; } + set { this._protectionStatus = value; } + } + + /// + /// Initializes a new instance of the DataSourceQueryParameter class. + /// + public DataSourceQueryParameter() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/POQueryParameter.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/POQueryParameter.cs new file mode 100644 index 000000000000..42d85b45ea68 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/POQueryParameter.cs @@ -0,0 +1,50 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; + +namespace Microsoft.Azure.Management.BackupServices.Models +{ + /// + /// The definition of a POQueryParameter object. + /// + public partial class POQueryParameter + { + private string _status; + + /// + /// Optional. Status Status of item. + /// + public string Status + { + get { return this._status; } + set { this._status = value; } + } + + /// + /// Initializes a new instance of the POQueryParameter class. + /// + public POQueryParameter() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/UpdateProtectionPolicyRequest.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/UpdateProtectionPolicyRequest.cs new file mode 100644 index 000000000000..1a1dc0517751 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/UpdateProtectionPolicyRequest.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices.Models +{ + /// + /// The definition of a Management List Response. + /// + public partial class UpdateProtectionPolicyRequest : ManagementBaseObject + { + private string _policyName; + + /// + /// Optional. Protection policy name + /// + public string PolicyName + { + get { return this._policyName; } + set { this._policyName = value; } + } + + private BackupSchedule _schedule; + + /// + /// Optional. Schedule of ProtectionPolicy. + /// + public BackupSchedule Schedule + { + get { return this._schedule; } + set { this._schedule = value; } + } + + /// + /// Initializes a new instance of the UpdateProtectionPolicyRequest + /// class. + /// + public UpdateProtectionPolicyRequest() + { + } + } +}