// <auto-generated>
// 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.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>

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

    /// <summary>
    /// Extension methods for LongTermRetentionBackupsOperations.
    /// </summary>
    public static partial class LongTermRetentionBackupsOperationsExtensions
    {
            /// <summary>
            /// Gets a long term retention backup.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database.
            /// </param>
            /// <param name='longTermRetentionServerName'>
            /// The name of the server
            /// </param>
            /// <param name='longTermRetentionDatabaseName'>
            /// The name of the database
            /// </param>
            /// <param name='backupName'>
            /// The backup name.
            /// </param>
            public static LongTermRetentionBackup Get(this ILongTermRetentionBackupsOperations operations, string locationName, string longTermRetentionServerName, string longTermRetentionDatabaseName, string backupName)
            {
                return operations.GetAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Gets a long term retention backup.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database.
            /// </param>
            /// <param name='longTermRetentionServerName'>
            /// The name of the server
            /// </param>
            /// <param name='longTermRetentionDatabaseName'>
            /// The name of the database
            /// </param>
            /// <param name='backupName'>
            /// The backup name.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<LongTermRetentionBackup> GetAsync(this ILongTermRetentionBackupsOperations operations, string locationName, string longTermRetentionServerName, string longTermRetentionDatabaseName, string backupName, CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.GetWithHttpMessagesAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Deletes a long term retention backup.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database
            /// </param>
            /// <param name='longTermRetentionServerName'>
            /// The name of the server
            /// </param>
            /// <param name='longTermRetentionDatabaseName'>
            /// The name of the database
            /// </param>
            /// <param name='backupName'>
            /// The backup name.
            /// </param>
            public static void Delete(this ILongTermRetentionBackupsOperations operations, string locationName, string longTermRetentionServerName, string longTermRetentionDatabaseName, string backupName)
            {
                operations.DeleteAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Deletes a long term retention backup.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database
            /// </param>
            /// <param name='longTermRetentionServerName'>
            /// The name of the server
            /// </param>
            /// <param name='longTermRetentionDatabaseName'>
            /// The name of the database
            /// </param>
            /// <param name='backupName'>
            /// The backup name.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task DeleteAsync(this ILongTermRetentionBackupsOperations operations, string locationName, string longTermRetentionServerName, string longTermRetentionDatabaseName, string backupName, CancellationToken cancellationToken = default(CancellationToken))
            {
                (await operations.DeleteWithHttpMessagesAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName, null, cancellationToken).ConfigureAwait(false)).Dispose();
            }

            /// <summary>
            /// Lists all long term retention backups for a database.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database
            /// </param>
            /// <param name='longTermRetentionServerName'>
            /// The name of the server
            /// </param>
            /// <param name='longTermRetentionDatabaseName'>
            /// The name of the database
            /// </param>
            /// <param name='onlyLatestPerDatabase'>
            /// Whether or not to only get the latest backup for each database.
            /// </param>
            /// <param name='databaseState'>
            /// Whether to query against just live databases, just deleted databases, or
            /// all databases. Possible values include: 'All', 'Live', 'Deleted'
            /// </param>
            public static IPage<LongTermRetentionBackup> ListByDatabase(this ILongTermRetentionBackupsOperations operations, string locationName, string longTermRetentionServerName, string longTermRetentionDatabaseName, bool? onlyLatestPerDatabase = default(bool?), string databaseState = default(string))
            {
                return operations.ListByDatabaseAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Lists all long term retention backups for a database.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database
            /// </param>
            /// <param name='longTermRetentionServerName'>
            /// The name of the server
            /// </param>
            /// <param name='longTermRetentionDatabaseName'>
            /// The name of the database
            /// </param>
            /// <param name='onlyLatestPerDatabase'>
            /// Whether or not to only get the latest backup for each database.
            /// </param>
            /// <param name='databaseState'>
            /// Whether to query against just live databases, just deleted databases, or
            /// all databases. Possible values include: 'All', 'Live', 'Deleted'
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<IPage<LongTermRetentionBackup>> ListByDatabaseAsync(this ILongTermRetentionBackupsOperations operations, string locationName, string longTermRetentionServerName, string longTermRetentionDatabaseName, bool? onlyLatestPerDatabase = default(bool?), string databaseState = default(string), CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.ListByDatabaseWithHttpMessagesAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, onlyLatestPerDatabase, databaseState, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Lists the long term retention backups for a given location.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database
            /// </param>
            /// <param name='onlyLatestPerDatabase'>
            /// Whether or not to only get the latest backup for each database.
            /// </param>
            /// <param name='databaseState'>
            /// Whether to query against just live databases, just deleted databases, or
            /// all databases. Possible values include: 'All', 'Live', 'Deleted'
            /// </param>
            public static IPage<LongTermRetentionBackup> ListByLocation(this ILongTermRetentionBackupsOperations operations, string locationName, bool? onlyLatestPerDatabase = default(bool?), string databaseState = default(string))
            {
                return operations.ListByLocationAsync(locationName, onlyLatestPerDatabase, databaseState).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Lists the long term retention backups for a given location.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database
            /// </param>
            /// <param name='onlyLatestPerDatabase'>
            /// Whether or not to only get the latest backup for each database.
            /// </param>
            /// <param name='databaseState'>
            /// Whether to query against just live databases, just deleted databases, or
            /// all databases. Possible values include: 'All', 'Live', 'Deleted'
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<IPage<LongTermRetentionBackup>> ListByLocationAsync(this ILongTermRetentionBackupsOperations operations, string locationName, bool? onlyLatestPerDatabase = default(bool?), string databaseState = default(string), CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.ListByLocationWithHttpMessagesAsync(locationName, onlyLatestPerDatabase, databaseState, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Lists the long term retention backups for a given server.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database
            /// </param>
            /// <param name='longTermRetentionServerName'>
            /// The name of the server
            /// </param>
            /// <param name='onlyLatestPerDatabase'>
            /// Whether or not to only get the latest backup for each database.
            /// </param>
            /// <param name='databaseState'>
            /// Whether to query against just live databases, just deleted databases, or
            /// all databases. Possible values include: 'All', 'Live', 'Deleted'
            /// </param>
            public static IPage<LongTermRetentionBackup> ListByServer(this ILongTermRetentionBackupsOperations operations, string locationName, string longTermRetentionServerName, bool? onlyLatestPerDatabase = default(bool?), string databaseState = default(string))
            {
                return operations.ListByServerAsync(locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Lists the long term retention backups for a given server.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database
            /// </param>
            /// <param name='longTermRetentionServerName'>
            /// The name of the server
            /// </param>
            /// <param name='onlyLatestPerDatabase'>
            /// Whether or not to only get the latest backup for each database.
            /// </param>
            /// <param name='databaseState'>
            /// Whether to query against just live databases, just deleted databases, or
            /// all databases. Possible values include: 'All', 'Live', 'Deleted'
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<IPage<LongTermRetentionBackup>> ListByServerAsync(this ILongTermRetentionBackupsOperations operations, string locationName, string longTermRetentionServerName, bool? onlyLatestPerDatabase = default(bool?), string databaseState = default(string), CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.ListByServerWithHttpMessagesAsync(locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Deletes a long term retention backup.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database
            /// </param>
            /// <param name='longTermRetentionServerName'>
            /// The name of the server
            /// </param>
            /// <param name='longTermRetentionDatabaseName'>
            /// The name of the database
            /// </param>
            /// <param name='backupName'>
            /// The backup name.
            /// </param>
            public static void BeginDelete(this ILongTermRetentionBackupsOperations operations, string locationName, string longTermRetentionServerName, string longTermRetentionDatabaseName, string backupName)
            {
                operations.BeginDeleteAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Deletes a long term retention backup.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='locationName'>
            /// The location of the database
            /// </param>
            /// <param name='longTermRetentionServerName'>
            /// The name of the server
            /// </param>
            /// <param name='longTermRetentionDatabaseName'>
            /// The name of the database
            /// </param>
            /// <param name='backupName'>
            /// The backup name.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task BeginDeleteAsync(this ILongTermRetentionBackupsOperations operations, string locationName, string longTermRetentionServerName, string longTermRetentionDatabaseName, string backupName, CancellationToken cancellationToken = default(CancellationToken))
            {
                (await operations.BeginDeleteWithHttpMessagesAsync(locationName, longTermRetentionServerName, longTermRetentionDatabaseName, backupName, null, cancellationToken).ConfigureAwait(false)).Dispose();
            }

            /// <summary>
            /// Lists all long term retention backups for a database.
            /// </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<LongTermRetentionBackup> ListByDatabaseNext(this ILongTermRetentionBackupsOperations operations, string nextPageLink)
            {
                return operations.ListByDatabaseNextAsync(nextPageLink).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Lists all long term retention backups for a database.
            /// </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<LongTermRetentionBackup>> ListByDatabaseNextAsync(this ILongTermRetentionBackupsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.ListByDatabaseNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Lists the long term retention backups for a given location.
            /// </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<LongTermRetentionBackup> ListByLocationNext(this ILongTermRetentionBackupsOperations operations, string nextPageLink)
            {
                return operations.ListByLocationNextAsync(nextPageLink).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Lists the long term retention backups for a given location.
            /// </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<LongTermRetentionBackup>> ListByLocationNextAsync(this ILongTermRetentionBackupsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.ListByLocationNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

            /// <summary>
            /// Lists the long term retention backups for a given server.
            /// </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<LongTermRetentionBackup> ListByServerNext(this ILongTermRetentionBackupsOperations operations, string nextPageLink)
            {
                return operations.ListByServerNextAsync(nextPageLink).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Lists the long term retention backups for a given server.
            /// </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<LongTermRetentionBackup>> ListByServerNextAsync(this ILongTermRetentionBackupsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.ListByServerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

    }
}
