// 
// 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.WindowsAzure.Management.SiteRecovery;
using Microsoft.WindowsAzure.Management.SiteRecovery.Models;

namespace Microsoft.WindowsAzure
{
    public static partial class ProtectionEntityOperationsExtensions
    {
        /// <summary>
        /// Commit failover of a protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static JobResponse CommitFailover(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, CustomRequestHeaders customRequestHeaders)
        {
            return Task.Factory.StartNew((object s) => 
            {
                return ((IProtectionEntityOperations)s).CommitFailoverAsync(protectionContainerId, protectionEntityId, customRequestHeaders);
            }
            , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
        }
        
        /// <summary>
        /// Commit failover of a protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static Task<JobResponse> CommitFailoverAsync(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, CustomRequestHeaders customRequestHeaders)
        {
            return operations.CommitFailoverAsync(protectionContainerId, protectionEntityId, customRequestHeaders, CancellationToken.None);
        }
        
        /// <summary>
        /// Disable Protection for the given protection enity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static JobResponse DisableProtection(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, CustomRequestHeaders customRequestHeaders)
        {
            return Task.Factory.StartNew((object s) => 
            {
                return ((IProtectionEntityOperations)s).DisableProtectionAsync(protectionContainerId, protectionEntityId, customRequestHeaders);
            }
            , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
        }
        
        /// <summary>
        /// Disable Protection for the given protection enity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static Task<JobResponse> DisableProtectionAsync(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, CustomRequestHeaders customRequestHeaders)
        {
            return operations.DisableProtectionAsync(protectionContainerId, protectionEntityId, customRequestHeaders, CancellationToken.None);
        }
        
        /// <summary>
        /// Enable Protection for the given protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static JobResponse EnableProtection(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, CustomRequestHeaders customRequestHeaders)
        {
            return Task.Factory.StartNew((object s) => 
            {
                return ((IProtectionEntityOperations)s).EnableProtectionAsync(protectionContainerId, protectionEntityId, customRequestHeaders);
            }
            , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
        }
        
        /// <summary>
        /// Enable Protection for the given protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static Task<JobResponse> EnableProtectionAsync(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, CustomRequestHeaders customRequestHeaders)
        {
            return operations.EnableProtectionAsync(protectionContainerId, protectionEntityId, customRequestHeaders, CancellationToken.None);
        }
        
        /// <summary>
        /// Get the protection entity object by Id.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Vm object.
        /// </returns>
        public static ProtectionEntityResponse Get(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, CustomRequestHeaders customRequestHeaders)
        {
            return Task.Factory.StartNew((object s) => 
            {
                return ((IProtectionEntityOperations)s).GetAsync(protectionContainerId, protectionEntityId, customRequestHeaders);
            }
            , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
        }
        
        /// <summary>
        /// Get the protection entity object by Id.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Vm object.
        /// </returns>
        public static Task<ProtectionEntityResponse> GetAsync(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, CustomRequestHeaders customRequestHeaders)
        {
            return operations.GetAsync(protectionContainerId, protectionEntityId, customRequestHeaders, CancellationToken.None);
        }
        
        /// <summary>
        /// Get the list of all protection entities.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the list Vm operation.
        /// </returns>
        public static ProtectionEntityListResponse List(this IProtectionEntityOperations operations, string protectionContainerId, CustomRequestHeaders customRequestHeaders)
        {
            return Task.Factory.StartNew((object s) => 
            {
                return ((IProtectionEntityOperations)s).ListAsync(protectionContainerId, customRequestHeaders);
            }
            , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
        }
        
        /// <summary>
        /// Get the list of all protection entities.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the list Vm operation.
        /// </returns>
        public static Task<ProtectionEntityListResponse> ListAsync(this IProtectionEntityOperations operations, string protectionContainerId, CustomRequestHeaders customRequestHeaders)
        {
            return operations.ListAsync(protectionContainerId, customRequestHeaders, CancellationToken.None);
        }
        
        /// <summary>
        /// Planned failover of a protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='parameters'>
        /// Required. Planned failover request.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static JobResponse PlannedFailover(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, PlannedFailoverRequest parameters, CustomRequestHeaders customRequestHeaders)
        {
            return Task.Factory.StartNew((object s) => 
            {
                return ((IProtectionEntityOperations)s).PlannedFailoverAsync(protectionContainerId, protectionEntityId, parameters, customRequestHeaders);
            }
            , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
        }
        
        /// <summary>
        /// Planned failover of a protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='parameters'>
        /// Required. Planned failover request.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static Task<JobResponse> PlannedFailoverAsync(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, PlannedFailoverRequest parameters, CustomRequestHeaders customRequestHeaders)
        {
            return operations.PlannedFailoverAsync(protectionContainerId, protectionEntityId, parameters, customRequestHeaders, CancellationToken.None);
        }
        
        /// <summary>
        /// Reprotect operation for the given protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='parameters'>
        /// Required. Reprotect request after failover.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static JobResponse Reprotect(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, ReprotectRequest parameters, CustomRequestHeaders customRequestHeaders)
        {
            return Task.Factory.StartNew((object s) => 
            {
                return ((IProtectionEntityOperations)s).ReprotectAsync(protectionContainerId, protectionEntityId, parameters, customRequestHeaders);
            }
            , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
        }
        
        /// <summary>
        /// Reprotect operation for the given protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='parameters'>
        /// Required. Reprotect request after failover.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static Task<JobResponse> ReprotectAsync(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, ReprotectRequest parameters, CustomRequestHeaders customRequestHeaders)
        {
            return operations.ReprotectAsync(protectionContainerId, protectionEntityId, parameters, customRequestHeaders, CancellationToken.None);
        }
        
        /// <summary>
        /// Test failover of a protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='parameters'>
        /// Required. Test failover request.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static JobResponse TestFailover(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, TestFailoverRequest parameters, CustomRequestHeaders customRequestHeaders)
        {
            return Task.Factory.StartNew((object s) => 
            {
                return ((IProtectionEntityOperations)s).TestFailoverAsync(protectionContainerId, protectionEntityId, parameters, customRequestHeaders);
            }
            , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
        }
        
        /// <summary>
        /// Test failover of a protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='parameters'>
        /// Required. Test failover request.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static Task<JobResponse> TestFailoverAsync(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, TestFailoverRequest parameters, CustomRequestHeaders customRequestHeaders)
        {
            return operations.TestFailoverAsync(protectionContainerId, protectionEntityId, parameters, customRequestHeaders, CancellationToken.None);
        }
        
        /// <summary>
        /// Unplanned failover of a protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='parameters'>
        /// Required. Planned failover request.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static JobResponse UnplannedFailover(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, UnplannedFailoverRequest parameters, CustomRequestHeaders customRequestHeaders)
        {
            return Task.Factory.StartNew((object s) => 
            {
                return ((IProtectionEntityOperations)s).UnplannedFailoverAsync(protectionContainerId, protectionEntityId, parameters, customRequestHeaders);
            }
            , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
        }
        
        /// <summary>
        /// Unplanned failover of a protection entity.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.WindowsAzure.Management.SiteRecovery.IProtectionEntityOperations.
        /// </param>
        /// <param name='protectionContainerId'>
        /// Required. Parent Protection Container ID.
        /// </param>
        /// <param name='protectionEntityId'>
        /// Required. Protection entity ID.
        /// </param>
        /// <param name='parameters'>
        /// Required. Planned failover request.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <returns>
        /// The response model for the Job details object.
        /// </returns>
        public static Task<JobResponse> UnplannedFailoverAsync(this IProtectionEntityOperations operations, string protectionContainerId, string protectionEntityId, UnplannedFailoverRequest parameters, CustomRequestHeaders customRequestHeaders)
        {
            return operations.UnplannedFailoverAsync(protectionContainerId, protectionEntityId, parameters, customRequestHeaders, CancellationToken.None);
        }
    }
}
