/// <summary>
 /// Enable the container reregistration.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.BackupServices.IContainerOperations.
 /// </param>
 /// <param name='containerId'>
 /// Required. MARS container ID.
 /// </param>
 /// <param name='enableReregistrationRequest'>
 /// Required. Enable Reregistration Request.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// The definition of a Operation Response.
 /// </returns>
 public static OperationResponse EnableMarsContainerReregistration(this IContainerOperations operations, string containerId, EnableReregistrationRequest enableReregistrationRequest, CustomRequestHeaders customRequestHeaders)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IContainerOperations)s).EnableMarsContainerReregistrationAsync(containerId, enableReregistrationRequest, customRequestHeaders);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
        /// <summary>
        /// Enable container reregistration
        /// </summary>
        /// <param name="containerId"></param>
        /// <returns></returns>
        public void EnableMachineContainerReregistration(string resourceGroupName, string resourceName, long containerId)
        {
            EnableReregistrationRequest request = new EnableReregistrationRequest()
            {
                ContainerReregistrationState = new ContainerReregistrationState()
                {
                    EnableReregistration = true,
                },
            };

            AzureBackupVaultClient.Container.EnableMarsContainerReregistration(resourceGroupName, resourceName, containerId.ToString(), request, GetCustomRequestHeaders());
        }
        void EnableContainerReregistrationSetsReregisterFlag()
        {
            using (UndoContext undoContext = UndoContext.Current)
            {
                undoContext.Start();

                BackupVaultServicesManagementClient client = GetServiceClient<BackupVaultServicesManagementClient>();
                string containerId = ConfigurationManager.AppSettings["ContainerId"];
                string friendlyName = ConfigurationManager.AppSettings["ContainerFriendlyName"];

                EnableReregistrationRequest request = new EnableReregistrationRequest()
                {
                    ContainerReregistrationState = new ContainerReregistrationState()
                    {
                        EnableReregistration = true,
                    },
                };

                OperationResponse response = client.Container.EnableMarsContainerReregistration(BackupServicesTestsBase.ResourceGroupName, BackupServicesTestsBase.ResourceName, containerId, request, GetCustomRequestHeaders());
                // Response Validation
                Assert.NotNull(response);
                Assert.True(response.StatusCode == HttpStatusCode.NoContent, "Status code should be NoContent");

                // Basic Validation
                ListMarsContainerOperationResponse getResponse = client.Container.ListMarsContainersByTypeAndFriendlyName(BackupServicesTestsBase.ResourceGroupName, BackupServicesTestsBase.ResourceName, MarsContainerType.Machine, friendlyName, GetCustomRequestHeaders());
                Assert.True(getResponse.ListMarsContainerResponse.Value.Any(marsContainer =>
                {
                    return marsContainer.ContainerType == MarsContainerType.Machine.ToString() &&
                           marsContainer.Properties != null &&
                           string.Equals(marsContainer.Properties.FriendlyName, friendlyName, StringComparison.OrdinalIgnoreCase) &&
                           marsContainer.Properties.CanReRegister == true;
                }), "Reregistration doesn't appear to have been enabled for the input container");
            }
        }
 /// <summary>
 /// Enable the container reregistration.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.BackupServices.IContainerOperations.
 /// </param>
 /// <param name='containerId'>
 /// Required. MARS container ID.
 /// </param>
 /// <param name='enableReregistrationRequest'>
 /// Required. Enable Reregistration Request.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// The definition of a Operation Response.
 /// </returns>
 public static Task<OperationResponse> EnableMarsContainerReregistrationAsync(this IContainerOperations operations, string containerId, EnableReregistrationRequest enableReregistrationRequest, CustomRequestHeaders customRequestHeaders)
 {
     return operations.EnableMarsContainerReregistrationAsync(containerId, enableReregistrationRequest, customRequestHeaders, CancellationToken.None);
 }