// Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.

namespace Microsoft.Azure.Management.Batch
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;
    using Microsoft.Rest;
    using Microsoft.Rest.Azure;
    using Models;

    /// <summary>
    /// Extension methods for ApplicationOperations.
    /// </summary>
    public static partial class ApplicationOperationsExtensions
    {
            /// <summary>
            /// Activates the specified application package.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='id'>
            /// The id of the application.
            /// </param>
            /// <param name='version'>
            /// The version of the application to activate.
            /// </param>
            /// <param name='parameters'>
            /// The parameters for the request.
            /// </param>
            public static void ActivateApplicationPackage(this IApplicationOperations operations, string resourceGroupName, string accountName, string id, string version, ActivateApplicationPackageParameters parameters)
            {
                Task.Factory.StartNew(s => ((IApplicationOperations)s).ActivateApplicationPackageAsync(resourceGroupName, accountName, id, version, parameters), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
            }

            /// <summary>
            /// Activates the specified application package.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='id'>
            /// The id of the application.
            /// </param>
            /// <param name='version'>
            /// The version of the application to activate.
            /// </param>
            /// <param name='parameters'>
            /// The parameters for the request.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task ActivateApplicationPackageAsync(this IApplicationOperations operations, string resourceGroupName, string accountName, string id, string version, ActivateApplicationPackageParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
            {
                await operations.ActivateApplicationPackageWithHttpMessagesAsync(resourceGroupName, accountName, id, version, parameters, null, cancellationToken).ConfigureAwait(false);
            }

            /// <summary>
            /// Adds an application to the specified Batch account.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='parameters'>
            /// The parameters for the request.
            /// </param>
            public static Application AddApplication(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, AddApplicationParameters parameters = default(AddApplicationParameters))
            {
                return Task.Factory.StartNew(s => ((IApplicationOperations)s).AddApplicationAsync(resourceGroupName, accountName, applicationId, parameters), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
            }

            /// <summary>
            /// Adds an application to the specified Batch account.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='parameters'>
            /// The parameters for the request.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<Application> AddApplicationAsync(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, AddApplicationParameters parameters = default(AddApplicationParameters), CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.AddApplicationWithHttpMessagesAsync(resourceGroupName, accountName, applicationId, parameters, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Deletes an application.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            public static void DeleteApplication(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId)
            {
                Task.Factory.StartNew(s => ((IApplicationOperations)s).DeleteApplicationAsync(resourceGroupName, accountName, applicationId), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
            }

            /// <summary>
            /// Deletes an application.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task DeleteApplicationAsync(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, CancellationToken cancellationToken = default(CancellationToken))
            {
                await operations.DeleteApplicationWithHttpMessagesAsync(resourceGroupName, accountName, applicationId, null, cancellationToken).ConfigureAwait(false);
            }

            /// <summary>
            /// Gets information about the specified application.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            public static Application GetApplication(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId)
            {
                return Task.Factory.StartNew(s => ((IApplicationOperations)s).GetApplicationAsync(resourceGroupName, accountName, applicationId), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
            }

            /// <summary>
            /// Gets information about the specified application.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<Application> GetApplicationAsync(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.GetApplicationWithHttpMessagesAsync(resourceGroupName, accountName, applicationId, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Updates settings for the specified application.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='parameters'>
            /// The parameters for the request.
            /// </param>
            public static void UpdateApplication(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, UpdateApplicationParameters parameters)
            {
                Task.Factory.StartNew(s => ((IApplicationOperations)s).UpdateApplicationAsync(resourceGroupName, accountName, applicationId, parameters), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
            }

            /// <summary>
            /// Updates settings for the specified application.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='parameters'>
            /// The parameters for the request.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task UpdateApplicationAsync(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, UpdateApplicationParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
            {
                await operations.UpdateApplicationWithHttpMessagesAsync(resourceGroupName, accountName, applicationId, parameters, null, cancellationToken).ConfigureAwait(false);
            }

            /// <summary>
            /// Creates an application package record.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='version'>
            /// The version of the application.
            /// </param>
            public static AddApplicationPackageResult AddApplicationPackage(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, string version)
            {
                return Task.Factory.StartNew(s => ((IApplicationOperations)s).AddApplicationPackageAsync(resourceGroupName, accountName, applicationId, version), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
            }

            /// <summary>
            /// Creates an application package record.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='version'>
            /// The version of the application.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<AddApplicationPackageResult> AddApplicationPackageAsync(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, string version, CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.AddApplicationPackageWithHttpMessagesAsync(resourceGroupName, accountName, applicationId, version, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Deletes an application package record and its associated binary file.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='version'>
            /// The version of the application to delete.
            /// </param>
            public static void DeleteApplicationPackage(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, string version)
            {
                Task.Factory.StartNew(s => ((IApplicationOperations)s).DeleteApplicationPackageAsync(resourceGroupName, accountName, applicationId, version), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
            }

            /// <summary>
            /// Deletes an application package record and its associated binary file.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='version'>
            /// The version of the application to delete.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task DeleteApplicationPackageAsync(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, string version, CancellationToken cancellationToken = default(CancellationToken))
            {
                await operations.DeleteApplicationPackageWithHttpMessagesAsync(resourceGroupName, accountName, applicationId, version, null, cancellationToken).ConfigureAwait(false);
            }

            /// <summary>
            /// Gets information about the specified application package.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='version'>
            /// The version of the application.
            /// </param>
            public static GetApplicationPackageResult GetApplicationPackage(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, string version)
            {
                return Task.Factory.StartNew(s => ((IApplicationOperations)s).GetApplicationPackageAsync(resourceGroupName, accountName, applicationId, version), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
            }

            /// <summary>
            /// Gets information about the specified application package.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='applicationId'>
            /// The id of the application.
            /// </param>
            /// <param name='version'>
            /// The version of the application.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<GetApplicationPackageResult> GetApplicationPackageAsync(this IApplicationOperations operations, string resourceGroupName, string accountName, string applicationId, string version, CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.GetApplicationPackageWithHttpMessagesAsync(resourceGroupName, accountName, applicationId, version, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Lists all of the applications in the specified account.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='maxresults'>
            /// The maximum number of items to return in the response.
            /// </param>
            public static IPage<Application> List(this IApplicationOperations operations, string resourceGroupName, string accountName, int? maxresults = default(int?))
            {
                return Task.Factory.StartNew(s => ((IApplicationOperations)s).ListAsync(resourceGroupName, accountName, maxresults), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
            }

            /// <summary>
            /// Lists all of the applications in the specified account.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='resourceGroupName'>
            /// The name of the resource group that contains the Batch account.
            /// </param>
            /// <param name='accountName'>
            /// The name of the Batch account.
            /// </param>
            /// <param name='maxresults'>
            /// The maximum number of items to return in the response.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<IPage<Application>> ListAsync(this IApplicationOperations operations, string resourceGroupName, string accountName, int? maxresults = default(int?), CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, accountName, maxresults, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Lists all of the applications in the specified account.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='nextPageLink'>
            /// The NextLink from the previous successful call to List operation.
            /// </param>
            public static IPage<Application> ListNext(this IApplicationOperations operations, string nextPageLink)
            {
                return Task.Factory.StartNew(s => ((IApplicationOperations)s).ListNextAsync(nextPageLink), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
            }

            /// <summary>
            /// Lists all of the applications in the specified account.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='nextPageLink'>
            /// The NextLink from the previous successful call to List operation.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<IPage<Application>> ListNextAsync(this IApplicationOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

    }
}
