Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// <auto-generated/>

#nullable disable

using System.ClientModel;
using System.ClientModel.Primitives;

namespace SampleTypeSpec
{
/// <summary></summary>
public partial class AnimalOperations
{
private static PipelineMessageClassifier _pipelineMessageClassifier200;

private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 });

internal PipelineMessage CreateUpdatePetAsAnimalRequest(BinaryContent content, RequestOptions options)
{
ClientUriBuilder uri = new ClientUriBuilder();
uri.Reset(_endpoint);
uri.AppendPath("/animals/pet/as-animal", false);
PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier200);
PipelineRequest request = message.Request;
request.Headers.Set("Content-Type", "application/json");
request.Headers.Set("Accept", "application/json");
request.Content = content;
message.Apply(options);
return message;
}

internal PipelineMessage CreateUpdateDogAsAnimalRequest(BinaryContent content, RequestOptions options)
{
ClientUriBuilder uri = new ClientUriBuilder();
uri.Reset(_endpoint);
uri.AppendPath("/animals/dog/as-animal", false);
PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier200);
PipelineRequest request = message.Request;
request.Headers.Set("Content-Type", "application/json");
request.Headers.Set("Accept", "application/json");
request.Content = content;
message.Apply(options);
return message;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
// <auto-generated/>

#nullable disable

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

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

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

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

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

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

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

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

ClientResult result = UpdatePetAsAnimal(animal, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
return ClientResult.FromValue((Animal)result, result.GetRawResponse());
}
catch (Exception ex)
{
System.Console.WriteLine($"An exception was thrown in method UpdatePetAsAnimal: {ex}");
throw;
}
finally
{
System.Console.WriteLine("Exiting method UpdatePetAsAnimal.");
}
}

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

ClientResult result = await UpdatePetAsAnimalAsync(animal, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null).ConfigureAwait(false);
return ClientResult.FromValue((Animal)result, result.GetRawResponse());
}
catch (Exception ex)
{
System.Console.WriteLine($"An exception was thrown in method UpdatePetAsAnimalAsync: {ex}");
throw;
}
finally
{
System.Console.WriteLine("Exiting method UpdatePetAsAnimalAsync.");
}
}

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

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

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

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

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

ClientResult result = UpdateDogAsAnimal(animal, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
return ClientResult.FromValue((Animal)result, result.GetRawResponse());
}
catch (Exception ex)
{
System.Console.WriteLine($"An exception was thrown in method UpdateDogAsAnimal: {ex}");
throw;
}
finally
{
System.Console.WriteLine("Exiting method UpdateDogAsAnimal.");
}
}

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

ClientResult result = await UpdateDogAsAnimalAsync(animal, cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null).ConfigureAwait(false);
return ClientResult.FromValue((Animal)result, result.GetRawResponse());
}
catch (Exception ex)
{
System.Console.WriteLine($"An exception was thrown in method UpdateDogAsAnimalAsync: {ex}");
throw;
}
finally
{
System.Console.WriteLine("Exiting method UpdateDogAsAnimalAsync.");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// <auto-generated/>

#nullable disable

using System.ClientModel;
using System.ClientModel.Primitives;

namespace SampleTypeSpec
{
/// <summary></summary>
public partial class DogOperations
{
private static PipelineMessageClassifier _pipelineMessageClassifier200;

private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 });

internal PipelineMessage CreateUpdateDogAsDogRequest(BinaryContent content, RequestOptions options)
{
ClientUriBuilder uri = new ClientUriBuilder();
uri.Reset(_endpoint);
uri.AppendPath("/dogs/dog/as-dog", false);
PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier200);
PipelineRequest request = message.Request;
request.Headers.Set("Content-Type", "application/json");
request.Headers.Set("Accept", "application/json");
request.Content = content;
message.Apply(options);
return message;
}
}
}
Loading
Loading