// 
// 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.RecoveryServices.Backup;
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;

namespace Microsoft.Azure.Management.RecoveryServices.Backup
{
    public static partial class RestoreOperationsExtensions
    {
        /// <summary>
        /// The Trigger Restore Operation starts an operation in the service
        /// which triggers the restore of the specified item in the specified
        /// container in your Recovery Services Vault based on the specified
        /// recovery point ID. This is an asynchronous operation. To determine
        /// whether the backend service has finished processing the request,
        /// call Get Protected Item Operation Result API.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.Azure.Management.RecoveryServices.Backup.IRestoreOperations.
        /// </param>
        /// <param name='resourceGroupName'>
        /// Required. Resource group name of your recovery services vault.
        /// </param>
        /// <param name='resourceName'>
        /// Required. Name of your recovery services vault.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <param name='fabricName'>
        /// Optional. Fabric name of the protected item.
        /// </param>
        /// <param name='containerName'>
        /// Optional. Name of the container where the protected item belongs to.
        /// </param>
        /// <param name='protectedItemName'>
        /// Optional. Name of the protected item whose recovery points are to
        /// be fetched.
        /// </param>
        /// <param name='recoveryPointId'>
        /// Optional. ID of the recovery point whose details are to be fetched.
        /// </param>
        /// <param name='request'>
        /// Optional. Restore request for the backup item.
        /// </param>
        /// <returns>
        /// Base recovery job response for all the asynchronous operations.
        /// </returns>
        public static BaseRecoveryServicesJobResponse TriggerRestore(this IRestoreOperations operations, string resourceGroupName, string resourceName, CustomRequestHeaders customRequestHeaders, string fabricName, string containerName, string protectedItemName, string recoveryPointId, TriggerRestoreRequest request)
        {
            return Task.Factory.StartNew((object s) => 
            {
                return ((IRestoreOperations)s).TriggerRestoreAsync(resourceGroupName, resourceName, customRequestHeaders, fabricName, containerName, protectedItemName, recoveryPointId, request);
            }
            , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
        }
        
        /// <summary>
        /// The Trigger Restore Operation starts an operation in the service
        /// which triggers the restore of the specified item in the specified
        /// container in your Recovery Services Vault based on the specified
        /// recovery point ID. This is an asynchronous operation. To determine
        /// whether the backend service has finished processing the request,
        /// call Get Protected Item Operation Result API.
        /// </summary>
        /// <param name='operations'>
        /// Reference to the
        /// Microsoft.Azure.Management.RecoveryServices.Backup.IRestoreOperations.
        /// </param>
        /// <param name='resourceGroupName'>
        /// Required. Resource group name of your recovery services vault.
        /// </param>
        /// <param name='resourceName'>
        /// Required. Name of your recovery services vault.
        /// </param>
        /// <param name='customRequestHeaders'>
        /// Optional. Request header parameters.
        /// </param>
        /// <param name='fabricName'>
        /// Optional. Fabric name of the protected item.
        /// </param>
        /// <param name='containerName'>
        /// Optional. Name of the container where the protected item belongs to.
        /// </param>
        /// <param name='protectedItemName'>
        /// Optional. Name of the protected item whose recovery points are to
        /// be fetched.
        /// </param>
        /// <param name='recoveryPointId'>
        /// Optional. ID of the recovery point whose details are to be fetched.
        /// </param>
        /// <param name='request'>
        /// Optional. Restore request for the backup item.
        /// </param>
        /// <returns>
        /// Base recovery job response for all the asynchronous operations.
        /// </returns>
        public static Task<BaseRecoveryServicesJobResponse> TriggerRestoreAsync(this IRestoreOperations operations, string resourceGroupName, string resourceName, CustomRequestHeaders customRequestHeaders, string fabricName, string containerName, string protectedItemName, string recoveryPointId, TriggerRestoreRequest request)
        {
            return operations.TriggerRestoreAsync(resourceGroupName, resourceName, customRequestHeaders, fabricName, containerName, protectedItemName, recoveryPointId, request, CancellationToken.None);
        }
    }
}
