// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.

namespace Microsoft.Azure.Management.RecoveryServices.Backup
{
    using System.Threading.Tasks;
   using Microsoft.Rest.Azure;
   using Models;

    /// <summary>
    /// Extension methods for ProtectionPolicyOperationStatusesOperations.
    /// </summary>
    public static partial class ProtectionPolicyOperationStatusesOperationsExtensions
    {
            /// <summary>
            /// Provides the status of the asynchronous operations like backup, restore.
            /// The status can be in progress, completed or failed. You can refer to the
            /// Operation Status enum for all the possible states of an operation. Some
            /// operations create jobs. This method returns the list of jobs associated
            /// with operation.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='vaultName'>
            /// The name of the recovery services vault.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group where the recovery services vault is
            /// present.
            /// </param>
            /// <param name='policyName'>
            /// Backup policy name whose operation's status needs to be fetched.
            /// </param>
            /// <param name='operationId'>
            /// Operation ID which represents an operation whose status needs to be
            /// fetched.
            /// </param>
            public static OperationStatus Get(this IProtectionPolicyOperationStatusesOperations operations, string vaultName, string resourceGroupName, string policyName, string operationId)
            {
                return System.Threading.Tasks.Task.Factory.StartNew(s => ((IProtectionPolicyOperationStatusesOperations)s).GetAsync(vaultName, resourceGroupName, policyName, operationId), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
            }

            /// <summary>
            /// Provides the status of the asynchronous operations like backup, restore.
            /// The status can be in progress, completed or failed. You can refer to the
            /// Operation Status enum for all the possible states of an operation. Some
            /// operations create jobs. This method returns the list of jobs associated
            /// with operation.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='vaultName'>
            /// The name of the recovery services vault.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group where the recovery services vault is
            /// present.
            /// </param>
            /// <param name='policyName'>
            /// Backup policy name whose operation's status needs to be fetched.
            /// </param>
            /// <param name='operationId'>
            /// Operation ID which represents an operation whose status needs to be
            /// fetched.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async System.Threading.Tasks.Task<OperationStatus> GetAsync(this IProtectionPolicyOperationStatusesOperations operations, string vaultName, string resourceGroupName, string policyName, string operationId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
            {
                using (var _result = await operations.GetWithHttpMessagesAsync(vaultName, resourceGroupName, policyName, operationId, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

    }
}
