// <auto-generated/>

#nullable disable

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

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

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

        /// <summary> Initializes a new instance of PetOperations. </summary>
        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
        /// <param name="endpoint"> Service endpoint. </param>
        internal PetOperations(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 pet as a pet
        /// <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 UpdatePetAsPet(BinaryContent content, RequestOptions options = null)
        {
            try
            {
                System.Console.WriteLine("Entering method UpdatePetAsPet.");
                Argument.AssertNotNull(content, nameof(content));

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

        /// <summary>
        /// [Protocol Method] Update a pet as a pet
        /// <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> UpdatePetAsPetAsync(BinaryContent content, RequestOptions options = null)
        {
            try
            {
                System.Console.WriteLine("Entering method UpdatePetAsPetAsync.");
                Argument.AssertNotNull(content, nameof(content));

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

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

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

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

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

        /// <summary>
        /// [Protocol Method] Update a dog as a pet
        /// <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 UpdateDogAsPet(BinaryContent content, RequestOptions options = null)
        {
            try
            {
                System.Console.WriteLine("Entering method UpdateDogAsPet.");
                Argument.AssertNotNull(content, nameof(content));

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

        /// <summary>
        /// [Protocol Method] Update a dog as a pet
        /// <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> UpdateDogAsPetAsync(BinaryContent content, RequestOptions options = null)
        {
            try
            {
                System.Console.WriteLine("Entering method UpdateDogAsPetAsync.");
                Argument.AssertNotNull(content, nameof(content));

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

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

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

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

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