diff --git a/src/ResourceManagement/AzureBackup/BackupServices.Tests/BackupServices.Tests.csproj b/src/ResourceManagement/AzureBackup/BackupServices.Tests/BackupServices.Tests.csproj index a2650a334cb04..882a2bdb959ae 100644 --- a/src/ResourceManagement/AzureBackup/BackupServices.Tests/BackupServices.Tests.csproj +++ b/src/ResourceManagement/AzureBackup/BackupServices.Tests/BackupServices.Tests.csproj @@ -9,15 +9,18 @@ - - + + Code + - + + Code + diff --git a/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/CSMAzureBackupItem.cs b/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/CSMAzureBackupItem.cs new file mode 100644 index 0000000000000..892e12288f6b1 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/CSMAzureBackupItem.cs @@ -0,0 +1,165 @@ +// +// Copyright (c) Microsoft. 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. +// + +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; +using Microsoft.Azure.Test; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace BackupServices.Tests +{ + public class CSMAzureBackupItem : BackupServicesTestsBase + { + [Fact] + public void EnableAzureBackupProtectionTest() + { + using (UndoContext context = UndoContext.Current) + { + var client = GetServiceClient(); + context.Start(); + CSMSetProtectionRequest input = new CSMSetProtectionRequest(); + input.Properties = new CSMSetProtectionRequestProperties(); + input.Properties.PolicyId = ConfigurationManager.AppSettings["PolicyId"]; + string itemName = ConfigurationManager.AppSettings["AzureBackupItemName"]; + string containerName = ConfigurationManager.AppSettings["ContainerName"]; + + var response = client.DataSource.EnableProtectionCSM(GetCustomRequestHeaders(), + containerName, + itemName, + input); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + } + } + + [Fact] + public void UpdateAzureBackupProtectionTest() + { + using (UndoContext context = UndoContext.Current) + { + var client = GetServiceClient(); + context.Start(); + + CSMUpdateProtectionRequest input = new CSMUpdateProtectionRequest(); + input.Properties = new CSMUpdateProtectionRequestProperties(); + string itemName = ConfigurationManager.AppSettings["AzureBackupItemName"]; + string containerName = ConfigurationManager.AppSettings["ContainerName"]; + input.Properties.PolicyId = string.Empty; + + var response = client.DataSource.UpdateProtectionCSM(GetCustomRequestHeaders(), + containerName, + itemName, + input); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + } + } + + [Fact] + public void DisableAzureBackupProtectionTest() + { + using (UndoContext context = UndoContext.Current) + { + var client = GetServiceClient(); + context.Start(); + + string itemName = ConfigurationManager.AppSettings["AzureBackupItemName"]; + string containerName = ConfigurationManager.AppSettings["ContainerName"]; + var response = client.DataSource.DisableProtectionCSM(GetCustomRequestHeaders(), + containerName, + itemName); + + Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); + } + } + + [Fact] + public void ListAzureBackupItemPOTest() + { + using (UndoContext context = UndoContext.Current) + { + context.Start(); + + CSMItemQueryObject POQueryParam = new CSMItemQueryObject() + { + Status = null, + Type = null + }; + + var client = GetServiceClient(); + + var response = client.ProtectableObject.ListCSMAsync(POQueryParam, GetCustomRequestHeaders()).Result; + + Assert.True(response.CSMItemListResponse.Value.Count > 0, "Protectable Object Result count can't be less than 1"); + + foreach (var po in response.CSMItemListResponse.Value) + { + Assert.True(!string.IsNullOrEmpty(po.Properties.ContainerId), "ContainerId can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(po.Properties.FriendlyName), "FriendlyName can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(po.Properties.ItemType), "ItemType can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(po.Properties.Status), "Status can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(po.Name), "Name can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(po.Type), "Type can't be null or empty"); + } + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + } + } + + [Fact] + public void ListAzureBackupItemDSTest() + { + using (UndoContext context = UndoContext.Current) + { + context.Start(); + + CSMProtectedItemQueryObject DSQueryParam = new CSMProtectedItemQueryObject() + { + ProtectionStatus = null, + Status = null, + Type = null + }; + + var client = GetServiceClient(); + + var response = client.DataSource.ListCSMAsync(DSQueryParam, GetCustomRequestHeaders()).Result; + foreach (var ds in response.CSMProtectedItemListResponse.Value) + { + Assert.True(!string.IsNullOrEmpty(ds.Properties.ContainerId), "ContainerId can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ds.Properties.FriendlyName), "FriendlyName can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ds.Properties.ItemType), "ItemType can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ds.Properties.LastBackupJobId), "LastBackupJobId can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ds.Properties.LastBackupStatus), "LastBackupStatus can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ds.Properties.ProtectionPolicyId), "ProtectionPolicyId can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ds.Properties.ProtectionStatus), "ProtectionStatus can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ds.Properties.RecoveryPointsCount.ToString()), "RecoveryPointsCount can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ds.Properties.Status), "Status can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ds.Name), "Name can't be null or empty"); + Assert.True(!string.IsNullOrEmpty(ds.Type), "Type can't be null or empty"); + } + + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + } + } + } +} \ No newline at end of file diff --git a/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/CSMProtectionPolicyTests.cs b/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/CSMProtectionPolicyTests.cs index 0d09bc8425876..fdd496eab07b4 100644 --- a/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/CSMProtectionPolicyTests.cs +++ b/src/ResourceManagement/AzureBackup/BackupServices.Tests/ScenarioTests/CSMProtectionPolicyTests.cs @@ -19,7 +19,7 @@ public void ListProtectionPolicyTest() context.Start(); var client = GetServiceClient(); - var response = client.ProtectionPolicy.List(GetCustomRequestHeaders()); + var response = client.CSMProtectionPolicy.List(GetCustomRequestHeaders()); Assert.True(response.CSMProtectionPolicyListResponse.Value.Count > 0, "Protection Policies Result count can't be less than 1"); @@ -32,12 +32,12 @@ public void ListProtectionPolicyTest() Assert.True(!string.IsNullOrEmpty(ppo.Name), "Policy Name can't be null or empty"); if(ppo.Properties.BackupSchedule.ScheduleRun == "Daily") { - Assert.True(ppo.Properties.LTRRetentionPolicy.DailySchedule == null, "Daily RetentionType can't be null or empty for Daily Schedule"); + Assert.True(ppo.Properties.LtrRetentionPolicy.DailySchedule == null, "Daily RetentionType can't be null or empty for Daily Schedule"); } else { - Assert.True(ppo.Properties.LTRRetentionPolicy.WeeklySchedule == null, "Weekly RetentionType can't be null or empty for Weekly Schedule"); + Assert.True(ppo.Properties.LtrRetentionPolicy.WeeklySchedule == null, "Weekly RetentionType can't be null or empty for Weekly Schedule"); } } @@ -61,7 +61,7 @@ public void AddProtectionPolicyTest() addProtectionPolicyRequest.Properties.BackupSchedule = backupSchedule; addProtectionPolicyRequest.Properties.WorkloadType = ConfigurationManager.AppSettings["WorkloadType"]; addProtectionPolicyRequest.Properties.LtrRetentionPolicy = GetRetentionPolicy(backupSchedule.ScheduleRunTimes); - var response = client.ProtectionPolicy.Add(policyName, addProtectionPolicyRequest, GetCustomRequestHeaders()); + var response = client.CSMProtectionPolicy.Add(policyName, addProtectionPolicyRequest, GetCustomRequestHeaders()); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } @@ -81,7 +81,7 @@ public void UpdateProtectionPolicyTest() string policyName = ConfigurationManager.AppSettings["PolicyName"]; updateProtectionPolicyRequest.Properties.BackupSchedule = backupSchedule; updateProtectionPolicyRequest.Properties.LtrRetentionPolicy = GetRetentionPolicy(backupSchedule.ScheduleRunTimes); - var response = client.ProtectionPolicy.Update(policyName, updateProtectionPolicyRequest, GetCustomRequestHeaders()); + var response = client.CSMProtectionPolicy.Update(policyName, updateProtectionPolicyRequest, GetCustomRequestHeaders()); var isSuccess = (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Accepted) ? true : false; Assert.Equal(true, isSuccess); } @@ -95,7 +95,7 @@ public void DeleteProtectionPolicyTest() context.Start(); var client = GetServiceClient(); string policyName = ConfigurationManager.AppSettings["PolicyName"]; - var response = client.ProtectionPolicy.Delete(policyName, GetCustomRequestHeaders()); + var response = client.CSMProtectionPolicy.Delete(policyName, GetCustomRequestHeaders()); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/BackupServicesManagement.csproj b/src/ResourceManagement/AzureBackup/BackupServicesManagement/BackupServicesManagement.csproj index 6f10f382f6432..bf45d380063b0 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/BackupServicesManagement.csproj +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/BackupServicesManagement.csproj @@ -33,7 +33,438 @@ - + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/BackupServicesManagementClient.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/BackupServicesManagementClient.cs index 55d70145e37a8..62aa7408b89f8 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/BackupServicesManagementClient.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/BackupServicesManagementClient.cs @@ -110,12 +110,12 @@ public virtual IBackUpOperations BackUp get { return this._backUp; } } - private IContainerOperation _container; + private IContainerOperations _container; /// /// Definition of Container operations for the Azure Backup extension. /// - public virtual IContainerOperation Container + public virtual IContainerOperations Container { get { return this._container; } } @@ -201,7 +201,7 @@ public BackupServicesManagementClient() : base() { this._backUp = new BackUpOperations(this); - this._container = new ContainerOperation(this); + this._container = new ContainerOperations(this); this._cSMProtectionPolicy = new CSMProtectionPolicyOperations(this); this._dataSource = new DataSourceOperations(this); this._job = new JobOperations(this); @@ -310,7 +310,7 @@ public BackupServicesManagementClient(HttpClient httpClient) : base(httpClient) { this._backUp = new BackUpOperations(this); - this._container = new ContainerOperation(this); + this._container = new ContainerOperations(this); this._cSMProtectionPolicy = new CSMProtectionPolicyOperations(this); this._dataSource = new DataSourceOperations(this); this._job = new JobOperations(this); diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/BackupVaultServicesManagementClient.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/BackupVaultServicesManagementClient.cs index b698d817fd9f1..f30b441790cbb 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/BackupVaultServicesManagementClient.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/BackupVaultServicesManagementClient.cs @@ -100,6 +100,16 @@ public string ResourceName set { this._resourceName = value; } } + private IMarsContainerOperations _container; + + /// + /// Definition of Container operations for the Azure Backup extension. + /// + public virtual IMarsContainerOperations Container + { + get { return this._container; } + } + private IVaultOperations _vault; /// @@ -118,6 +128,7 @@ public virtual IVaultOperations Vault public BackupVaultServicesManagementClient() : base() { + this._container = new MarsContainerOperations(this); this._vault = new VaultOperations(this); this._apiVersion = "2013-03-01"; this._longRunningOperationInitialTimeout = -1; @@ -219,6 +230,7 @@ public BackupVaultServicesManagementClient(string resourceName, string resourceG public BackupVaultServicesManagementClient(HttpClient httpClient) : base(httpClient) { + this._container = new MarsContainerOperations(this); this._vault = new VaultOperations(this); this._apiVersion = "2013-03-01"; this._longRunningOperationInitialTimeout = -1; diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperation.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperations.cs similarity index 96% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperation.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperations.cs index 242aec6fdc6f2..a29ae5ae6dae3 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperation.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperations.cs @@ -36,15 +36,15 @@ namespace Microsoft.Azure.Management.BackupServices /// /// Definition of Container operations for the Azure Backup extension. /// - internal partial class ContainerOperation : IServiceOperations, IContainerOperation + internal partial class ContainerOperations : IServiceOperations, IContainerOperations { /// - /// Initializes a new instance of the ContainerOperation class. + /// Initializes a new instance of the ContainerOperations class. /// /// /// Reference to the service client. /// - internal ContainerOperation(BackupServicesManagementClient client) + internal ContainerOperations(BackupServicesManagementClient client) { this._client = client; } @@ -64,8 +64,8 @@ public BackupServicesManagementClient Client /// Get the list of all container based on the given query filter /// string. /// - /// - /// Optional. Job query parameter string. + /// + /// Optional. Container query parameters. /// /// /// Optional. Request header parameters. @@ -76,7 +76,7 @@ public BackupServicesManagementClient Client /// /// The definition of a CSMContainerListOperationResponse. /// - public async Task ListAsync(string queryFilterString, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) + public async Task ListAsync(ContainerQueryParameters parameters, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) { // Validate @@ -87,7 +87,7 @@ public async Task ListAsync(string queryFilte { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("queryFilterString", queryFilterString); + tracingParameters.Add("parameters", parameters); tracingParameters.Add("customRequestHeaders", customRequestHeaders); TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); } @@ -110,9 +110,22 @@ public async Task ListAsync(string queryFilte url = url + "/containers"; List queryParameters = new List(); queryParameters.Add("api-version=2014-09-01"); - if (queryFilterString != null) + List odataFilter = new List(); + if (parameters != null && parameters.ContainerType != null) { - queryParameters.Add("dummy=" + Uri.EscapeDataString(queryFilterString)); + odataFilter.Add("containerType eq '" + Uri.EscapeDataString(parameters.ContainerType) + "'"); + } + if (parameters != null && parameters.FriendlyName != null) + { + odataFilter.Add("friendlyName eq '" + Uri.EscapeDataString(parameters.FriendlyName) + "'"); + } + if (parameters != null && parameters.Status != null) + { + odataFilter.Add("status eq '" + Uri.EscapeDataString(parameters.Status) + "'"); + } + if (odataFilter.Count > 0) + { + queryParameters.Add("$filter=" + string.Join(" and ", odataFilter)); } if (queryParameters.Count > 0) { @@ -527,7 +540,7 @@ public async Task RegisterAsync(string containerName, CustomR url = url + "BackupVault"; url = url + "/"; url = url + Uri.EscapeDataString(this.Client.ResourceName); - url = url + "//registeredContainers/"; + url = url + "/registeredContainers/"; url = url + Uri.EscapeDataString(containerName); List queryParameters = new List(); queryParameters.Add("api-version=2014-09-01"); diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperationExtensions.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperationsExtensions.cs similarity index 82% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperationExtensions.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperationsExtensions.cs index d7135a2d3eed5..f77ee4ee800a3 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperationExtensions.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ContainerOperationsExtensions.cs @@ -28,7 +28,7 @@ namespace Microsoft.Azure.Management.BackupServices { - public static partial class ContainerOperationExtensions + public static partial class ContainerOperationsExtensions { /// /// Get the list of all container based on the given query filter @@ -36,10 +36,10 @@ public static partial class ContainerOperationExtensions /// /// /// Reference to the - /// Microsoft.Azure.Management.BackupServices.IContainerOperation. + /// Microsoft.Azure.Management.BackupServices.IContainerOperations. /// - /// - /// Optional. Job query parameter string. + /// + /// Optional. Container query parameters. /// /// /// Optional. Request header parameters. @@ -47,11 +47,11 @@ public static partial class ContainerOperationExtensions /// /// The definition of a CSMContainerListOperationResponse. /// - public static CSMContainerListOperationResponse List(this IContainerOperation operations, string queryFilterString, CustomRequestHeaders customRequestHeaders) + public static CSMContainerListOperationResponse List(this IContainerOperations operations, ContainerQueryParameters parameters, CustomRequestHeaders customRequestHeaders) { return Task.Factory.StartNew((object s) => { - return ((IContainerOperation)s).ListAsync(queryFilterString, customRequestHeaders); + return ((IContainerOperations)s).ListAsync(parameters, customRequestHeaders); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); } @@ -62,10 +62,10 @@ public static CSMContainerListOperationResponse List(this IContainerOperation op /// /// /// Reference to the - /// Microsoft.Azure.Management.BackupServices.IContainerOperation. + /// Microsoft.Azure.Management.BackupServices.IContainerOperations. /// - /// - /// Optional. Job query parameter string. + /// + /// Optional. Container query parameters. /// /// /// Optional. Request header parameters. @@ -73,9 +73,9 @@ public static CSMContainerListOperationResponse List(this IContainerOperation op /// /// The definition of a CSMContainerListOperationResponse. /// - public static Task ListAsync(this IContainerOperation operations, string queryFilterString, CustomRequestHeaders customRequestHeaders) + public static Task ListAsync(this IContainerOperations operations, ContainerQueryParameters parameters, CustomRequestHeaders customRequestHeaders) { - return operations.ListAsync(queryFilterString, customRequestHeaders, CancellationToken.None); + return operations.ListAsync(parameters, customRequestHeaders, CancellationToken.None); } /// @@ -83,7 +83,7 @@ public static Task ListAsync(this IContainerO /// /// /// Reference to the - /// Microsoft.Azure.Management.BackupServices.IContainerOperation. + /// Microsoft.Azure.Management.BackupServices.IContainerOperations. /// /// /// Optional. Request header parameters. @@ -91,11 +91,11 @@ public static Task ListAsync(this IContainerO /// /// The definition of a Operation Response. /// - public static OperationResponse Refresh(this IContainerOperation operations, CustomRequestHeaders customRequestHeaders) + public static OperationResponse Refresh(this IContainerOperations operations, CustomRequestHeaders customRequestHeaders) { return Task.Factory.StartNew((object s) => { - return ((IContainerOperation)s).RefreshAsync(customRequestHeaders); + return ((IContainerOperations)s).RefreshAsync(customRequestHeaders); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); } @@ -105,7 +105,7 @@ public static OperationResponse Refresh(this IContainerOperation operations, Cus /// /// /// Reference to the - /// Microsoft.Azure.Management.BackupServices.IContainerOperation. + /// Microsoft.Azure.Management.BackupServices.IContainerOperations. /// /// /// Optional. Request header parameters. @@ -113,7 +113,7 @@ public static OperationResponse Refresh(this IContainerOperation operations, Cus /// /// The definition of a Operation Response. /// - public static Task RefreshAsync(this IContainerOperation operations, CustomRequestHeaders customRequestHeaders) + public static Task RefreshAsync(this IContainerOperations operations, CustomRequestHeaders customRequestHeaders) { return operations.RefreshAsync(customRequestHeaders, CancellationToken.None); } @@ -123,7 +123,7 @@ public static Task RefreshAsync(this IContainerOperation oper /// /// /// Reference to the - /// Microsoft.Azure.Management.BackupServices.IContainerOperation. + /// Microsoft.Azure.Management.BackupServices.IContainerOperations. /// /// /// Required. Container to be register. @@ -134,11 +134,11 @@ public static Task RefreshAsync(this IContainerOperation oper /// /// The definition of a Operation Response. /// - public static OperationResponse Register(this IContainerOperation operations, string containerName, CustomRequestHeaders customRequestHeaders) + public static OperationResponse Register(this IContainerOperations operations, string containerName, CustomRequestHeaders customRequestHeaders) { return Task.Factory.StartNew((object s) => { - return ((IContainerOperation)s).RegisterAsync(containerName, customRequestHeaders); + return ((IContainerOperations)s).RegisterAsync(containerName, customRequestHeaders); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); } @@ -148,7 +148,7 @@ public static OperationResponse Register(this IContainerOperation operations, st /// /// /// Reference to the - /// Microsoft.Azure.Management.BackupServices.IContainerOperation. + /// Microsoft.Azure.Management.BackupServices.IContainerOperations. /// /// /// Required. Container to be register. @@ -159,7 +159,7 @@ public static OperationResponse Register(this IContainerOperation operations, st /// /// The definition of a Operation Response. /// - public static Task RegisterAsync(this IContainerOperation operations, string containerName, CustomRequestHeaders customRequestHeaders) + public static Task RegisterAsync(this IContainerOperations operations, string containerName, CustomRequestHeaders customRequestHeaders) { return operations.RegisterAsync(containerName, customRequestHeaders, CancellationToken.None); } @@ -169,7 +169,7 @@ public static Task RegisterAsync(this IContainerOperation ope /// /// /// Reference to the - /// Microsoft.Azure.Management.BackupServices.IContainerOperation. + /// Microsoft.Azure.Management.BackupServices.IContainerOperations. /// /// /// Required. Container which we want to unregister. @@ -180,11 +180,11 @@ public static Task RegisterAsync(this IContainerOperation ope /// /// The definition of a Operation Response. /// - public static OperationResponse Unregister(this IContainerOperation operations, string containerName, CustomRequestHeaders customRequestHeaders) + public static OperationResponse Unregister(this IContainerOperations operations, string containerName, CustomRequestHeaders customRequestHeaders) { return Task.Factory.StartNew((object s) => { - return ((IContainerOperation)s).UnregisterAsync(containerName, customRequestHeaders); + return ((IContainerOperations)s).UnregisterAsync(containerName, customRequestHeaders); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); } @@ -194,7 +194,7 @@ public static OperationResponse Unregister(this IContainerOperation operations, /// /// /// Reference to the - /// Microsoft.Azure.Management.BackupServices.IContainerOperation. + /// Microsoft.Azure.Management.BackupServices.IContainerOperations. /// /// /// Required. Container which we want to unregister. @@ -205,7 +205,7 @@ public static OperationResponse Unregister(this IContainerOperation operations, /// /// The definition of a Operation Response. /// - public static Task UnregisterAsync(this IContainerOperation operations, string containerName, CustomRequestHeaders customRequestHeaders) + public static Task UnregisterAsync(this IContainerOperations operations, string containerName, CustomRequestHeaders customRequestHeaders) { return operations.UnregisterAsync(containerName, customRequestHeaders, CancellationToken.None); } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/DataSourceOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/DataSourceOperations.cs index 854c21ed25edf..7ddacac178fe1 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/DataSourceOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/DataSourceOperations.cs @@ -62,210 +62,6 @@ public BackupServicesManagementClient Client get { return this._client; } } - /// - /// Enable protection for given item. - /// - /// - /// Optional. Request header parameters. - /// - /// - /// Required. containerName. - /// - /// - /// Required. itemName. - /// - /// - /// Required. Set protection request input. - /// - /// - /// Cancellation token. - /// - /// - /// The definition of a Operation Response. - /// - public async Task CSMUpdateProtectionAsync(CustomRequestHeaders customRequestHeaders, CustomRequestHeaders containerName, CustomRequestHeaders itemName, CSMUpdateProtectionRequest csmparameters, CancellationToken cancellationToken) - { - // Validate - if (containerName == null) - { - throw new ArgumentNullException("containerName"); - } - if (itemName == null) - { - throw new ArgumentNullException("itemName"); - } - if (csmparameters == null) - { - throw new ArgumentNullException("csmparameters"); - } - if (csmparameters.Properties == null) - { - throw new ArgumentNullException("csmparameters.Properties"); - } - if (csmparameters.Properties.PolicyId == null) - { - throw new ArgumentNullException("csmparameters.Properties.PolicyId"); - } - - // 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("csmparameters", csmparameters); - TracingAdapter.Enter(invocationId, this, "CSMUpdateProtectionAsync", 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/"; - url = url + Uri.EscapeDataString(containerName.ToString()); - url = url + "/protectedItems/"; - url = url + Uri.EscapeDataString(itemName.ToString()); - 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 = new HttpMethod("PATCH"); - 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); - - // Serialize Request - string requestContent = null; - JToken requestDoc = null; - - JObject cSMUpdateProtectionRequestValue = new JObject(); - requestDoc = cSMUpdateProtectionRequestValue; - - JObject propertiesValue = new JObject(); - cSMUpdateProtectionRequestValue["properties"] = propertiesValue; - - propertiesValue["policyId"] = csmparameters.Properties.PolicyId; - - 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.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.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) - { - Guid operationIdInstance = Guid.Parse(((string)responseDoc)); - result.OperationId = operationIdInstance; - } - - } - 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(); - } - } - } - /// /// Disable protection for given item /// @@ -311,7 +107,7 @@ public async Task DisableProtectionCSMAsync(CustomRequestHead // Construct URL string url = ""; - url = url + "/Subscriptions/"; + url = url + "/subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); @@ -499,7 +295,7 @@ public async Task EnableProtectionCSMAsync(CustomRequestHeade // Construct URL string url = ""; - url = url + "/Subscriptions/"; + url = url + "/subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); @@ -675,7 +471,7 @@ public async Task ListCSMAsync(CSMProtect // Construct URL string url = ""; - url = url + "/Subscriptions/"; + url = url + "/subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); @@ -691,17 +487,22 @@ public async Task ListCSMAsync(CSMProtect url = url + "/protectedItems"; List queryParameters = new List(); queryParameters.Add("api-version=2014-09-01"); + List odataFilter = new List(); if (csmparameters != null && csmparameters.ProtectionStatus != null) { - queryParameters.Add("ProtectionStatus -eq " + Uri.EscapeDataString(csmparameters.ProtectionStatus)); + odataFilter.Add("protectionStatus eq '" + Uri.EscapeDataString(csmparameters.ProtectionStatus) + "'"); } if (csmparameters != null && csmparameters.Status != null) { - queryParameters.Add("Status -eq " + Uri.EscapeDataString(csmparameters.Status)); + odataFilter.Add("status eq '" + Uri.EscapeDataString(csmparameters.Status) + "'"); } if (csmparameters != null && csmparameters.Type != null) { - queryParameters.Add("Type -eq " + Uri.EscapeDataString(csmparameters.Type)); + odataFilter.Add("type eq '" + Uri.EscapeDataString(csmparameters.Type) + "'"); + } + if (odataFilter.Count > 0) + { + queryParameters.Add("$filter=" + string.Join(" and ", odataFilter)); } if (queryParameters.Count > 0) { @@ -780,7 +581,7 @@ public async Task ListCSMAsync(CSMProtect CSMProtectedItemListResponse cSMProtectedItemListResponseInstance = new CSMProtectedItemListResponse(); result.CSMProtectedItemListResponse = cSMProtectedItemListResponseInstance; - JToken valueArray = responseDoc["Value"]; + JToken valueArray = responseDoc["value"]; if (valueArray != null && valueArray.Type != JTokenType.Null) { foreach (JToken valueValue in ((JArray)valueArray)) @@ -788,7 +589,7 @@ public async Task ListCSMAsync(CSMProtect CSMProtectedItemResponse cSMProtectedItemResponseInstance = new CSMProtectedItemResponse(); cSMProtectedItemListResponseInstance.Value.Add(cSMProtectedItemResponseInstance); - JToken propertiesValue = valueValue["Properties"]; + JToken propertiesValue = valueValue["properties"]; if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) { CSMProtectedItemProperties propertiesInstance = new CSMProtectedItemProperties(); @@ -960,5 +761,209 @@ public async Task ListCSMAsync(CSMProtect } } } + + /// + /// Enable protection for given item. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Required. containerName. + /// + /// + /// Required. itemName. + /// + /// + /// Required. Set protection request input. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + public async Task UpdateProtectionCSMAsync(CustomRequestHeaders customRequestHeaders, string containerName, string itemName, CSMUpdateProtectionRequest csmparameters, CancellationToken cancellationToken) + { + // Validate + if (containerName == null) + { + throw new ArgumentNullException("containerName"); + } + if (itemName == null) + { + throw new ArgumentNullException("itemName"); + } + if (csmparameters == null) + { + throw new ArgumentNullException("csmparameters"); + } + if (csmparameters.Properties == null) + { + throw new ArgumentNullException("csmparameters.Properties"); + } + if (csmparameters.Properties.PolicyId == null) + { + throw new ArgumentNullException("csmparameters.Properties.PolicyId"); + } + + // 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("csmparameters", csmparameters); + TracingAdapter.Enter(invocationId, this, "UpdateProtectionCSMAsync", 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/"; + url = url + Uri.EscapeDataString(containerName); + url = url + "/protectedItems/"; + url = url + Uri.EscapeDataString(itemName); + 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 = new HttpMethod("PATCH"); + 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); + + // Serialize Request + string requestContent = null; + JToken requestDoc = null; + + JObject cSMUpdateProtectionRequestValue = new JObject(); + requestDoc = cSMUpdateProtectionRequestValue; + + JObject propertiesValue = new JObject(); + cSMUpdateProtectionRequestValue["properties"] = propertiesValue; + + propertiesValue["policyId"] = csmparameters.Properties.PolicyId; + + 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.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.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) + { + Guid operationIdInstance = Guid.Parse(((string)responseDoc)); + result.OperationId = operationIdInstance; + } + + } + 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(); + } + } + } } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/DataSourceOperationsExtensions.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/DataSourceOperationsExtensions.cs index d77bed3d706c0..6f2f7aa3c3153 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/DataSourceOperationsExtensions.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/DataSourceOperationsExtensions.cs @@ -30,64 +30,6 @@ namespace Microsoft.Azure.Management.BackupServices { public static partial class DataSourceOperationsExtensions { - /// - /// Enable protection for given item. - /// - /// - /// Reference to the - /// Microsoft.Azure.Management.BackupServices.IDataSourceOperations. - /// - /// - /// Optional. Request header parameters. - /// - /// - /// Required. containerName. - /// - /// - /// Required. itemName. - /// - /// - /// Required. Set protection request input. - /// - /// - /// The definition of a Operation Response. - /// - public static OperationResponse CSMUpdateProtection(this IDataSourceOperations operations, CustomRequestHeaders customRequestHeaders, CustomRequestHeaders containerName, CustomRequestHeaders itemName, CSMUpdateProtectionRequest csmparameters) - { - return Task.Factory.StartNew((object s) => - { - return ((IDataSourceOperations)s).CSMUpdateProtectionAsync(customRequestHeaders, containerName, itemName, csmparameters); - } - , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); - } - - /// - /// Enable protection for given item. - /// - /// - /// Reference to the - /// Microsoft.Azure.Management.BackupServices.IDataSourceOperations. - /// - /// - /// Optional. Request header parameters. - /// - /// - /// Required. containerName. - /// - /// - /// Required. itemName. - /// - /// - /// Required. Set protection request input. - /// - /// - /// The definition of a Operation Response. - /// - public static Task CSMUpdateProtectionAsync(this IDataSourceOperations operations, CustomRequestHeaders customRequestHeaders, CustomRequestHeaders containerName, CustomRequestHeaders itemName, CSMUpdateProtectionRequest csmparameters) - { - return operations.CSMUpdateProtectionAsync(customRequestHeaders, containerName, itemName, csmparameters, CancellationToken.None); - } - /// /// Disable protection for given item /// @@ -243,5 +185,63 @@ public static Task ListCSMAsync(this IDat { return operations.ListCSMAsync(csmparameters, customRequestHeaders, CancellationToken.None); } + + /// + /// Enable protection for given item. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IDataSourceOperations. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Required. containerName. + /// + /// + /// Required. itemName. + /// + /// + /// Required. Set protection request input. + /// + /// + /// The definition of a Operation Response. + /// + public static OperationResponse UpdateProtectionCSM(this IDataSourceOperations operations, CustomRequestHeaders customRequestHeaders, string containerName, string itemName, CSMUpdateProtectionRequest csmparameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IDataSourceOperations)s).UpdateProtectionCSMAsync(customRequestHeaders, containerName, itemName, csmparameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Enable protection for given item. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IDataSourceOperations. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Required. containerName. + /// + /// + /// Required. itemName. + /// + /// + /// Required. Set protection request input. + /// + /// + /// The definition of a Operation Response. + /// + public static Task UpdateProtectionCSMAsync(this IDataSourceOperations operations, CustomRequestHeaders customRequestHeaders, string containerName, string itemName, CSMUpdateProtectionRequest csmparameters) + { + return operations.UpdateProtectionCSMAsync(customRequestHeaders, containerName, itemName, csmparameters, CancellationToken.None); + } } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IBackupServicesManagementClient.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IBackupServicesManagementClient.cs index 8cccf7d633b23..c293ff71f17bc 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IBackupServicesManagementClient.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IBackupServicesManagementClient.cs @@ -91,7 +91,7 @@ IBackUpOperations BackUp /// /// Definition of Container operations for the Azure Backup extension. /// - IContainerOperation Container + IContainerOperations Container { get; } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IBackupVaultServicesManagementClient.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IBackupVaultServicesManagementClient.cs index bd70ba032be59..f2ca337b67976 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IBackupVaultServicesManagementClient.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IBackupVaultServicesManagementClient.cs @@ -80,6 +80,14 @@ string ResourceName get; set; } + /// + /// Definition of Container operations for the Azure Backup extension. + /// + IMarsContainerOperations Container + { + get; + } + /// /// Definition of Vault-related operations for the Azure Backup /// extension. diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IContainerOperation.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IContainerOperations.cs similarity index 91% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IContainerOperation.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IContainerOperations.cs index 4fc24f26ace03..3927dfbd4e035 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IContainerOperation.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IContainerOperations.cs @@ -31,14 +31,14 @@ namespace Microsoft.Azure.Management.BackupServices /// /// Definition of Container operations for the Azure Backup extension. /// - public partial interface IContainerOperation + public partial interface IContainerOperations { /// /// Get the list of all container based on the given query filter /// string. /// - /// - /// Job query parameter string. + /// + /// Container query parameters. /// /// /// Request header parameters. @@ -49,7 +49,7 @@ public partial interface IContainerOperation /// /// The definition of a CSMContainerListOperationResponse. /// - Task ListAsync(string queryFilterString, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); + Task ListAsync(ContainerQueryParameters parameters, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); /// /// Trigger the Discovery. diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IDataSourceOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IDataSourceOperations.cs index a0e8118c1a7b6..5f0dfe95cf9dc 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IDataSourceOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IDataSourceOperations.cs @@ -33,29 +33,6 @@ namespace Microsoft.Azure.Management.BackupServices /// public partial interface IDataSourceOperations { - /// - /// Enable protection for given item. - /// - /// - /// Request header parameters. - /// - /// - /// containerName. - /// - /// - /// itemName. - /// - /// - /// Set protection request input. - /// - /// - /// Cancellation token. - /// - /// - /// The definition of a Operation Response. - /// - Task CSMUpdateProtectionAsync(CustomRequestHeaders customRequestHeaders, CustomRequestHeaders containerName, CustomRequestHeaders itemName, CSMUpdateProtectionRequest csmparameters, CancellationToken cancellationToken); - /// /// Disable protection for given item /// @@ -115,5 +92,28 @@ public partial interface IDataSourceOperations /// The definition of a CSMProtectedItemListOperationResponse. /// Task ListCSMAsync(CSMProtectedItemQueryObject csmparameters, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); + + /// + /// Enable protection for given item. + /// + /// + /// Request header parameters. + /// + /// + /// containerName. + /// + /// + /// itemName. + /// + /// + /// Set protection request input. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + Task UpdateProtectionCSMAsync(CustomRequestHeaders customRequestHeaders, string containerName, string itemName, CSMUpdateProtectionRequest csmparameters, CancellationToken cancellationToken); } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IMarsContainerOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IMarsContainerOperations.cs new file mode 100644 index 0000000000000..32d4696590d7a --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/IMarsContainerOperations.cs @@ -0,0 +1,112 @@ +// +// 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 System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices +{ + /// + /// Definition of Container operations for the Azure Backup extension. + /// + public partial interface IMarsContainerOperations + { + /// + /// Enable the container reregistration. + /// + /// + /// MARS container ID. + /// + /// + /// Enable Reregistration Request. + /// + /// + /// Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + Task EnableMarsContainerReregistrationAsync(string containerId, EnableReregistrationRequest enableReregistrationRequest, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); + + /// + /// Get the list of all container based on the given query filter + /// string. + /// + /// + /// Type of container. + /// + /// + /// Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// List of Microsoft Azure Recovery Services (MARS) containers. + /// + Task ListMarsContainersByTypeAsync(MarsContainerType containerType, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); + + /// + /// Get the list of all container based on the given query filter + /// string. + /// + /// + /// Type of container. + /// + /// + /// Friendly name of container. + /// + /// + /// Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// List of Microsoft Azure Recovery Services (MARS) containers. + /// + Task ListMarsContainersByTypeAndFriendlyNameAsync(MarsContainerType containerType, string friendlyName, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); + + /// + /// Unregister the container. + /// + /// + /// MARS container ID. + /// + /// + /// Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + Task UnregisterMarsContainerAsync(string containerId, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/JobQueryParameter.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/JobQueryParameter.cs deleted file mode 100644 index 9e32cfecaa09f..0000000000000 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/JobQueryParameter.cs +++ /dev/null @@ -1,105 +0,0 @@ -// -// 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 -{ - /// - /// The definition of a JobQueryParameter object. - /// - public partial class JobQueryParameter - { - private string _endTime; - - /// - /// Optional. End time of time range in UTC. - /// - public string EndTime - { - get { return this._endTime; } - set { this._endTime = value; } - } - - private string _jobId; - - /// - /// Optional. JobId of job. - /// - public string JobId - { - get { return this._jobId; } - set { this._jobId = value; } - } - - private string _operation; - - /// - /// Optional. Operation of job. - /// - public string Operation - { - get { return this._operation; } - set { this._operation = value; } - } - - private string _startTime; - - /// - /// Optional. Start time of time range in UTC. - /// - public string StartTime - { - get { return this._startTime; } - set { this._startTime = value; } - } - - private string _status; - - /// - /// Optional. Status of job. - /// - public string Status - { - get { return this._status; } - set { this._status = value; } - } - - private string _type; - - /// - /// Optional. Type of job. - /// - public string Type - { - get { return this._type; } - set { this._type = value; } - } - - /// - /// Initializes a new instance of the JobQueryParameter class. - /// - public JobQueryParameter() - { - } - } -} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/JobResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/JobResponse.cs deleted file mode 100644 index 9d2170619788c..0000000000000 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/JobResponse.cs +++ /dev/null @@ -1,92 +0,0 @@ -// -// 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.Collections.Generic; -using System.Linq; -using Hyak.Common; -using Microsoft.Azure.Management.BackupServices.Models; - -namespace Microsoft.Azure.Management.BackupServices -{ - /// - /// The definition of a Management List Response. - /// - public partial class JobResponse : ManagementBaseObject, IEnumerable - { - private IList _objects; - - /// - /// Optional. The Objects of the JobResponse. - /// - public IList Objects - { - get { return this._objects; } - set { this._objects = value; } - } - - private int _resultCount; - - /// - /// Optional. The ResultCount of JobResponse. - /// - public int ResultCount - { - get { return this._resultCount; } - set { this._resultCount = value; } - } - - private string _skiptoken; - - /// - /// Optional. The Skiptoken of the JobResponse. - /// - public string Skiptoken - { - get { return this._skiptoken; } - set { this._skiptoken = value; } - } - - /// - /// Initializes a new instance of the JobResponse class. - /// - public JobResponse() - { - this.Objects = new LazyList(); - } - - /// - /// Gets the sequence of Objects. - /// - public IEnumerator GetEnumerator() - { - return this.Objects.GetEnumerator(); - } - - /// - /// Gets the sequence of Objects. - /// - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return this.GetEnumerator(); - } - } -} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/MarsContainerOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/MarsContainerOperations.cs new file mode 100644 index 0000000000000..1c210894e11a1 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/MarsContainerOperations.cs @@ -0,0 +1,993 @@ +// +// 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.Collections.Generic; +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; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.BackupServices +{ + /// + /// Definition of Container operations for the Azure Backup extension. + /// + internal partial class MarsContainerOperations : IServiceOperations, IMarsContainerOperations + { + /// + /// Initializes a new instance of the MarsContainerOperations class. + /// + /// + /// Reference to the service client. + /// + internal MarsContainerOperations(BackupVaultServicesManagementClient client) + { + this._client = client; + } + + private BackupVaultServicesManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.BackupServices.BackupVaultServicesManagementClient. + /// + public BackupVaultServicesManagementClient Client + { + get { return this._client; } + } + + /// + /// Enable the container reregistration. + /// + /// + /// Required. MARS container ID. + /// + /// + /// Required. Enable Reregistration Request. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + public async Task EnableMarsContainerReregistrationAsync(string containerId, EnableReregistrationRequest enableReregistrationRequest, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) + { + // Validate + if (containerId == null) + { + throw new ArgumentNullException("containerId"); + } + if (enableReregistrationRequest == null) + { + throw new ArgumentNullException("enableReregistrationRequest"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("containerId", containerId); + tracingParameters.Add("enableReregistrationRequest", enableReregistrationRequest); + tracingParameters.Add("customRequestHeaders", customRequestHeaders); + TracingAdapter.Enter(invocationId, this, "EnableMarsContainerReregistrationAsync", 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 + "/backupContainers/"; + url = url + Uri.EscapeDataString(containerId); + url = url + "/enableReRegister"; + List queryParameters = new List(); + queryParameters.Add("api-version=2015-03-15"); + 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 = new HttpMethod("PATCH"); + 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 enableReregistrationRequestValue = new JObject(); + requestDoc = enableReregistrationRequestValue; + + if (enableReregistrationRequest.ContainerReregistrationState != null) + { + JObject propertiesValue = new JObject(); + enableReregistrationRequestValue["properties"] = propertiesValue; + + propertiesValue["enableReRegister"] = enableReregistrationRequest.ContainerReregistrationState.EnableReregistration; + } + + 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.NoContent) + { + 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.NoContent) + { + 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) + { + Guid operationIdInstance = Guid.Parse(((string)responseDoc)); + result.OperationId = operationIdInstance; + } + + } + 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 container based on the given query filter + /// string. + /// + /// + /// Required. Type of container. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// List of Microsoft Azure Recovery Services (MARS) containers. + /// + public async Task ListMarsContainersByTypeAsync(MarsContainerType containerType, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("containerType", containerType); + tracingParameters.Add("customRequestHeaders", customRequestHeaders); + TracingAdapter.Enter(invocationId, this, "ListMarsContainersByTypeAsync", 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 + "/backupContainers"; + List queryParameters = new List(); + queryParameters.Add("api-version=2015-03-15"); + List odataFilter = new List(); + odataFilter.Add("type eq '" + Uri.EscapeDataString(containerType.ToString()) + "'"); + if (odataFilter.Count > 0) + { + queryParameters.Add("$filter=" + string.Join(null, odataFilter)); + } + 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 + ListMarsContainerOperationResponse result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ListMarsContainerOperationResponse(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + ListMarsContainerResponse listMarsContainerResponseInstance = new ListMarsContainerResponse(); + result.ListMarsContainerResponse = listMarsContainerResponseInstance; + + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + MarsContainerResponse marsContainerResponseInstance = new MarsContainerResponse(); + listMarsContainerResponseInstance.Value.Add(marsContainerResponseInstance); + + JToken uniqueNameValue = valueValue["uniqueName"]; + if (uniqueNameValue != null && uniqueNameValue.Type != JTokenType.Null) + { + string uniqueNameInstance = ((string)uniqueNameValue); + marsContainerResponseInstance.UniqueName = uniqueNameInstance; + } + + JToken containerTypeValue = valueValue["containerType"]; + if (containerTypeValue != null && containerTypeValue.Type != JTokenType.Null) + { + string containerTypeInstance = ((string)containerTypeValue); + marsContainerResponseInstance.ContainerType = containerTypeInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + MarsContainerProperties propertiesInstance = new MarsContainerProperties(); + marsContainerResponseInstance.Properties = propertiesInstance; + + JToken containerIdValue = propertiesValue["containerId"]; + if (containerIdValue != null && containerIdValue.Type != JTokenType.Null) + { + long containerIdInstance = ((long)containerIdValue); + propertiesInstance.ContainerId = containerIdInstance; + } + + JToken friendlyNameValue = propertiesValue["friendlyName"]; + if (friendlyNameValue != null && friendlyNameValue.Type != JTokenType.Null) + { + string friendlyNameInstance = ((string)friendlyNameValue); + propertiesInstance.FriendlyName = friendlyNameInstance; + } + + JToken containerStampIdValue = propertiesValue["containerStampId"]; + if (containerStampIdValue != null && containerStampIdValue.Type != JTokenType.Null) + { + Guid containerStampIdInstance = Guid.Parse(((string)containerStampIdValue)); + propertiesInstance.ContainerStampId = containerStampIdInstance; + } + + JToken containerStampUriValue = propertiesValue["containerStampUri"]; + if (containerStampUriValue != null && containerStampUriValue.Type != JTokenType.Null) + { + string containerStampUriInstance = ((string)containerStampUriValue); + propertiesInstance.ContainerStampUri = containerStampUriInstance; + } + + JToken canReRegisterValue = propertiesValue["canReRegister"]; + if (canReRegisterValue != null && canReRegisterValue.Type != JTokenType.Null) + { + bool canReRegisterInstance = ((bool)canReRegisterValue); + propertiesInstance.CanReRegister = canReRegisterInstance; + } + + JToken customerTypeValue = propertiesValue["customerType"]; + if (customerTypeValue != null && customerTypeValue.Type != JTokenType.Null) + { + string customerTypeInstance = ((string)customerTypeValue); + propertiesInstance.CustomerType = customerTypeInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + marsContainerResponseInstance.Id = idInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + marsContainerResponseInstance.Name = nameInstance; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + marsContainerResponseInstance.Type = typeInstance; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + listMarsContainerResponseInstance.NextLink = nextLinkInstance; + } + + JToken idValue2 = responseDoc["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + listMarsContainerResponseInstance.Id = idInstance2; + } + + JToken nameValue2 = responseDoc["name"]; + if (nameValue2 != null && nameValue2.Type != JTokenType.Null) + { + string nameInstance2 = ((string)nameValue2); + listMarsContainerResponseInstance.Name = nameInstance2; + } + + JToken typeValue2 = responseDoc["type"]; + if (typeValue2 != null && typeValue2.Type != JTokenType.Null) + { + string typeInstance2 = ((string)typeValue2); + listMarsContainerResponseInstance.Type = typeInstance2; + } + } + + } + 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 container based on the given query filter + /// string. + /// + /// + /// Required. Type of container. + /// + /// + /// Required. Friendly name of container. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// List of Microsoft Azure Recovery Services (MARS) containers. + /// + public async Task ListMarsContainersByTypeAndFriendlyNameAsync(MarsContainerType containerType, string friendlyName, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) + { + // Validate + if (friendlyName == null) + { + throw new ArgumentNullException("friendlyName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("containerType", containerType); + tracingParameters.Add("friendlyName", friendlyName); + tracingParameters.Add("customRequestHeaders", customRequestHeaders); + TracingAdapter.Enter(invocationId, this, "ListMarsContainersByTypeAndFriendlyNameAsync", 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 + "/backupContainers"; + List queryParameters = new List(); + queryParameters.Add("api-version=2015-03-15"); + List odataFilter = new List(); + odataFilter.Add("type eq '" + Uri.EscapeDataString(containerType.ToString()) + "'"); + odataFilter.Add("friendlyName eq '" + Uri.EscapeDataString(friendlyName) + "'"); + if (odataFilter.Count > 0) + { + queryParameters.Add("$filter=" + string.Join(" and ", odataFilter)); + } + 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 + ListMarsContainerOperationResponse result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ListMarsContainerOperationResponse(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + ListMarsContainerResponse listMarsContainerResponseInstance = new ListMarsContainerResponse(); + result.ListMarsContainerResponse = listMarsContainerResponseInstance; + + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + MarsContainerResponse marsContainerResponseInstance = new MarsContainerResponse(); + listMarsContainerResponseInstance.Value.Add(marsContainerResponseInstance); + + JToken uniqueNameValue = valueValue["uniqueName"]; + if (uniqueNameValue != null && uniqueNameValue.Type != JTokenType.Null) + { + string uniqueNameInstance = ((string)uniqueNameValue); + marsContainerResponseInstance.UniqueName = uniqueNameInstance; + } + + JToken containerTypeValue = valueValue["containerType"]; + if (containerTypeValue != null && containerTypeValue.Type != JTokenType.Null) + { + string containerTypeInstance = ((string)containerTypeValue); + marsContainerResponseInstance.ContainerType = containerTypeInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + MarsContainerProperties propertiesInstance = new MarsContainerProperties(); + marsContainerResponseInstance.Properties = propertiesInstance; + + JToken containerIdValue = propertiesValue["containerId"]; + if (containerIdValue != null && containerIdValue.Type != JTokenType.Null) + { + long containerIdInstance = ((long)containerIdValue); + propertiesInstance.ContainerId = containerIdInstance; + } + + JToken friendlyNameValue = propertiesValue["friendlyName"]; + if (friendlyNameValue != null && friendlyNameValue.Type != JTokenType.Null) + { + string friendlyNameInstance = ((string)friendlyNameValue); + propertiesInstance.FriendlyName = friendlyNameInstance; + } + + JToken containerStampIdValue = propertiesValue["containerStampId"]; + if (containerStampIdValue != null && containerStampIdValue.Type != JTokenType.Null) + { + Guid containerStampIdInstance = Guid.Parse(((string)containerStampIdValue)); + propertiesInstance.ContainerStampId = containerStampIdInstance; + } + + JToken containerStampUriValue = propertiesValue["containerStampUri"]; + if (containerStampUriValue != null && containerStampUriValue.Type != JTokenType.Null) + { + string containerStampUriInstance = ((string)containerStampUriValue); + propertiesInstance.ContainerStampUri = containerStampUriInstance; + } + + JToken canReRegisterValue = propertiesValue["canReRegister"]; + if (canReRegisterValue != null && canReRegisterValue.Type != JTokenType.Null) + { + bool canReRegisterInstance = ((bool)canReRegisterValue); + propertiesInstance.CanReRegister = canReRegisterInstance; + } + + JToken customerTypeValue = propertiesValue["customerType"]; + if (customerTypeValue != null && customerTypeValue.Type != JTokenType.Null) + { + string customerTypeInstance = ((string)customerTypeValue); + propertiesInstance.CustomerType = customerTypeInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + marsContainerResponseInstance.Id = idInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + marsContainerResponseInstance.Name = nameInstance; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + marsContainerResponseInstance.Type = typeInstance; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + listMarsContainerResponseInstance.NextLink = nextLinkInstance; + } + + JToken idValue2 = responseDoc["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + listMarsContainerResponseInstance.Id = idInstance2; + } + + JToken nameValue2 = responseDoc["name"]; + if (nameValue2 != null && nameValue2.Type != JTokenType.Null) + { + string nameInstance2 = ((string)nameValue2); + listMarsContainerResponseInstance.Name = nameInstance2; + } + + JToken typeValue2 = responseDoc["type"]; + if (typeValue2 != null && typeValue2.Type != JTokenType.Null) + { + string typeInstance2 = ((string)typeValue2); + listMarsContainerResponseInstance.Type = typeInstance2; + } + } + + } + 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(); + } + } + } + + /// + /// Unregister the container. + /// + /// + /// Required. MARS container ID. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + public async Task UnregisterMarsContainerAsync(string containerId, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) + { + // Validate + if (containerId == null) + { + throw new ArgumentNullException("containerId"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("containerId", containerId); + tracingParameters.Add("customRequestHeaders", customRequestHeaders); + TracingAdapter.Enter(invocationId, this, "UnregisterMarsContainerAsync", 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 + "/backupContainers/"; + url = url + Uri.EscapeDataString(containerId); + url = url + "/UnRegisterContainer"; + List queryParameters = new List(); + queryParameters.Add("api-version=2015-03-15"); + 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.Delete; + 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.NoContent) + { + 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.NoContent) + { + 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) + { + Guid operationIdInstance = Guid.Parse(((string)responseDoc)); + result.OperationId = operationIdInstance; + } + + } + 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/BackupServicesManagement/Generated/MarsContainerOperationsExtensions.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/MarsContainerOperationsExtensions.cs new file mode 100644 index 0000000000000..ae098c0a2dc83 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/MarsContainerOperationsExtensions.cs @@ -0,0 +1,233 @@ +// +// 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 System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices +{ + public static partial class MarsContainerOperationsExtensions + { + /// + /// Enable the container reregistration. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IMarsContainerOperations. + /// + /// + /// Required. MARS container ID. + /// + /// + /// Required. Enable Reregistration Request. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a Operation Response. + /// + public static OperationResponse EnableMarsContainerReregistration(this IMarsContainerOperations operations, string containerId, EnableReregistrationRequest enableReregistrationRequest, CustomRequestHeaders customRequestHeaders) + { + return Task.Factory.StartNew((object s) => + { + return ((IMarsContainerOperations)s).EnableMarsContainerReregistrationAsync(containerId, enableReregistrationRequest, customRequestHeaders); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Enable the container reregistration. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IMarsContainerOperations. + /// + /// + /// Required. MARS container ID. + /// + /// + /// Required. Enable Reregistration Request. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a Operation Response. + /// + public static Task EnableMarsContainerReregistrationAsync(this IMarsContainerOperations operations, string containerId, EnableReregistrationRequest enableReregistrationRequest, CustomRequestHeaders customRequestHeaders) + { + return operations.EnableMarsContainerReregistrationAsync(containerId, enableReregistrationRequest, customRequestHeaders, CancellationToken.None); + } + + /// + /// Get the list of all container based on the given query filter + /// string. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IMarsContainerOperations. + /// + /// + /// Required. Type of container. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// List of Microsoft Azure Recovery Services (MARS) containers. + /// + public static ListMarsContainerOperationResponse ListMarsContainersByType(this IMarsContainerOperations operations, MarsContainerType containerType, CustomRequestHeaders customRequestHeaders) + { + return Task.Factory.StartNew((object s) => + { + return ((IMarsContainerOperations)s).ListMarsContainersByTypeAsync(containerType, customRequestHeaders); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get the list of all container based on the given query filter + /// string. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IMarsContainerOperations. + /// + /// + /// Required. Type of container. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// List of Microsoft Azure Recovery Services (MARS) containers. + /// + public static Task ListMarsContainersByTypeAsync(this IMarsContainerOperations operations, MarsContainerType containerType, CustomRequestHeaders customRequestHeaders) + { + return operations.ListMarsContainersByTypeAsync(containerType, customRequestHeaders, CancellationToken.None); + } + + /// + /// Get the list of all container based on the given query filter + /// string. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IMarsContainerOperations. + /// + /// + /// Required. Type of container. + /// + /// + /// Required. Friendly name of container. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// List of Microsoft Azure Recovery Services (MARS) containers. + /// + public static ListMarsContainerOperationResponse ListMarsContainersByTypeAndFriendlyName(this IMarsContainerOperations operations, MarsContainerType containerType, string friendlyName, CustomRequestHeaders customRequestHeaders) + { + return Task.Factory.StartNew((object s) => + { + return ((IMarsContainerOperations)s).ListMarsContainersByTypeAndFriendlyNameAsync(containerType, friendlyName, customRequestHeaders); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get the list of all container based on the given query filter + /// string. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IMarsContainerOperations. + /// + /// + /// Required. Type of container. + /// + /// + /// Required. Friendly name of container. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// List of Microsoft Azure Recovery Services (MARS) containers. + /// + public static Task ListMarsContainersByTypeAndFriendlyNameAsync(this IMarsContainerOperations operations, MarsContainerType containerType, string friendlyName, CustomRequestHeaders customRequestHeaders) + { + return operations.ListMarsContainersByTypeAndFriendlyNameAsync(containerType, friendlyName, customRequestHeaders, CancellationToken.None); + } + + /// + /// Unregister the container. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IMarsContainerOperations. + /// + /// + /// Required. MARS container ID. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a Operation Response. + /// + public static OperationResponse UnregisterMarsContainer(this IMarsContainerOperations operations, string containerId, CustomRequestHeaders customRequestHeaders) + { + return Task.Factory.StartNew((object s) => + { + return ((IMarsContainerOperations)s).UnregisterMarsContainerAsync(containerId, customRequestHeaders); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Unregister the container. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IMarsContainerOperations. + /// + /// + /// Required. MARS container ID. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a Operation Response. + /// + public static Task UnregisterMarsContainerAsync(this IMarsContainerOperations operations, string containerId, CustomRequestHeaders customRequestHeaders) + { + return operations.UnregisterMarsContainerAsync(containerId, customRequestHeaders, CancellationToken.None); + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/BackupBaseObject.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/BackupBaseObject.cs new file mode 100644 index 0000000000000..cb4f4ca62c825 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/BackupBaseObject.cs @@ -0,0 +1,39 @@ +// +// 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 BackupBaseObject. + /// + public partial class BackupBaseObject + { + /// + /// Initializes a new instance of the BackupBaseObject class. + /// + public BackupBaseObject() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/DataSourceQueryParameter.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/BackupBaseResponse.cs similarity index 68% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/DataSourceQueryParameter.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/BackupBaseResponse.cs index 2e1466ebe56ec..a2015df2644ea 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/DataSourceQueryParameter.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/BackupBaseResponse.cs @@ -21,40 +21,41 @@ using System; using System.Linq; +using Microsoft.Azure.Management.BackupServices.Models; namespace Microsoft.Azure.Management.BackupServices.Models { /// - /// The definition of a DataSourceQueryParameter object. + /// The definition of a BackupBaseResponse. /// - public partial class DataSourceQueryParameter + public partial class BackupBaseResponse : BackupBaseObject { - private string _protectionStatus; + private string _id; /// - /// Optional. Protection Status of item. + /// Optional. ID /// - public string ProtectionStatus + public string Id { - get { return this._protectionStatus; } - set { this._protectionStatus = value; } + get { return this._id; } + set { this._id = value; } } - private string _status; + private string _name; /// - /// Optional. Status of item. + /// Optional. Name /// - public string Status + public string Name { - get { return this._status; } - set { this._status = value; } + get { return this._name; } + set { this._name = value; } } private string _type; /// - /// Optional. Type of item. + /// Optional. Type /// public string Type { @@ -63,9 +64,9 @@ public string Type } /// - /// Initializes a new instance of the DataSourceQueryParameter class. + /// Initializes a new instance of the BackupBaseResponse class. /// - public DataSourceQueryParameter() + public BackupBaseResponse() { } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobByIdResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/BackupListResponse.cs similarity index 69% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobByIdResponse.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/BackupListResponse.cs index db96bc9182a13..71eed8b1f6d57 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobByIdResponse.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/BackupListResponse.cs @@ -21,32 +21,30 @@ using System; using System.Linq; -using Microsoft.Azure; using Microsoft.Azure.Management.BackupServices.Models; namespace Microsoft.Azure.Management.BackupServices.Models { /// - /// The response model for the list jobs operation. + /// The definition of a BackupListResponse. /// - public partial class JobByIdResponse : AzureOperationResponse + public partial class BackupListResponse : BackupBaseResponse { - private JobProperties _job; + private string _nextLink; /// - /// Optional. The list of jobs queried by the filters for the resource - /// id. + /// Optional. Next Link /// - public JobProperties Job + public string NextLink { - get { return this._job; } - set { this._job = value; } + get { return this._nextLink; } + set { this._nextLink = value; } } /// - /// Initializes a new instance of the JobByIdResponse class. + /// Initializes a new instance of the BackupListResponse class. /// - public JobByIdResponse() + public BackupListResponse() { } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobProperties.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/CSMUpdateProtectionPolicyRequest.cs similarity index 54% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobProperties.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/CSMUpdateProtectionPolicyRequest.cs index 8df38346376b8..347067a7bd9c1 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobProperties.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/CSMUpdateProtectionPolicyRequest.cs @@ -20,47 +20,47 @@ // code is regenerated. using System; -using System.Collections.Generic; using System.Linq; -using Hyak.Common; using Microsoft.Azure.Management.BackupServices.Models; namespace Microsoft.Azure.Management.BackupServices.Models { /// - /// The definition of a Management List Response. + /// The definition of a CSMUpdateProtectionPolicyRequest Request. /// - public partial class JobProperties : Job + public partial class CSMUpdateProtectionPolicyRequest : CSMBaseRequest { - private IDictionary _propertyBag; + private CSMUpdateProtectionPolicyRequestProperties _properties; /// - /// Optional. PropertyBag of JobProperties. + /// Required. CSMUpdateProtectionPolicy Request Properties /// - public IDictionary PropertyBag + public CSMUpdateProtectionPolicyRequestProperties Properties { - get { return this._propertyBag; } - set { this._propertyBag = value; } + get { return this._properties; } + set { this._properties = value; } } - private IList _tasksList; - /// - /// Optional. TasksList of JobProperties. + /// Initializes a new instance of the CSMUpdateProtectionPolicyRequest + /// class. /// - public IList TasksList + public CSMUpdateProtectionPolicyRequest() { - get { return this._tasksList; } - set { this._tasksList = value; } } /// - /// Initializes a new instance of the JobProperties class. + /// Initializes a new instance of the CSMUpdateProtectionPolicyRequest + /// class with required arguments. /// - public JobProperties() + public CSMUpdateProtectionPolicyRequest(CSMUpdateProtectionPolicyRequestProperties properties) + : this() { - this.PropertyBag = new LazyDictionary(); - this.TasksList = new LazyList(); + if (properties == null) + { + throw new ArgumentNullException("properties"); + } + this.Properties = properties; } } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/POQueryParameter.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ContainerQueryParameters.cs similarity index 65% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/POQueryParameter.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ContainerQueryParameters.cs index 28446055df3f6..341642ac7d125 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/POQueryParameter.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ContainerQueryParameters.cs @@ -24,37 +24,45 @@ namespace Microsoft.Azure.Management.BackupServices.Models { - /// - /// The definition of a POQueryParameter object. - /// - public partial class POQueryParameter + public partial class ContainerQueryParameters { - private string _status; + private string _containerType; /// - /// Optional. Status Status of item. + /// Optional. /// - public string Status + public string ContainerType { - get { return this._status; } - set { this._status = value; } + get { return this._containerType; } + set { this._containerType = value; } + } + + private string _friendlyName; + + /// + /// Optional. + /// + public string FriendlyName + { + get { return this._friendlyName; } + set { this._friendlyName = value; } } - private string _type; + private string _status; /// - /// Optional. Type of item. + /// Optional. /// - public string Type + public string Status { - get { return this._type; } - set { this._type = value; } + get { return this._status; } + set { this._status = value; } } /// - /// Initializes a new instance of the POQueryParameter class. + /// Initializes a new instance of the ContainerQueryParameters class. /// - public POQueryParameter() + public ContainerQueryParameters() { } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobListResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ContainerReregistrationState.cs similarity index 67% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobListResponse.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ContainerReregistrationState.cs index efcadd7bc587b..6f5f427999282 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobListResponse.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ContainerReregistrationState.cs @@ -21,31 +21,30 @@ using System; using System.Linq; -using Microsoft.Azure; -using Microsoft.Azure.Management.BackupServices; namespace Microsoft.Azure.Management.BackupServices.Models { /// - /// The response model for the list jobs operation. + /// The definition of a ContainerReregistrationState. /// - public partial class JobListResponse : AzureOperationResponse + public partial class ContainerReregistrationState { - private JobResponse _jobs; + private bool _enableReregistration; /// - /// Optional. The list of jobs queried by filters for the resource id. + /// Optional. Flag to enable container reregistration. /// - public JobResponse Jobs + public bool EnableReregistration { - get { return this._jobs; } - set { this._jobs = value; } + get { return this._enableReregistration; } + set { this._enableReregistration = value; } } /// - /// Initializes a new instance of the JobListResponse class. + /// Initializes a new instance of the ContainerReregistrationState + /// class. /// - public JobListResponse() + public ContainerReregistrationState() { } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/CustomerType.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/CustomerType.cs new file mode 100644 index 0000000000000..815e5ce48e570 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/CustomerType.cs @@ -0,0 +1,43 @@ +// +// 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 +{ + public enum CustomerType + { + Invalid = 0, + + OBS = 1, + + SBS = 2, + + DPM = 4, + + InMage = 8, + + ManagedContainer = 16, + + SqlPaaS = 32, + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/DataSourceListResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/EnableReregistrationRequest.cs similarity index 67% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/DataSourceListResponse.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/EnableReregistrationRequest.cs index 3e61c11cc0c2d..f9d6e230a6a91 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/DataSourceListResponse.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/EnableReregistrationRequest.cs @@ -21,31 +21,30 @@ using System; using System.Linq; -using Microsoft.Azure; using Microsoft.Azure.Management.BackupServices.Models; namespace Microsoft.Azure.Management.BackupServices.Models { /// - /// The response model for the list DataSource operation. + /// Enable MARS Container Reregistration. /// - public partial class DataSourceListResponse : AzureOperationResponse + public partial class EnableReregistrationRequest { - private DataSourceResponse _dataSources; + private ContainerReregistrationState _containerReregistrationState; /// - /// Optional. The list of DataSource for the resource id. + /// Optional. MARS Container Reregistration State. /// - public DataSourceResponse DataSources + public ContainerReregistrationState ContainerReregistrationState { - get { return this._dataSources; } - set { this._dataSources = value; } + get { return this._containerReregistrationState; } + set { this._containerReregistrationState = value; } } /// - /// Initializes a new instance of the DataSourceListResponse class. + /// Initializes a new instance of the EnableReregistrationRequest class. /// - public DataSourceListResponse() + public EnableReregistrationRequest() { } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ErrorInfo.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ErrorInfo.cs deleted file mode 100644 index 4c0e09342ff63..0000000000000 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ErrorInfo.cs +++ /dev/null @@ -1,105 +0,0 @@ -// -// 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.Collections.Generic; -using System.Linq; - -namespace Microsoft.Azure.Management.BackupServices.Models -{ - /// - /// The definition of an ErrorInfo object. - /// - public partial class ErrorInfo - { - private int _errorCode; - - /// - /// Required. Error code for failed job. - /// - public int ErrorCode - { - get { return this._errorCode; } - set { this._errorCode = value; } - } - - private string _errorString; - - /// - /// Required. ErrorString of Job. - /// - public string ErrorString - { - get { return this._errorString; } - set { this._errorString = value; } - } - - private string _errorTitle; - - /// - /// Optional. ErrorTitle of Job. - /// - public string ErrorTitle - { - get { return this._errorTitle; } - set { this._errorTitle = value; } - } - - private IList _recommendations; - - /// - /// Required. Recommendations of Job. - /// - public IList Recommendations - { - get { return this._recommendations; } - set { this._recommendations = value; } - } - - /// - /// Initializes a new instance of the ErrorInfo class. - /// - public ErrorInfo() - { - this.Recommendations = new List(); - } - - /// - /// Initializes a new instance of the ErrorInfo class with required - /// arguments. - /// - public ErrorInfo(int errorCode, string errorString, IList recommendations) - : this() - { - if (errorString == null) - { - throw new ArgumentNullException("errorString"); - } - if (recommendations == null) - { - throw new ArgumentNullException("recommendations"); - } - this.ErrorCode = errorCode; - this.ErrorString = errorString; - this.Recommendations = recommendations; - } - } -} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/Job.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/Job.cs deleted file mode 100644 index a1567b065ec0d..0000000000000 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/Job.cs +++ /dev/null @@ -1,143 +0,0 @@ -// -// 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.Collections.Generic; -using System.Linq; -using Hyak.Common; -using Microsoft.Azure.Management.BackupServices.Models; - -namespace Microsoft.Azure.Management.BackupServices.Models -{ - /// - /// The definition of a Job object. - /// - public partial class Job : ManagementResponseObject - { - private IList _actionsInfo; - - /// - /// Optional. ActionsInfo of Job. - /// - public IList ActionsInfo - { - get { return this._actionsInfo; } - set { this._actionsInfo = value; } - } - - private TimeSpan _duration; - - /// - /// Optional. Duration of Job. - /// - public TimeSpan Duration - { - get { return this._duration; } - set { this._duration = value; } - } - - private DateTime _endTimestamp; - - /// - /// Optional. EndTimestamp of Job. - /// - public DateTime EndTimestamp - { - get { return this._endTimestamp; } - set { this._endTimestamp = value; } - } - - private string _entityFriendlyName; - - /// - /// Required. EntityFriendlyName of Job. - /// - public string EntityFriendlyName - { - get { return this._entityFriendlyName; } - set { this._entityFriendlyName = value; } - } - - private IList _errorDetails; - - /// - /// Optional. ErrorDetails of Job. - /// - public IList ErrorDetails - { - get { return this._errorDetails; } - set { this._errorDetails = value; } - } - - private string _operation; - - /// - /// Required. Operation of Job. - /// - public string Operation - { - get { return this._operation; } - set { this._operation = value; } - } - - private DateTime _startTimestamp; - - /// - /// Required. StartTimestamp of Job. - /// - public DateTime StartTimestamp - { - get { return this._startTimestamp; } - set { this._startTimestamp = value; } - } - - private string _status; - - /// - /// Required. Status of Job. - /// - public string Status - { - get { return this._status; } - set { this._status = value; } - } - - private string _type; - - /// - /// Required. Type of Job. - /// - public string Type - { - get { return this._type; } - set { this._type = value; } - } - - /// - /// Initializes a new instance of the Job class. - /// - public Job() - { - this.ActionsInfo = new LazyList(); - this.ErrorDetails = new List(); - } - } -} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobTaskDetails.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobTaskDetails.cs deleted file mode 100644 index 790818e9975ad..0000000000000 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/JobTaskDetails.cs +++ /dev/null @@ -1,95 +0,0 @@ -// -// 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 JobTaskDetails : ManagementResponseObject - { - private TimeSpan _duration; - - /// - /// Optional. Duration of Subtask. - /// - public TimeSpan Duration - { - get { return this._duration; } - set { this._duration = value; } - } - - private System.DateTime? _endTime; - - /// - /// Required. EndTime of Subtask. - /// - public System.DateTime? EndTime - { - get { return this._endTime; } - set { this._endTime = value; } - } - - private System.DateTime? _startTime; - - /// - /// Required. StartTime of Subtask. - /// - public System.DateTime? StartTime - { - get { return this._startTime; } - set { this._startTime = value; } - } - - private string _status; - - /// - /// Required. Status of Subtask. - /// - public string Status - { - get { return this._status; } - set { this._status = value; } - } - - private string _taskId; - - /// - /// Required. TaskId of Subtask. - /// - public string TaskId - { - get { return this._taskId; } - set { this._taskId = value; } - } - - /// - /// Initializes a new instance of the JobTaskDetails class. - /// - public JobTaskDetails() - { - } - } -} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ProtectableObjectListResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ListMarsContainerOperationResponse.cs similarity index 65% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ProtectableObjectListResponse.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ListMarsContainerOperationResponse.cs index 6bc98178c8d8e..e9cf9fa2659af 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ProtectableObjectListResponse.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ListMarsContainerOperationResponse.cs @@ -27,26 +27,26 @@ namespace Microsoft.Azure.Management.BackupServices.Models { /// - /// The response model for the list ProtectableObject operation. + /// List of Microsoft Azure Recovery Services (MARS) containers. /// - public partial class ProtectableObjectListResponse : AzureOperationResponse + public partial class ListMarsContainerOperationResponse : AzureOperationResponse { - private ProtectableObjectResponse _protectableObject; + private ListMarsContainerResponse _listMarsContainerResponse; /// - /// Optional. The list of ProtectableObject for the resource id. + /// Optional. MARS Container List Response. /// - public ProtectableObjectResponse ProtectableObject + public ListMarsContainerResponse ListMarsContainerResponse { - get { return this._protectableObject; } - set { this._protectableObject = value; } + get { return this._listMarsContainerResponse; } + set { this._listMarsContainerResponse = value; } } /// - /// Initializes a new instance of the ProtectableObjectListResponse - /// class. + /// Initializes a new instance of the + /// ListMarsContainerOperationResponse class. /// - public ProtectableObjectListResponse() + public ListMarsContainerOperationResponse() { } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/RecoveryPointListResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ListMarsContainerResponse.cs similarity index 66% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/RecoveryPointListResponse.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ListMarsContainerResponse.cs index 6a98291c8e79d..fa4d5ff91c525 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/RecoveryPointListResponse.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/ListMarsContainerResponse.cs @@ -20,33 +20,35 @@ // code is regenerated. using System; +using System.Collections.Generic; using System.Linq; -using Microsoft.Azure; +using Hyak.Common; using Microsoft.Azure.Management.BackupServices.Models; namespace Microsoft.Azure.Management.BackupServices.Models { /// - /// The response model for the list RecoveryPoints operation. + /// The definition of a ListMarsContainerResponse. /// - public partial class RecoveryPointListResponse : AzureOperationResponse + public partial class ListMarsContainerResponse : BackupListResponse { - private RecoveryPointInfoResponse _recoveryPoints; + private IList _value; /// - /// Optional. The list of RecoveryPoints for the resource id. + /// Optional. List of MARS container responses. /// - public RecoveryPointInfoResponse RecoveryPoints + public IList Value { - get { return this._recoveryPoints; } - set { this._recoveryPoints = value; } + get { return this._value; } + set { this._value = value; } } /// - /// Initializes a new instance of the RecoveryPointListResponse class. + /// Initializes a new instance of the ListMarsContainerResponse class. /// - public RecoveryPointListResponse() + public ListMarsContainerResponse() { + this.Value = new LazyList(); } } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/MarsContainerProperties.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/MarsContainerProperties.cs new file mode 100644 index 0000000000000..5c51e5b97bcd3 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/MarsContainerProperties.cs @@ -0,0 +1,105 @@ +// +// 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 MarsContainerProperties. + /// + public partial class MarsContainerProperties + { + private bool _canReRegister; + + /// + /// Optional. MARS Container Re-registrablity Flag + /// + public bool CanReRegister + { + get { return this._canReRegister; } + set { this._canReRegister = value; } + } + + private long _containerId; + + /// + /// Optional. MARS Container ID + /// + public long ContainerId + { + get { return this._containerId; } + set { this._containerId = value; } + } + + private Guid _containerStampId; + + /// + /// Optional. MARS Container Stamp ID + /// + public Guid ContainerStampId + { + get { return this._containerStampId; } + set { this._containerStampId = value; } + } + + private string _containerStampUri; + + /// + /// Optional. MARS Container Stamp URI + /// + public string ContainerStampUri + { + get { return this._containerStampUri; } + set { this._containerStampUri = value; } + } + + private string _customerType; + + /// + /// Optional. MARS Container Customer Type + /// + public string CustomerType + { + get { return this._customerType; } + set { this._customerType = value; } + } + + private string _friendlyName; + + /// + /// Optional. MARS Container Friendly Name + /// + public string FriendlyName + { + get { return this._friendlyName; } + set { this._friendlyName = value; } + } + + /// + /// Initializes a new instance of the MarsContainerProperties class. + /// + public MarsContainerProperties() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/RecoveryPointInfo.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/MarsContainerResponse.cs similarity index 55% rename from src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/RecoveryPointInfo.cs rename to src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/MarsContainerResponse.cs index 090b2b9e3c62d..641f922fa6ec5 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/RecoveryPointInfo.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/MarsContainerResponse.cs @@ -26,47 +26,47 @@ namespace Microsoft.Azure.Management.BackupServices.Models { /// - /// The definition of a RecoveryPoint Info object. + /// The definition of a MarsContainerResponse. /// - public partial class RecoveryPointInfo : ManagementResponseObject + public partial class MarsContainerResponse : BackupBaseResponse { - private string _recoveryPointAdditionalInfo; + private string _containerType; /// - /// Optional. RecoveryPointAdditionalInfo of RecoveryPointInfo. + /// Optional. MARS Container Friendly Name /// - public string RecoveryPointAdditionalInfo + public string ContainerType { - get { return this._recoveryPointAdditionalInfo; } - set { this._recoveryPointAdditionalInfo = value; } + get { return this._containerType; } + set { this._containerType = value; } } - private DateTime _recoveryPointTime; + private MarsContainerProperties _properties; /// - /// Optional. RecoveryPointTime of RecoveryPointInfo. + /// Optional. MARS Container Properties /// - public DateTime RecoveryPointTime + public MarsContainerProperties Properties { - get { return this._recoveryPointTime; } - set { this._recoveryPointTime = value; } + get { return this._properties; } + set { this._properties = value; } } - private string _recoveryPointType; + private string _uniqueName; /// - /// Optional. RecoveryPointType of RecoveryPointInfo. + /// Optional. MARS Container Unique Name /// - public string RecoveryPointType + public string UniqueName { - get { return this._recoveryPointType; } - set { this._recoveryPointType = value; } + get { return this._uniqueName; } + set { this._uniqueName = value; } } /// - /// Initializes a new instance of the RecoveryPointInfo class. + /// Initializes a new instance of the MarsContainerResponse class. /// - public RecoveryPointInfo() + public MarsContainerResponse() { } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/MarsContainerType.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/MarsContainerType.cs new file mode 100644 index 0000000000000..7630803e3ea1e --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/MarsContainerType.cs @@ -0,0 +1,33 @@ +// +// 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 +{ + public enum MarsContainerType + { + Invalid = 0, + + Machine = 1, + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/RecoveryPointInfoResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/RecoveryPointInfoResponse.cs deleted file mode 100644 index ea03cea8fd8b7..0000000000000 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/Models/RecoveryPointInfoResponse.cs +++ /dev/null @@ -1,92 +0,0 @@ -// -// 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.Collections.Generic; -using System.Linq; -using Hyak.Common; -using Microsoft.Azure.Management.BackupServices.Models; - -namespace Microsoft.Azure.Management.BackupServices.Models -{ - /// - /// The definition of a Recovery Point Info Response. - /// - public partial class RecoveryPointInfoResponse : ManagementBaseObject, IEnumerable - { - private IList _objects; - - /// - /// Optional. The definition of List of ProtectionPolicyInfo. - /// - public IList Objects - { - get { return this._objects; } - set { this._objects = value; } - } - - private int _resultCount; - - /// - /// Optional. The definition of ResultCount. - /// - public int ResultCount - { - get { return this._resultCount; } - set { this._resultCount = value; } - } - - private string _skiptoken; - - /// - /// Optional. The definition of Skiptoken. - /// - public string Skiptoken - { - get { return this._skiptoken; } - set { this._skiptoken = value; } - } - - /// - /// Initializes a new instance of the RecoveryPointInfoResponse class. - /// - public RecoveryPointInfoResponse() - { - this.Objects = new LazyList(); - } - - /// - /// Gets the sequence of Objects. - /// - public IEnumerator GetEnumerator() - { - return this.Objects.GetEnumerator(); - } - - /// - /// Gets the sequence of Objects. - /// - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return this.GetEnumerator(); - } - } -} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/OperationResultResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/OperationResultResponse.cs deleted file mode 100644 index ef86a43abda8a..0000000000000 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/OperationResultResponse.cs +++ /dev/null @@ -1,98 +0,0 @@ -// -// 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.Collections.Generic; -using System.Linq; -using Hyak.Common; -using Microsoft.Azure; - -namespace Microsoft.Azure.Management.BackupServices -{ - /// - /// The definition of a BMSOperationStatusResponse. - /// - public partial class OperationResultResponse : AzureOperationResponse - { - private string _errorCode; - - /// - /// Optional. Error Code - /// - public string ErrorCode - { - get { return this._errorCode; } - set { this._errorCode = value; } - } - - private IList _jobs; - - /// - /// Optional. ID of jobs created by this operation - /// - public IList Jobs - { - get { return this._jobs; } - set { this._jobs = value; } - } - - private string _message; - - /// - /// Optional. Message - /// - public string Message - { - get { return this._message; } - set { this._message = value; } - } - - private string _operationResult; - - /// - /// Optional. Operation Result. - /// - public string OperationResult - { - get { return this._operationResult; } - set { this._operationResult = value; } - } - - private string _operationStatus; - - /// - /// Optional. Operation Status. - /// - public string OperationStatus - { - get { return this._operationStatus; } - set { this._operationStatus = value; } - } - - /// - /// Initializes a new instance of the OperationResultResponse class. - /// - public OperationResultResponse() - { - this.Jobs = new LazyList(); - } - } -} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/OperationStatus.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/OperationStatus.cs index 0fbd72697b376..d564f8b601d3b 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/OperationStatus.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/OperationStatus.cs @@ -97,7 +97,7 @@ public async Task CSMGetAsync(string operationId, CustomRequ // Construct URL string url = ""; - url = url + "/Subscriptions/"; + url = url + "/subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); @@ -110,7 +110,7 @@ public async Task CSMGetAsync(string operationId, CustomRequ url = url + "BackupVault"; url = url + "/"; url = url + Uri.EscapeDataString(this.Client.ResourceName); - url = url + "/operations/"; + url = url + "/operationResults/"; url = url + Uri.EscapeDataString(operationId); List queryParameters = new List(); queryParameters.Add("api-version=2014-09-01"); diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ProtectableObjectOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ProtectableObjectOperations.cs index 11ca16a10697f..8c017e8330537 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ProtectableObjectOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagement/Generated/ProtectableObjectOperations.cs @@ -94,7 +94,7 @@ public async Task ListCSMAsync(CSMItemQueryObject // Construct URL string url = ""; - url = url + "/Subscriptions/"; + url = url + "/subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); @@ -110,8 +110,19 @@ public async Task ListCSMAsync(CSMItemQueryObject url = url + "/items"; List queryParameters = new List(); queryParameters.Add("api-version=2014-09-01"); - queryParameters.Add("Status -eq csmparameters.Status}"); - queryParameters.Add("Type -eq csmparameters.Type}"); + List odataFilter = new List(); + if (csmparameters != null && csmparameters.Status != null) + { + odataFilter.Add("status eq '" + Uri.EscapeDataString(csmparameters.Status) + "'"); + } + if (csmparameters != null && csmparameters.Type != null) + { + odataFilter.Add("itemType eq '" + Uri.EscapeDataString(csmparameters.Type) + "'"); + } + if (odataFilter.Count > 0) + { + queryParameters.Add("$filter=" + string.Join(" and ", odataFilter)); + } if (queryParameters.Count > 0) { url = url + "?" + string.Join("&", queryParameters);