Workloads.Autorest/custom/New-AzWorkloadsSapVirtualInstance/WorkloadsClient.cs

// 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.
 
namespace Microsoft.Azure.PowerShell.Cmdlets.Workloads
{
    using static Microsoft.Azure.PowerShell.Cmdlets.Workloads.Runtime.Extensions;
 
    /// <summary>
    /// Low-level API implementation for the Workloads Client service.
    /// Workloads client provides access to various workload operations.<br>Azure Center for SAP solutions is currently in PREVIEW.
    /// See the [Azure Center for SAP solutions - Legal Terms](https://learn.microsoft.com/en-us/legal/azure-center-for-sap-solutions/azure-center-for-sap-solutions-legal-terms)
    /// for legal notices applicable to Azure Center for SAP solutions.
    /// </summary>
    public partial class WorkloadsClient
    {
       
        /// <summary>Creates a Virtual Instance for SAP solutions (VIS) resource</summary>
        /// <param name="subscriptionId">The ID of the target subscription.</param>
        /// <param name="resourceGroupName">The name of the resource group. The name is case insensitive.</param>
        /// <param name="sapVirtualInstanceName">The name of the Virtual Instances for SAP solutions resource</param>
        /// <param name="jsonString">Json string supplied to the Create SapVirtualInstances operation.</param>
        /// <param name="onOk">a delegate that is called when the remote service returns 200 (OK).</param>
        /// <param name="onDefault">a delegate that is called when the remote service returns default (any response code not handled
        /// elsewhere).</param>
        /// <param name="eventListener">an <see cref="Microsoft.Azure.PowerShell.Cmdlets.Workloads.Runtime.IEventListener" /> instance that will receive events.</param>
        /// <param name="sender">an instance of an Microsoft.Azure.PowerShell.Cmdlets.Workloads.Runtime.ISendAsync pipeline to use to make the request.</param>
        /// <returns>
        /// A <see cref="global::System.Threading.Tasks.Task" /> that will be complete when handling of the response is completed.
        /// </returns>
        public async global::System.Threading.Tasks.Task SapVirtualInstancesCreateViaJsonString(string subscriptionId, string resourceGroupName, string sapVirtualInstanceName, string jsonString, global::System.Func<global::System.Net.Http.HttpResponseMessage, global::System.Threading.Tasks.Task<Microsoft.Azure.PowerShell.Cmdlets.Workloads.Models.Api20231001Preview.ISapVirtualInstance>, global::System.Threading.Tasks.Task> onOk, global::System.Func<global::System.Net.Http.HttpResponseMessage, global::System.Threading.Tasks.Task<Microsoft.Azure.PowerShell.Cmdlets.Workloads.Models.Api30.IErrorResponse>, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.Workloads.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.Workloads.Runtime.ISendAsync sender)
        {
            var apiVersion = @"2023-10-01-preview";
            // Constant Parameters
            using( NoSynchronizationContext )
            {
                              // construct URL
                var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace(
                        "/subscriptions/"
                        + global::System.Uri.EscapeDataString(subscriptionId)
                        + "/resourceGroups/"
                        + global::System.Uri.EscapeDataString(resourceGroupName)
                        + "/providers/Microsoft.Workloads/sapVirtualInstances/"
                        + global::System.Uri.EscapeDataString(sapVirtualInstanceName)
                        + "?"
                        + "api-version=" + global::System.Uri.EscapeDataString(apiVersion)
                        ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2");
                await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Workloads.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
                // generate request object
                var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}");
                var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.Workloads.Runtime.Method.Put, _url);
                await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Workloads.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; }
 
                await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Workloads.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; }
                // set body content
                request.Content = new global::System.Net.Http.StringContent(jsonString, global::System.Text.Encoding.UTF8);
                request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
                await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.Workloads.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; }
                // make the call
                await this.SapVirtualInstancesCreate_Call(request,onOk,onDefault,eventListener,sender);
            }
        }
    }
}