diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/Azure.Template.Widgetmanager.sln b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/Azure.Template.Widgetmanager.sln new file mode 100644 index 000000000000..b1952abc318b --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/Azure.Template.Widgetmanager.sln @@ -0,0 +1,69 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" +EndProject +Project("{2B62A209-5D81-4D54-B282-F71E608FE66C}") = "Azure.Template.Widgetmanager.Perf", "perf\Azure.Template.Widgetmanager.Perf.csproj", "{30C5FF85-655A-49FC-A324-16438130FF3F}" +EndProject +Project("{2B62A209-5D81-4D54-B282-F71E608FE66C}") = "Azure.Template.Widgetmanager.Stress", "stress\Azure.Template.Widgetmanager.Stress.csproj", "{47E3BC66-5C4F-47CD-A37B-A973E54BCBA9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Template.Widgetmanager", "src\Azure.Template.Widgetmanager.csproj", "{7610CB96-CBE8-4582-AAA1-A5FB64EC5505}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Template.Widgetmanager.Tests", "tests\Azure.Template.Widgetmanager.Tests.csproj", "{A1DB68BC-D882-43D4-B505-6E4C1349DDAD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {30C5FF85-655A-49FC-A324-16438130FF3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30C5FF85-655A-49FC-A324-16438130FF3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30C5FF85-655A-49FC-A324-16438130FF3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30C5FF85-655A-49FC-A324-16438130FF3F}.Release|Any CPU.Build.0 = Release|Any CPU + {47E3BC66-5C4F-47CD-A37B-A973E54BCBA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47E3BC66-5C4F-47CD-A37B-A973E54BCBA9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47E3BC66-5C4F-47CD-A37B-A973E54BCBA9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47E3BC66-5C4F-47CD-A37B-A973E54BCBA9}.Release|Any CPU.Build.0 = Release|Any CPU + {7610CB96-CBE8-4582-AAA1-A5FB64EC5505}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7610CB96-CBE8-4582-AAA1-A5FB64EC5505}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7610CB96-CBE8-4582-AAA1-A5FB64EC5505}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7610CB96-CBE8-4582-AAA1-A5FB64EC5505}.Release|Any CPU.Build.0 = Release|Any CPU + {A1DB68BC-D882-43D4-B505-6E4C1349DDAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A1DB68BC-D882-43D4-B505-6E4C1349DDAD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A1DB68BC-D882-43D4-B505-6E4C1349DDAD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A1DB68BC-D882-43D4-B505-6E4C1349DDAD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/CHANGELOG.md b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/CHANGELOG.md new file mode 100644 index 000000000000..13dd08af78ab --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/Directory.Build.props b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/Directory.Build.props new file mode 100644 index 000000000000..1a9611bd4924 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/README.md b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/README.md new file mode 100644 index 000000000000..ba0519a29fe1 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/README.md @@ -0,0 +1,90 @@ +# Azure Widgetmanager client library for .NET + +This section should give out brief introduction of the client library. + +* First sentence: **Describe the service** briefly. You can usually use the first line of the service's docs landing page for this (Example: [Cosmos DB docs landing page](https://docs.microsoft.com/azure/cosmos-db/)). +* Next, add a **bulleted list** of the **most common tasks** supported by the package or library, prefaced with "Use the client library for [Product Name] to:". Then, provide code snippets for these tasks in the [Examples](#examples) section later in the document. Keep the task list short but include those tasks most developers need to perform with your package. + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src) | [Package (NuGet)](https://www.nuget.org/packages/Azure.Template.Widgetmanager) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.Template.Widgetmanager --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/samples). + +### + +You can create a client and call the client's `` method. + +```C# Snippet:Azure_Template_Widgetmanager_Scenario +``` + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/README.png) \ No newline at end of file diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/api/Azure.Template.Widgetmanager.netstandard2.0.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/api/Azure.Template.Widgetmanager.netstandard2.0.cs new file mode 100644 index 000000000000..56d6b136c727 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/api/Azure.Template.Widgetmanager.netstandard2.0.cs @@ -0,0 +1,25 @@ +namespace Azure.Template.Widgetmanager +{ + public partial class WidgetManagerClient + { + public WidgetManagerClient() { } + public WidgetManagerClient(Azure.Template.Widgetmanager.WidgetManagerClientOptions options) { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.Operation CreateOrUpdateWidget(Azure.WaitUntil waitUntil, string widgetName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateWidgetAsync(Azure.WaitUntil waitUntil, string widgetName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Operation DeleteWidget(Azure.WaitUntil waitUntil, string widgetName, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task> DeleteWidgetAsync(Azure.WaitUntil waitUntil, string widgetName, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response GetWidget(string widgetName, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task GetWidgetAsync(string widgetName, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Pageable GetWidgets(int? maxCount = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; } + public virtual Azure.AsyncPageable GetWidgetsAsync(int? maxCount = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), Azure.RequestContext context = null) { throw null; } + } + public partial class WidgetManagerClientOptions : Azure.Core.ClientOptions + { + public WidgetManagerClientOptions(Azure.Template.Widgetmanager.WidgetManagerClientOptions.ServiceVersion version = Azure.Template.Widgetmanager.WidgetManagerClientOptions.ServiceVersion.V2022_11_01_Preview) { } + public enum ServiceVersion + { + V2022_11_01_Preview = 1, + } + } +} diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/perf/Azure.Template.Widgetmanager.Perf.csproj b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/perf/Azure.Template.Widgetmanager.Perf.csproj new file mode 100644 index 000000000000..944fa839c831 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/perf/Azure.Template.Widgetmanager.Perf.csproj @@ -0,0 +1,16 @@ + + + + Exe + + + + + + + + + + + + diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/perf/Program.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/perf/Program.cs new file mode 100644 index 000000000000..78a52ddce190 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/perf/Program.cs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Reflection; +using Azure.Test.Perf; + + await PerfProgram.Main(Assembly.GetEntryAssembly(), args); diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/perf/WidgetmanagerClientTest.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/perf/WidgetmanagerClientTest.cs new file mode 100644 index 000000000000..aa504dc2d632 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/perf/WidgetmanagerClientTest.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Identity; +using Azure.Test.Perf; +using CommandLine; + +namespace Azure.Template.Widgetmanager.Perf +{ + public class WidgetmanagerClientTest : PerfTest + { + /* please refer to https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template/perf/TemplateClientTest.cs to write perf test. */ + + public WidgetmanagerClientTest(WidgetmanagerClientPerfOptions options) : base(options) + { + } + public class WidgetmanagerClientPerfOptions : PerfOptions + { + } + + public override void Run(CancellationToken cancellationToken) + { + } + + public override async Task RunAsync(CancellationToken cancellationToken) + { + await Task.Run(() => + { + Console.WriteLine("exec some async operation"); + }); + } + } +} diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/samples/README.md b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/samples/README.md new file mode 100644 index 000000000000..fb1c15e0b6ab --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/samples/README.md @@ -0,0 +1,14 @@ +--- +page_type: sample +languages: +- csharp +products: +# Including relevant stubs from https://review.docs.microsoft.com/help/contribute/metadata-taxonomies#product +- azure +name: Azure.Template.Widgetmanager samples for .NET +description: Samples for the Azure.Template.Widgetmanager client library. +--- + +# Azure.Template.Widgetmanager Samples + + diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/samples/Sample1_HelloWorld.md b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/samples/Sample1_HelloWorld.md new file mode 100644 index 000000000000..c3e30976fc70 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/samples/Sample1_HelloWorld.md @@ -0,0 +1,15 @@ +# + +To use these samples, you'll first need to set up resources. See [getting started](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/README.md#getting-started) for details. + +## + +You can create a client and call the client's `` method + +```C# Snippet:Azure_Template_Widgetmanager_Scenario +``` + +To see the full example source files, see: +* [HelloWorld](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Samples/Sample1_HelloWorld.cs)) + + \ No newline at end of file diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/samples/Sample1_HelloWorldAsync.md b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/samples/Sample1_HelloWorldAsync.md new file mode 100644 index 000000000000..152f1cfb9847 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/samples/Sample1_HelloWorldAsync.md @@ -0,0 +1,15 @@ +# + +To use these samples, you'll first need to set up resources. See [getting started](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/README.md#getting-started) for details. + +## asynchronously + +You can create a client and call the client's `` method + +```C# Snippet:Azure_Template_Widgetmanager_ScenarioAsync +``` + +To see the full example source files, see: +* [HelloWorld](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Samples/Sample1_HelloWorldAsync.cs)) + + \ No newline at end of file diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Azure.Template.Widgetmanager.csproj b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Azure.Template.Widgetmanager.csproj new file mode 100644 index 000000000000..731a79b748d7 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Azure.Template.Widgetmanager.csproj @@ -0,0 +1,22 @@ + + + This is the Widgetmanager client library for developing .NET applications with rich experience. + Azure SDK Code Generation Widgetmanager for Azure Data Plane + 1.0.0-beta.1 + Azure Widgetmanager + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + + + diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Generated/Docs/WidgetManagerClient.xml b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Generated/Docs/WidgetManagerClient.xml new file mode 100644 index 000000000000..976a7ac3c786 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Generated/Docs/WidgetManagerClient.xml @@ -0,0 +1,369 @@ + + + + + +This sample shows how to call GetWidgetAsync with required parameters and parse the result. +"); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("manufacturerId").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("tag").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("createdDate").ToString()); +]]> + + +Below is the JSON schema for the response payload. + +Response Body: + +Schema for Widget: +{ + name: string, # Required. + manufacturerId: string, # Required. + sharedModel: { + tag: string, # Required. + createdDate: string (date & time), # Required. + }, # Optional. +} + + + + + + +This sample shows how to call GetWidget with required parameters and parse the result. +"); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("manufacturerId").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("tag").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("createdDate").ToString()); +]]> + + +Below is the JSON schema for the response payload. + +Response Body: + +Schema for Widget: +{ + name: string, # Required. + manufacturerId: string, # Required. + sharedModel: { + tag: string, # Required. + createdDate: string (date & time), # Required. + }, # Optional. +} + + + + + + +This sample shows how to call GetWidgetsAsync and parse the result. + +This sample shows how to call GetWidgetsAsync with all parameters, and how to parse the result. + + + +Below is the JSON schema for one item in the pageable response. + +Response Body: + +Schema for Array: +{ + name: string, # Required. + manufacturerId: string, # Required. + sharedModel: { + tag: string, # Required. + createdDate: string (date & time), # Required. + }, # Optional. +} + + + + + + +This sample shows how to call GetWidgets and parse the result. + +This sample shows how to call GetWidgets with all parameters, and how to parse the result. + + + +Below is the JSON schema for one item in the pageable response. + +Response Body: + +Schema for Array: +{ + name: string, # Required. + manufacturerId: string, # Required. + sharedModel: { + tag: string, # Required. + createdDate: string (date & time), # Required. + }, # Optional. +} + + + + + + +This sample shows how to call CreateOrUpdateWidgetAsync with required parameters and request content, and how to parse the result. +", +}; + +var operation = await client.CreateOrUpdateWidgetAsync(WaitUntil.Started, "", RequestContent.Create(data)); + +BinaryData data = await operation.WaitForCompletionAsync(); +JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("manufacturerId").ToString()); +]]> +This sample shows how to call CreateOrUpdateWidgetAsync with all parameters and request content, and how to parse the result. +", + sharedModel = new { + tag = "", + createdDate = "2022-05-10T14:57:31.2311892-04:00", + }, +}; + +var operation = await client.CreateOrUpdateWidgetAsync(WaitUntil.Started, "", RequestContent.Create(data)); + +BinaryData data = await operation.WaitForCompletionAsync(); +JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("manufacturerId").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("tag").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("createdDate").ToString()); +]]> + + +Below is the JSON schema for the request and response payloads. + +Request Body: + +Schema for Widget: +{ + name: string, # Required. + manufacturerId: string, # Required. + sharedModel: { + tag: string, # Required. + createdDate: string (date & time), # Required. + }, # Optional. +} + + +Response Body: + +Schema for Widget: +{ + name: string, # Required. + manufacturerId: string, # Required. + sharedModel: { + tag: string, # Required. + createdDate: string (date & time), # Required. + }, # Optional. +} + + + + + + +This sample shows how to call CreateOrUpdateWidget with required parameters and request content, and how to parse the result. +", +}; + +var operation = client.CreateOrUpdateWidget(WaitUntil.Started, "", RequestContent.Create(data)); + +BinaryData data = operation.WaitForCompletion(); +JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("manufacturerId").ToString()); +]]> +This sample shows how to call CreateOrUpdateWidget with all parameters and request content, and how to parse the result. +", + sharedModel = new { + tag = "", + createdDate = "2022-05-10T14:57:31.2311892-04:00", + }, +}; + +var operation = client.CreateOrUpdateWidget(WaitUntil.Started, "", RequestContent.Create(data)); + +BinaryData data = operation.WaitForCompletion(); +JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("manufacturerId").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("tag").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("createdDate").ToString()); +]]> + + +Below is the JSON schema for the request and response payloads. + +Request Body: + +Schema for Widget: +{ + name: string, # Required. + manufacturerId: string, # Required. + sharedModel: { + tag: string, # Required. + createdDate: string (date & time), # Required. + }, # Optional. +} + + +Response Body: + +Schema for Widget: +{ + name: string, # Required. + manufacturerId: string, # Required. + sharedModel: { + tag: string, # Required. + createdDate: string (date & time), # Required. + }, # Optional. +} + + + + + + +This sample shows how to call DeleteWidgetAsync with required parameters and parse the result. +"); + +BinaryData data = await operation.WaitForCompletionAsync(); +JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("manufacturerId").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("tag").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("createdDate").ToString()); +]]> + + +Below is the JSON schema for the response payload. + +Response Body: + +Schema for Widget: +{ + name: string, # Required. + manufacturerId: string, # Required. + sharedModel: { + tag: string, # Required. + createdDate: string (date & time), # Required. + }, # Optional. +} + + + + + + +This sample shows how to call DeleteWidget with required parameters and parse the result. +"); + +BinaryData data = operation.WaitForCompletion(); +JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement; +Console.WriteLine(result.GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("manufacturerId").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("tag").ToString()); +Console.WriteLine(result.GetProperty("sharedModel").GetProperty("createdDate").ToString()); +]]> + + +Below is the JSON schema for the response payload. + +Response Body: + +Schema for Widget: +{ + name: string, # Required. + manufacturerId: string, # Required. + sharedModel: { + tag: string, # Required. + createdDate: string (date & time), # Required. + }, # Optional. +} + + + + + + \ No newline at end of file diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Generated/WidgetManagerClient.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Generated/WidgetManagerClient.cs new file mode 100644 index 000000000000..433b391a3a56 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Generated/WidgetManagerClient.cs @@ -0,0 +1,360 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Template.Widgetmanager +{ + // Data plane generated client. + /// The WidgetManager service client. + public partial class WidgetManagerClient + { + private readonly HttpPipeline _pipeline; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of WidgetManagerClient. + public WidgetManagerClient() : this(new WidgetManagerClientOptions()) + { + } + + /// Initializes a new instance of WidgetManagerClient. + /// The options for configuring the client. + public WidgetManagerClient(WidgetManagerClientOptions options) + { + options ??= new WidgetManagerClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), Array.Empty(), new ResponseClassifier()); + _apiVersion = options.Version; + } + + /// Fetch a Widget by name. + /// The widget name. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. Details of the response body schema are in the Remarks section below. + /// + public virtual async Task GetWidgetAsync(string widgetName, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + using var scope = ClientDiagnostics.CreateScope("WidgetManagerClient.GetWidget"); + scope.Start(); + try + { + using HttpMessage message = CreateGetWidgetRequest(widgetName, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Fetch a Widget by name. + /// The widget name. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. Details of the response body schema are in the Remarks section below. + /// + public virtual Response GetWidget(string widgetName, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + using var scope = ClientDiagnostics.CreateScope("WidgetManagerClient.GetWidget"); + scope.Start(); + try + { + using HttpMessage message = CreateGetWidgetRequest(widgetName, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List Widget resources. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetWidgetsAsync(int? maxCount = null, int? skip = null, int? maxpagesize = null, RequestContext context = null) + { + return GetWidgetsImplementationAsync("WidgetManagerClient.GetWidgets", maxCount, skip, maxpagesize, context); + } + + private AsyncPageable GetWidgetsImplementationAsync(string diagnosticsScopeName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + return PageableHelpers.CreateAsyncPageable(CreateEnumerableAsync, ClientDiagnostics, diagnosticsScopeName); + async IAsyncEnumerable> CreateEnumerableAsync(string nextLink, int? pageSizeHint, [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + do + { + var message = string.IsNullOrEmpty(nextLink) + ? CreateGetWidgetsRequest(maxCount, skip, maxpagesize, context) + : CreateGetWidgetsNextPageRequest(nextLink, maxCount, skip, maxpagesize, context); + var page = await LowLevelPageableHelpers.ProcessMessageAsync(_pipeline, message, context, "value", "nextLink", cancellationToken).ConfigureAwait(false); + nextLink = page.ContinuationToken; + yield return page; + } while (!string.IsNullOrEmpty(nextLink)); + } + } + + /// List Widget resources. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetWidgets(int? maxCount = null, int? skip = null, int? maxpagesize = null, RequestContext context = null) + { + return GetWidgetsImplementation("WidgetManagerClient.GetWidgets", maxCount, skip, maxpagesize, context); + } + + private Pageable GetWidgetsImplementation(string diagnosticsScopeName, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + return PageableHelpers.CreatePageable(CreateEnumerable, ClientDiagnostics, diagnosticsScopeName); + IEnumerable> CreateEnumerable(string nextLink, int? pageSizeHint) + { + do + { + var message = string.IsNullOrEmpty(nextLink) + ? CreateGetWidgetsRequest(maxCount, skip, maxpagesize, context) + : CreateGetWidgetsNextPageRequest(nextLink, maxCount, skip, maxpagesize, context); + var page = LowLevelPageableHelpers.ProcessMessage(_pipeline, message, context, "value", "nextLink"); + nextLink = page.ContinuationToken; + yield return page; + } while (!string.IsNullOrEmpty(nextLink)); + } + } + + /// Creates or updates a Widget asynchronously. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The widget name. + /// The content to send as the body of the request. Details of the request body schema are in the Remarks section below. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service that will contain a object once the asynchronous operation on the service has completed. Details of the body schema for the operation's final value are in the Remarks section below. + /// + public virtual async Task> CreateOrUpdateWidgetAsync(WaitUntil waitUntil, string widgetName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("WidgetManagerClient.CreateOrUpdateWidget"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateWidgetRequest(widgetName, content, context); + return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "WidgetManagerClient.CreateOrUpdateWidget", OperationFinalStateVia.Location, context, waitUntil).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates or updates a Widget asynchronously. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The widget name. + /// The content to send as the body of the request. Details of the request body schema are in the Remarks section below. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service that will contain a object once the asynchronous operation on the service has completed. Details of the body schema for the operation's final value are in the Remarks section below. + /// + public virtual Operation CreateOrUpdateWidget(WaitUntil waitUntil, string widgetName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("WidgetManagerClient.CreateOrUpdateWidget"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateWidgetRequest(widgetName, content, context); + return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "WidgetManagerClient.CreateOrUpdateWidget", OperationFinalStateVia.Location, context, waitUntil); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete a Widget asynchronously. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The widget name. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service that will contain a object once the asynchronous operation on the service has completed. Details of the body schema for the operation's final value are in the Remarks section below. + /// + public virtual async Task> DeleteWidgetAsync(WaitUntil waitUntil, string widgetName, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + using var scope = ClientDiagnostics.CreateScope("WidgetManagerClient.DeleteWidget"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteWidgetRequest(widgetName, context); + return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "WidgetManagerClient.DeleteWidget", OperationFinalStateVia.Location, context, waitUntil).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete a Widget asynchronously. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The widget name. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service that will contain a object once the asynchronous operation on the service has completed. Details of the body schema for the operation's final value are in the Remarks section below. + /// + public virtual Operation DeleteWidget(WaitUntil waitUntil, string widgetName, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(widgetName, nameof(widgetName)); + + using var scope = ClientDiagnostics.CreateScope("WidgetManagerClient.DeleteWidget"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteWidgetRequest(widgetName, context); + return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "WidgetManagerClient.DeleteWidget", OperationFinalStateVia.Location, context, waitUntil); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateGetWidgetRequest(string widgetName, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendPath("/widgets/", false); + uri.AppendPath(widgetName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateWidgetRequest(string widgetName, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendPath("/widgets/", false); + uri.AppendPath(widgetName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteWidgetRequest(string widgetName, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier202); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendPath("/widgets/", false); + uri.AppendPath(widgetName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetWidgetsRequest(int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendPath("/widgets", false); + if (maxCount != null) + { + uri.AppendQuery("top", maxCount.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetWidgetsNextPageRequest(string nextLink, int? maxCount, int? skip, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + private static ResponseClassifier _responseClassifier202; + private static ResponseClassifier ResponseClassifier202 => _responseClassifier202 ??= new StatusCodeClassifier(stackalloc ushort[] { 202 }); + } +} diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Generated/WidgetManagerClientOptions.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Generated/WidgetManagerClientOptions.cs new file mode 100644 index 000000000000..b2726a413ab1 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/Generated/WidgetManagerClientOptions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.Template.Widgetmanager +{ + /// Client options for WidgetManagerClient. + public partial class WidgetManagerClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2022_11_01_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2022-11-01-preview". + V2022_11_01_Preview = 1, + } + + internal string Version { get; } + + /// Initializes new instance of WidgetManagerClientOptions. + public WidgetManagerClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2022_11_01_Preview => "2022-11-01-preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/GlobalSuppressions.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/GlobalSuppressions.cs new file mode 100644 index 000000000000..9b3803f9838c --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/GlobalSuppressions.cs @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Usage", "AZC0002:DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.", Justification = "CancellationToken can be passed through RequestOptions")] \ No newline at end of file diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/cadl-location.yaml b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/cadl-location.yaml new file mode 100644 index 000000000000..565b4d2edbdc --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/cadl-location.yaml @@ -0,0 +1,3 @@ +spec-root-dir: /mnt/vss/_work/1/s/azure-rest-api-specs +directory: specification/contosowidgetmanager/Contoso.WidgetManager + diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/properties/AssemblyInfo.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/properties/AssemblyInfo.cs new file mode 100644 index 000000000000..d6b91bc93269 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/src/properties/AssemblyInfo.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +// Replace with test project/test project public key and uncomment to make internal members visible to +// your test project. If not needed, this can be deleted. +// [assembly: InternalsVisibleTo("Azure.Template.Widgetmanager.Generated.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Contosowidgetmanager")] diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/stress/Azure.Template.Widgetmanager.Stress.csproj b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/stress/Azure.Template.Widgetmanager.Stress.csproj new file mode 100644 index 000000000000..0b53be9032a9 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/stress/Azure.Template.Widgetmanager.Stress.csproj @@ -0,0 +1,16 @@ + + + + Exe + + + + + + + + + + + + diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/stress/Program.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/stress/Program.cs new file mode 100644 index 000000000000..d25a1b56e291 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/stress/Program.cs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Reflection; +using Azure.Test.Stress; + +await StressProgram.Main(Assembly.GetEntryAssembly(), args); diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/stress/WidgetmanagerClientTest.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/stress/WidgetmanagerClientTest.cs new file mode 100644 index 000000000000..f3a70cfbdaca --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/stress/WidgetmanagerClientTest.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Identity; +using Azure.Test.Stress; +using CommandLine; + +namespace Azure.Template.Widgetmanager.Stress +{ + public class WidgetmanagerClientTest : StressTest + { + public WidgetmanagerClientTest(WidgetmanagerClientStressOptions options, WidgetmanagerClientStressMetrics metrics) : base(options, metrics) + { + } + + /* please refer to https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template/stress/TemplateClientTest.cs to write stress tests. */ + + public override async Task RunAsync(CancellationToken cancellationToken) + { + await Task.Run(() => + { + Console.WriteLine("exec some async operation"); + }); + } + public class WidgetmanagerClientStressMetrics : StressMetrics + { + } + + public class WidgetmanagerClientStressOptions : StressOptions + { + } + } +} diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Azure.Template.Widgetmanager.Tests.csproj b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Azure.Template.Widgetmanager.Tests.csproj new file mode 100644 index 000000000000..ea43d6b86bd3 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Azure.Template.Widgetmanager.Tests.csproj @@ -0,0 +1,25 @@ + + + $(RequiredTargetFrameworks) + + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Samples/README.md b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Samples/README.md new file mode 100644 index 000000000000..41d65781e44a --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Samples/README.md @@ -0,0 +1,3 @@ +Source files in this directory are written as tests from which samples are extracted. +They are not intended to be viewed directly and help ensure our samples compile and work correctly. +See our [list of samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/samples) for more explanation about how to use this client library. diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Samples/Sample1_HelloWorld.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Samples/Sample1_HelloWorld.cs new file mode 100644 index 000000000000..b49e740c9999 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Samples/Sample1_HelloWorld.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.Template.Widgetmanager.Tests.Samples +{ + public partial class WidgetmanagerSamples: SamplesBase + { + /* please refer to https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template/tests/Samples/Sample1.HelloWorld.cs to write samples. */ + #region Snippet:Azure_Template_Widgetmanager_Scenario + + #endregion + } +} diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Samples/Sample1_HelloWorldAsync.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Samples/Sample1_HelloWorldAsync.cs new file mode 100644 index 000000000000..5456f013b3b4 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/Samples/Sample1_HelloWorldAsync.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.Template.Widgetmanager.Tests.Samples +{ + public partial class WidgetmanagerSamples: SamplesBase + { + /* please refer to https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template/tests/Samples/Sample1.HelloWorldAsync.cs to write samples. */ + #region Snippet:Azure_Template_Widgetmanager_ScenarioAsync + + #endregion + } +} diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/WidgetmanagerClientTest.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/WidgetmanagerClientTest.cs new file mode 100644 index 000000000000..e6524e738413 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/WidgetmanagerClientTest.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.IO; +using System.Net.Http; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core.Pipeline; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.Template.Widgetmanager.Tests +{ + public class WidgetmanagerClientTest: RecordedTestBase + { + public WidgetmanagerClientTest(bool isAsync) : base(isAsync) + { + } + + /* please refer to https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template/tests/TemplateClientLiveTests.cs to write tests. */ + + [RecordedTest] + public void TestOperation() + { + Assert.IsTrue(true); + } + + #region Helpers + + private static BinaryData GetContentFromResponse(Response r) + { + // Workaround azure/azure-sdk-for-net#21048, which prevents .Content from working when dealing with responses + // from the playback system. + + MemoryStream ms = new MemoryStream(); + r.ContentStream.CopyTo(ms); + return new BinaryData(ms.ToArray()); + } + #endregion + } +} diff --git a/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/WidgetmanagerClientTestEnvironment.cs b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/WidgetmanagerClientTestEnvironment.cs new file mode 100644 index 000000000000..570b08733f92 --- /dev/null +++ b/sdk/contosowidgetmanager/Azure.Template.Widgetmanager/tests/WidgetmanagerClientTestEnvironment.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.Template.Widgetmanager.Tests +{ + public class WidgetmanagerClientTestEnvironment : TestEnvironment + { + public string Endpoint => GetRecordedVariable("Widgetmanager_ENDPOINT"); + + // Add other client paramters here as above. + } +} diff --git a/sdk/contosowidgetmanager/ci.yml b/sdk/contosowidgetmanager/ci.yml new file mode 100644 index 000000000000..fc91d874a95b --- /dev/null +++ b/sdk/contosowidgetmanager/ci.yml @@ -0,0 +1,31 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/contosowidgetmanager/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/contosowidgetmanager/ + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: contosowidgetmanager + ArtifactName: packages + Artifacts: + - name: Azure.Template.Widgetmanager + safeName: AzureTemplateWidgetmanager