// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// <auto-generated/>

#nullable disable

using System;
using System.Threading;
using System.Threading.Tasks;
using Azure.Core.Pipeline;

namespace Azure.ResourceManager.Network
{
    /// <summary> The VpnServerConfigurationsAssociatedWithVirtualWan service client. </summary>
    public partial class VpnServerConfigurationsAssociatedWithVirtualWanOperations
    {
        private readonly ClientDiagnostics _clientDiagnostics;
        private readonly HttpPipeline _pipeline;
        internal VpnServerConfigurationsAssociatedWithVirtualWanRestOperations RestClient { get; }
        /// <summary> Initializes a new instance of VpnServerConfigurationsAssociatedWithVirtualWanOperations for mocking. </summary>
        protected VpnServerConfigurationsAssociatedWithVirtualWanOperations()
        {
        }
        /// <summary> Initializes a new instance of VpnServerConfigurationsAssociatedWithVirtualWanOperations. </summary>
        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
        /// <param name="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. </param>
        /// <param name="endpoint"> server parameter. </param>
        internal VpnServerConfigurationsAssociatedWithVirtualWanOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri endpoint = null)
        {
            RestClient = new VpnServerConfigurationsAssociatedWithVirtualWanRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
            _clientDiagnostics = clientDiagnostics;
            _pipeline = pipeline;
        }

        /// <summary> Gives the list of VpnServerConfigurations associated with Virtual Wan in a resource group. </summary>
        /// <param name="resourceGroupName"> The resource group name. </param>
        /// <param name="virtualWANName"> The name of the VirtualWAN whose associated VpnServerConfigurations is needed. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="virtualWANName"/> is null. </exception>
        public virtual async Task<VpnServerConfigurationsAssociatedWithVirtualWanListOperation> StartListAsync(string resourceGroupName, string virtualWANName, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (virtualWANName == null)
            {
                throw new ArgumentNullException(nameof(virtualWANName));
            }

            using var scope = _clientDiagnostics.CreateScope("VpnServerConfigurationsAssociatedWithVirtualWanOperations.StartList");
            scope.Start();
            try
            {
                var originalResponse = await RestClient.ListAsync(resourceGroupName, virtualWANName, cancellationToken).ConfigureAwait(false);
                return new VpnServerConfigurationsAssociatedWithVirtualWanListOperation(_clientDiagnostics, _pipeline, RestClient.CreateListRequest(resourceGroupName, virtualWANName).Request, originalResponse);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }

        /// <summary> Gives the list of VpnServerConfigurations associated with Virtual Wan in a resource group. </summary>
        /// <param name="resourceGroupName"> The resource group name. </param>
        /// <param name="virtualWANName"> The name of the VirtualWAN whose associated VpnServerConfigurations is needed. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="virtualWANName"/> is null. </exception>
        public virtual VpnServerConfigurationsAssociatedWithVirtualWanListOperation StartList(string resourceGroupName, string virtualWANName, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (virtualWANName == null)
            {
                throw new ArgumentNullException(nameof(virtualWANName));
            }

            using var scope = _clientDiagnostics.CreateScope("VpnServerConfigurationsAssociatedWithVirtualWanOperations.StartList");
            scope.Start();
            try
            {
                var originalResponse = RestClient.List(resourceGroupName, virtualWANName, cancellationToken);
                return new VpnServerConfigurationsAssociatedWithVirtualWanListOperation(_clientDiagnostics, _pipeline, RestClient.CreateListRequest(resourceGroupName, virtualWANName).Request, originalResponse);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
    }
}
