// <auto-generated/>

#nullable disable

using System;
using System.ClientModel;
using System.ClientModel.Primitives;
using System.Threading;
using System.Threading.Tasks;

namespace SampleTypeSpec
{
    /// <summary> The DogOperations sub-client. </summary>
    public partial class DogOperations
    {
        private readonly Uri _endpoint;

        /// <summary> Initializes a new instance of DogOperations for mocking. </summary>
        protected DogOperations()
        {
        }

        /// <summary> Initializes a new instance of DogOperations. </summary>
        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
        /// <param name="endpoint"> Service endpoint. </param>
        internal DogOperations(ClientPipeline pipeline, Uri endpoint)
        {
            _endpoint = endpoint;
            Pipeline = pipeline;
        }

        /// <summary> The HTTP pipeline for sending and receiving REST requests and responses. </summary>
        public ClientPipeline Pipeline { get; }

        /// <summary>
        /// [Protocol Method] Update a dog as a dog
        /// <list type="bullet">
        /// <item>
        /// <description> This <see href="https://aka.ms/azsdk/net/protocol-methods">protocol method</see> allows explicit creation of the request and processing of the response for advanced scenarios. </description>
        /// </item>
        /// </list>
        /// </summary>
        /// <param name="content"> The content to send as the body of the request. </param>
        /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
        /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. </returns>
        public virtual ClientResult UpdateDogAsDog(BinaryContent content, RequestOptions options = null)
        {
            try
            {
                System.Console.WriteLine("Entering method UpdateDogAsDog.");
                Argument.AssertNotNull(content, nameof(content));

                using PipelineMessage message = CreateUpdateDogAsDogRequest(content, options);
                return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
            }
            catch (Exception ex)
            {
                System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDog: {ex}");
                throw;
            }
            finally
            {
                System.Console.WriteLine("Exiting method UpdateDogAsDog.");
            }
        }

        /// <summary>
        /// [Protocol Method] Update a dog as a dog
        /// <list type="bullet">
        /// <item>
        /// <description> This <see href="https://aka.ms/azsdk/net/protocol-methods">protocol method</see> allows explicit creation of the request and processing of the response for advanced scenarios. </description>
        /// </item>
        /// </list>
        /// </summary>
        /// <param name="content"> The content to send as the body of the request. </param>
        /// <param name="options"> The request options, which can override default behaviors of the client pipeline on a per-call basis. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
        /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
        /// <returns> The response returned from the service. </returns>
        public virtual async Task<ClientResult> UpdateDogAsDogAsync(BinaryContent content, RequestOptions options = null)
        {
            try
            {
                System.Console.WriteLine("Entering method UpdateDogAsDogAsync.");
                Argument.AssertNotNull(content, nameof(content));

                using PipelineMessage message = CreateUpdateDogAsDogRequest(content, options);
                return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
            }
            catch (Exception ex)
            {
                System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDogAsync: {ex}");
                throw;
            }
            finally
            {
                System.Console.WriteLine("Exiting method UpdateDogAsDogAsync.");
            }
        }

        /// <summary> Update a dog as a dog. </summary>
        /// <param name="dog"></param>
        /// <param name="cancellationToken"> The cancellation token that can be used to cancel the operation. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="dog"/> is null. </exception>
        /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
        public virtual ClientResult<Dog> UpdateDogAsDog(Dog dog, CancellationToken cancellationToken = default)
        {
            try
            {
                System.Console.WriteLine("Entering method UpdateDogAsDog.");
                Argument.AssertNotNull(dog, nameof(dog));

                ClientResult result = UpdateDogAsDog(dog, cancellationToken.ToRequestOptions());
                return ClientResult.FromValue((Dog)result, result.GetRawResponse());
            }
            catch (Exception ex)
            {
                System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDog: {ex}");
                throw;
            }
            finally
            {
                System.Console.WriteLine("Exiting method UpdateDogAsDog.");
            }
        }

        /// <summary> Update a dog as a dog. </summary>
        /// <param name="dog"></param>
        /// <param name="cancellationToken"> The cancellation token that can be used to cancel the operation. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="dog"/> is null. </exception>
        /// <exception cref="ClientResultException"> Service returned a non-success status code. </exception>
        public virtual async Task<ClientResult<Dog>> UpdateDogAsDogAsync(Dog dog, CancellationToken cancellationToken = default)
        {
            try
            {
                System.Console.WriteLine("Entering method UpdateDogAsDogAsync.");
                Argument.AssertNotNull(dog, nameof(dog));

                ClientResult result = await UpdateDogAsDogAsync(dog, cancellationToken.ToRequestOptions()).ConfigureAwait(false);
                return ClientResult.FromValue((Dog)result, result.GetRawResponse());
            }
            catch (Exception ex)
            {
                System.Console.WriteLine($"An exception was thrown in method UpdateDogAsDogAsync: {ex}");
                throw;
            }
            finally
            {
                System.Console.WriteLine("Exiting method UpdateDogAsDogAsync.");
            }
        }
    }
}
