From 10296eecaead7654d558af6c50f92dc6c1a3a69f Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 1 Jun 2023 06:44:34 +0000 Subject: [PATCH] CodeGen from PR 24199 in Azure/azure-rest-api-specs Merge 30c109da4938817374a888f1d0f1ee1fd13095d9 into 0724e72994ed3c77f76ed0bfa2df3b1f0c33a41b --- .../Azure.Messaging.EventGrid.Namespaces.sln | 63 ++ .../CHANGELOG.md | 11 + .../Directory.Build.props | 6 + .../README.md | 91 +++ ...ing.EventGrid.Namespaces.netstandard2.0.cs | 38 + ...Messaging.EventGrid.Namespaces.Perf.csproj | 16 + .../perf/NamespacesClientTest.cs | 36 + .../perf/Program.cs | 7 + .../samples/README.md | 14 + .../samples/Sample1_HelloWorld.md | 12 + .../samples/Sample1_HelloWorldAsync.md | 12 + ...zure.Messaging.EventGrid.Namespaces.csproj | 22 + ...ssagingEventGridClientBuilderExtensions.cs | 37 + .../src/Generated/Docs/EventGridClient.xml | 379 ++++++++++ .../src/Generated/EventGridClient.cs | 648 ++++++++++++++++++ .../src/Generated/EventGridClientOptions.cs | 37 + .../src/properties/AssemblyInfo.cs | 13 + .../stress/README.md | 1 + ...essaging.EventGrid.Namespaces.Tests.csproj | 25 + .../Samples/Samples_EventGridClient.cs | 594 ++++++++++++++++ .../tests/NamespacesClientTest.cs | 42 ++ .../tests/NamespacesClientTestEnvironment.cs | 14 + .../tests/Samples/README.md | 3 + .../tests/Samples/Sample1_HelloWorld.cs | 26 + .../tests/Samples/Sample1_HelloWorldAsync.cs | 28 + .../tsp-location.yaml | 3 + sdk/eventgrid/ci.yml | 2 + 27 files changed, 2180 insertions(+) create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/Azure.Messaging.EventGrid.Namespaces.sln create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/CHANGELOG.md create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/Directory.Build.props create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/README.md create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/api/Azure.Messaging.EventGrid.Namespaces.netstandard2.0.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/perf/Azure.Messaging.EventGrid.Namespaces.Perf.csproj create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/perf/NamespacesClientTest.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/perf/Program.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/README.md create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/Sample1_HelloWorld.md create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/Sample1_HelloWorldAsync.md create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Azure.Messaging.EventGrid.Namespaces.csproj create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/AzureMessagingEventGridClientBuilderExtensions.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/Docs/EventGridClient.xml create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/EventGridClient.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/EventGridClientOptions.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/properties/AssemblyInfo.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/stress/README.md create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Azure.Messaging.EventGrid.Namespaces.Tests.csproj create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Generated/Samples/Samples_EventGridClient.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/NamespacesClientTest.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/NamespacesClientTestEnvironment.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Samples/README.md create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Samples/Sample1_HelloWorld.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Samples/Sample1_HelloWorldAsync.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tsp-location.yaml diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/Azure.Messaging.EventGrid.Namespaces.sln b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/Azure.Messaging.EventGrid.Namespaces.sln new file mode 100644 index 0000000000000..4e0698e9f9855 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/Azure.Messaging.EventGrid.Namespaces.sln @@ -0,0 +1,63 @@ + +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("{30061BD7-0D68-4C94-A457-29E1E06F046D}") = "Azure.Messaging.EventGrid.Namespaces.Perf", "perf\Azure.Messaging.EventGrid.Namespaces.Perf.csproj", "{30C5FF85-655A-49FC-A324-16438130FF3F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Messaging.EventGrid.Namespaces", "src\Azure.Messaging.EventGrid.Namespaces.csproj", "{F39F12FC-1EDD-41E3-8676-B01513A0A8E4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Messaging.EventGrid.Namespaces.Tests", "tests\Azure.Messaging.EventGrid.Namespaces.Tests.csproj", "{9BC69A8D-475E-412F-840F-B36FF988DCE5}" +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 + {F39F12FC-1EDD-41E3-8676-B01513A0A8E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F39F12FC-1EDD-41E3-8676-B01513A0A8E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F39F12FC-1EDD-41E3-8676-B01513A0A8E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F39F12FC-1EDD-41E3-8676-B01513A0A8E4}.Release|Any CPU.Build.0 = Release|Any CPU + {9BC69A8D-475E-412F-840F-B36FF988DCE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BC69A8D-475E-412F-840F-B36FF988DCE5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BC69A8D-475E-412F-840F-B36FF988DCE5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BC69A8D-475E-412F-840F-B36FF988DCE5}.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/eventgrid/Azure.Messaging.EventGrid.Namespaces/CHANGELOG.md b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/CHANGELOG.md new file mode 100644 index 0000000000000..13dd08af78abe --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/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/eventgrid/Azure.Messaging.EventGrid.Namespaces/Directory.Build.props b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/Directory.Build.props new file mode 100644 index 0000000000000..1a9611bd49242 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/README.md b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/README.md new file mode 100644 index 0000000000000..e244fa27d7b47 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/README.md @@ -0,0 +1,91 @@ +# Azure Namespaces 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/eventgrid/Azure.Messaging.EventGrid.Namespaces/src) | [Package (NuGet)](https://www.nuget.org/packages/Azure.Messaging.EventGrid.Namespaces) | [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.Messaging.EventGrid.Namespaces --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/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples). + +### + +You can create a client and call the client's `` method. + +```C# Snippet:Azure_Messaging_EventGrid_Namespaces_Scenario +Console.WriteLine("Hello, world!"); +``` + +## 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/eventgrid/Azure.Messaging.EventGrid.Namespaces/README.png) \ No newline at end of file diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/api/Azure.Messaging.EventGrid.Namespaces.netstandard2.0.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/api/Azure.Messaging.EventGrid.Namespaces.netstandard2.0.cs new file mode 100644 index 0000000000000..8595fc61422e2 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/api/Azure.Messaging.EventGrid.Namespaces.netstandard2.0.cs @@ -0,0 +1,38 @@ +namespace Azure.Messaging.EventGrid.Namespaces +{ + public partial class EventGridClient + { + protected EventGridClient() { } + public EventGridClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { } + public EventGridClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.Messaging.EventGrid.Namespaces.EventGridClientOptions options) { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.Response AcknowledgeCloudEvents(string topicName, string eventSubscriptionName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task AcknowledgeCloudEventsAsync(string topicName, string eventSubscriptionName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response PublishCloudEvent(string topicName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task PublishCloudEventAsync(string topicName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response PublishCloudEvents(string topicName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task PublishCloudEventsAsync(string topicName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response ReceiveCloudEvents(string topicName, string eventSubscriptionName, int? maxEvents = default(int?), System.TimeSpan? maxWaitTime = default(System.TimeSpan?), Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task ReceiveCloudEventsAsync(string topicName, string eventSubscriptionName, int? maxEvents = default(int?), System.TimeSpan? maxWaitTime = default(System.TimeSpan?), Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response RejectCloudEvents(string topicName, string eventSubscriptionName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task RejectCloudEventsAsync(string topicName, string eventSubscriptionName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual Azure.Response ReleaseCloudEvents(string topicName, string eventSubscriptionName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + public virtual System.Threading.Tasks.Task ReleaseCloudEventsAsync(string topicName, string eventSubscriptionName, Azure.Core.RequestContent content, Azure.RequestContext context = null) { throw null; } + } + public partial class EventGridClientOptions : Azure.Core.ClientOptions + { + public EventGridClientOptions(Azure.Messaging.EventGrid.Namespaces.EventGridClientOptions.ServiceVersion version = Azure.Messaging.EventGrid.Namespaces.EventGridClientOptions.ServiceVersion.V2023_06_01_Preview) { } + public enum ServiceVersion + { + V2023_06_01_Preview = 1, + } + } +} +namespace Microsoft.Extensions.Azure +{ + public static partial class AzureMessagingEventGridClientBuilderExtensions + { + public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; } + public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/perf/Azure.Messaging.EventGrid.Namespaces.Perf.csproj b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/perf/Azure.Messaging.EventGrid.Namespaces.Perf.csproj new file mode 100644 index 0000000000000..cc2dcf6e4d4e6 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/perf/Azure.Messaging.EventGrid.Namespaces.Perf.csproj @@ -0,0 +1,16 @@ + + + + Exe + + + + + + + + + + + + diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/perf/NamespacesClientTest.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/perf/NamespacesClientTest.cs new file mode 100644 index 0000000000000..174a04e33ebf3 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/perf/NamespacesClientTest.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.Messaging.EventGrid.Namespaces.Perf +{ + public class NamespacesClientTest : 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 NamespacesClientTest(NamespacesClientPerfOptions options) : base(options) + { + } + public class NamespacesClientPerfOptions : 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/eventgrid/Azure.Messaging.EventGrid.Namespaces/perf/Program.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/perf/Program.cs new file mode 100644 index 0000000000000..78a52ddce1909 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/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/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/README.md b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/README.md new file mode 100644 index 0000000000000..99caa245c332c --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/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.Messaging.EventGrid.Namespaces samples for .NET +description: Samples for the Azure.Messaging.EventGrid.Namespaces client library. +--- + +# Azure.Messaging.EventGrid.Namespaces Samples + + diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/Sample1_HelloWorld.md b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/Sample1_HelloWorld.md new file mode 100644 index 0000000000000..870604d253aea --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/Sample1_HelloWorld.md @@ -0,0 +1,12 @@ +# + +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/eventgrid/Azure.Messaging.EventGrid.Namespaces/README.md#getting-started) for details. + +## + +You can create a client and call the client's `` method + + +```C# Snippet:Azure_Messaging_EventGrid_Namespaces_Scenario +Console.WriteLine("Hello, world!"); +``` diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/Sample1_HelloWorldAsync.md b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/Sample1_HelloWorldAsync.md new file mode 100644 index 0000000000000..6f99d4018e24b --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/Sample1_HelloWorldAsync.md @@ -0,0 +1,12 @@ +# + +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/eventgrid/Azure.Messaging.EventGrid.Namespaces/README.md#getting-started) for details. + +## asynchronously + +You can create a client and call the client's `` method + + +```C# Snippet:Azure_Messaging_EventGrid_Namespaces_ScenarioAsync +Console.WriteLine("Hello, world!"); +``` diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Azure.Messaging.EventGrid.Namespaces.csproj b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Azure.Messaging.EventGrid.Namespaces.csproj new file mode 100644 index 0000000000000..44ffd4df60e4c --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Azure.Messaging.EventGrid.Namespaces.csproj @@ -0,0 +1,22 @@ + + + This is the Namespaces client library for developing .NET applications with rich experience. + Azure SDK Code Generation Namespaces for Azure Data Plane + 1.0.0-beta.1 + Azure Namespaces + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + + + diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/AzureMessagingEventGridClientBuilderExtensions.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/AzureMessagingEventGridClientBuilderExtensions.cs new file mode 100644 index 0000000000000..c42e7d35bf35a --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/AzureMessagingEventGridClientBuilderExtensions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core.Extensions; +using Azure.Messaging.EventGrid.Namespaces; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class AzureMessagingEventGridClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net. + /// A credential used to authenticate to an Azure Service. + public static IAzureClientBuilder AddEventGridClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new EventGridClient(endpoint, credential, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddEventGridClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/Docs/EventGridClient.xml b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/Docs/EventGridClient.xml new file mode 100644 index 0000000000000..01d6137bc8fea --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/Docs/EventGridClient.xml @@ -0,0 +1,379 @@ + + + + + +This sample shows how to call PublishCloudEventAsync with required parameters and request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new { + id = "", + source = "", + type = "", + specversion = "", +}; + +Response response = await client.PublishCloudEventAsync("", RequestContent.Create(data)); + +Console.WriteLine(response.ToString()); +]]> +This sample shows how to call PublishCloudEventAsync with all parameters and request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new { + id = "", + source = "", + data = new {}, + data_base64 = new {}, + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", +}; + +Response response = await client.PublishCloudEventAsync("", RequestContent.Create(data), new RequestContext()); + +Console.WriteLine(response.ToString()); +]]> + + + + +This sample shows how to call PublishCloudEvent with required parameters and request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new { + id = "", + source = "", + type = "", + specversion = "", +}; + +Response response = client.PublishCloudEvent("", RequestContent.Create(data)); + +Console.WriteLine(response.ToString()); +]]> +This sample shows how to call PublishCloudEvent with all parameters and request content, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new { + id = "", + source = "", + data = new {}, + data_base64 = new {}, + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", +}; + +Response response = client.PublishCloudEvent("", RequestContent.Create(data), new RequestContext()); + +Console.WriteLine(response.ToString()); +]]> + + + + +This sample shows how to call PublishCloudEventsAsync with required parameters and request content and parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new[] { + new { + id = "", + source = "", + data = new {}, + data_base64 = new {}, + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", + } +}; + +Response response = await client.PublishCloudEventsAsync("", RequestContent.Create(data), new RequestContext()); + +Console.WriteLine(response.ToString()); +]]> + + + + +This sample shows how to call PublishCloudEvents with required parameters and request content and parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new[] { + new { + id = "", + source = "", + data = new {}, + data_base64 = new {}, + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", + } +}; + +Response response = client.PublishCloudEvents("", RequestContent.Create(data), new RequestContext()); + +Console.WriteLine(response.ToString()); +]]> + + + + +This sample shows how to call ReceiveCloudEventsAsync with required parameters and parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +Response response = await client.ReceiveCloudEventsAsync("", ""); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("lockToken").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("deliveryCount").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("source").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("specversion").ToString()); +]]> +This sample shows how to call ReceiveCloudEventsAsync with all parameters, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +Response response = await client.ReceiveCloudEventsAsync("", "", 1234, new TimeSpan(1, 2, 3), new RequestContext()); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("lockToken").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("deliveryCount").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("source").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("data").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("data_base64").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("time").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("specversion").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("dataschema").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("datacontenttype").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("subject").ToString()); +]]> + + + + +This sample shows how to call ReceiveCloudEvents with required parameters and parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +Response response = client.ReceiveCloudEvents("", ""); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("lockToken").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("deliveryCount").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("source").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("specversion").ToString()); +]]> +This sample shows how to call ReceiveCloudEvents with all parameters, and how to parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +Response response = client.ReceiveCloudEvents("", "", 1234, new TimeSpan(1, 2, 3), new RequestContext()); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("lockToken").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("deliveryCount").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("source").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("data").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("data_base64").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("time").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("specversion").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("dataschema").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("datacontenttype").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("subject").ToString()); +]]> + + + + +This sample shows how to call AcknowledgeCloudEventsAsync with required parameters and request content and parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new { + lockTokens = new[] { + "" + }, +}; + +Response response = await client.AcknowledgeCloudEventsAsync("", "", RequestContent.Create(data), new RequestContext()); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); +Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); +]]> + + + + +This sample shows how to call AcknowledgeCloudEvents with required parameters and request content and parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new { + lockTokens = new[] { + "" + }, +}; + +Response response = client.AcknowledgeCloudEvents("", "", RequestContent.Create(data), new RequestContext()); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); +Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); +]]> + + + + +This sample shows how to call ReleaseCloudEventsAsync with required parameters and request content and parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new { + lockTokens = new[] { + "" + }, +}; + +Response response = await client.ReleaseCloudEventsAsync("", "", RequestContent.Create(data), new RequestContext()); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); +Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); +]]> + + + + +This sample shows how to call ReleaseCloudEvents with required parameters and request content and parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new { + lockTokens = new[] { + "" + }, +}; + +Response response = client.ReleaseCloudEvents("", "", RequestContent.Create(data), new RequestContext()); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); +Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); +]]> + + + + +This sample shows how to call RejectCloudEventsAsync with required parameters and request content and parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new { + lockTokens = new[] { + "" + }, +}; + +Response response = await client.RejectCloudEventsAsync("", "", RequestContent.Create(data), new RequestContext()); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); +Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); +]]> + + + + +This sample shows how to call RejectCloudEvents with required parameters and request content and parse the result. +"); +var endpoint = new Uri(""); +var client = new EventGridClient(endpoint, credential); + +var data = new { + lockTokens = new[] { + "" + }, +}; + +Response response = client.RejectCloudEvents("", "", RequestContent.Create(data), new RequestContext()); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); +Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); +Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); +]]> + + + + \ No newline at end of file diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/EventGridClient.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/EventGridClient.cs new file mode 100644 index 0000000000000..56ed0ad0b52a0 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/EventGridClient.cs @@ -0,0 +1,648 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.Messaging.EventGrid.Namespaces +{ + // Data plane generated client. + /// Azure Messaging EventGrid Client. + public partial class EventGridClient + { + private const string AuthorizationHeader = "SharedAccessKey"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + 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 EventGridClient for mocking. + protected EventGridClient() + { + } + + /// Initializes a new instance of EventGridClient. + /// The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public EventGridClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new EventGridClientOptions()) + { + } + + /// Initializes a new instance of EventGridClient. + /// The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public EventGridClient(Uri endpoint, AzureKeyCredential credential, EventGridClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new EventGridClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// + /// [Protocol Method] Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// The content to send as the body of the request. + /// 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 response returned from the service. + /// + public virtual async Task PublishCloudEventAsync(string topicName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.PublishCloudEvent"); + scope.Start(); + try + { + using HttpMessage message = CreatePublishCloudEventRequest(topicName, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// The content to send as the body of the request. + /// 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 response returned from the service. + /// + public virtual Response PublishCloudEvent(string topicName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.PublishCloudEvent"); + scope.Start(); + try + { + using HttpMessage message = CreatePublishCloudEventRequest(topicName, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// The content to send as the body of the request. + /// 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 response returned from the service. + /// + public virtual async Task PublishCloudEventsAsync(string topicName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.PublishCloudEvents"); + scope.Start(); + try + { + using HttpMessage message = CreatePublishCloudEventsRequest(topicName, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// The content to send as the body of the request. + /// 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 response returned from the service. + /// + public virtual Response PublishCloudEvents(string topicName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.PublishCloudEvents"); + scope.Start(); + try + { + using HttpMessage message = CreatePublishCloudEventsRequest(topicName, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Receive Batch of Cloud Events from the Event Subscription. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// Event Subscription Name. + /// Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not specified, the default value is 1. + /// Max wait time value for receive operation in Seconds. It is the time in seconds that the server approximately waits for the availability of an event and responds to the request. If an event is available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120 seconds. If not specified, the default value is 60 seconds. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task ReceiveCloudEventsAsync(string topicName, string eventSubscriptionName, int? maxEvents = null, TimeSpan? maxWaitTime = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.ReceiveCloudEvents"); + scope.Start(); + try + { + using HttpMessage message = CreateReceiveCloudEventsRequest(topicName, eventSubscriptionName, maxEvents, maxWaitTime, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Receive Batch of Cloud Events from the Event Subscription. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// Event Subscription Name. + /// Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not specified, the default value is 1. + /// Max wait time value for receive operation in Seconds. It is the time in seconds that the server approximately waits for the availability of an event and responds to the request. If an event is available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120 seconds. If not specified, the default value is 60 seconds. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response ReceiveCloudEvents(string topicName, string eventSubscriptionName, int? maxEvents = null, TimeSpan? maxWaitTime = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.ReceiveCloudEvents"); + scope.Start(); + try + { + using HttpMessage message = CreateReceiveCloudEventsRequest(topicName, eventSubscriptionName, maxEvents, maxWaitTime, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is successfully acknowledged. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// Event Subscription Name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task AcknowledgeCloudEventsAsync(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.AcknowledgeCloudEvents"); + scope.Start(); + try + { + using HttpMessage message = CreateAcknowledgeCloudEventsRequest(topicName, eventSubscriptionName, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is successfully acknowledged. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// Event Subscription Name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response AcknowledgeCloudEvents(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.AcknowledgeCloudEvents"); + scope.Start(); + try + { + using HttpMessage message = CreateAcknowledgeCloudEventsRequest(topicName, eventSubscriptionName, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is successfully released. The response body will include the set of successfully released lockTokens, along with other failed lockTokens with their corresponding error information. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// Event Subscription Name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task ReleaseCloudEventsAsync(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.ReleaseCloudEvents"); + scope.Start(); + try + { + using HttpMessage message = CreateReleaseCloudEventsRequest(topicName, eventSubscriptionName, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is successfully released. The response body will include the set of successfully released lockTokens, along with other failed lockTokens with their corresponding error information. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// Event Subscription Name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response ReleaseCloudEvents(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.ReleaseCloudEvents"); + scope.Start(); + try + { + using HttpMessage message = CreateReleaseCloudEventsRequest(topicName, eventSubscriptionName, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Reject batch of Cloud Events. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// Event Subscription Name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task RejectCloudEventsAsync(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.RejectCloudEvents"); + scope.Start(); + try + { + using HttpMessage message = CreateRejectCloudEventsRequest(topicName, eventSubscriptionName, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Reject batch of Cloud Events. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Topic Name. + /// Event Subscription Name. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response RejectCloudEvents(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(topicName, nameof(topicName)); + Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("EventGridClient.RejectCloudEvents"); + scope.Start(); + try + { + using HttpMessage message = CreateRejectCloudEventsRequest(topicName, eventSubscriptionName, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreatePublishCloudEventRequest(string topicName, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/topics/", false); + uri.AppendPath(topicName, true); + uri.AppendPath(":publish", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-type", "application/cloudevents+json; charset=utf-8"); + request.Content = content; + return message; + } + + internal HttpMessage CreatePublishCloudEventsRequest(string topicName, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/topics/", false); + uri.AppendPath(topicName, true); + uri.AppendPath(":publish", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-type", "application/cloudevents-batch+json; charset=utf-8"); + request.Content = content; + return message; + } + + internal HttpMessage CreateReceiveCloudEventsRequest(string topicName, string eventSubscriptionName, int? maxEvents, TimeSpan? maxWaitTime, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/topics/", false); + uri.AppendPath(topicName, true); + uri.AppendPath("/eventsubscriptions/", false); + uri.AppendPath(eventSubscriptionName, true); + uri.AppendPath(":receive", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxEvents != null) + { + uri.AppendQuery("maxEvents", maxEvents.Value, true); + } + if (maxWaitTime != null) + { + uri.AppendQuery("maxWaitTime", maxWaitTime.Value, "%s", true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateAcknowledgeCloudEventsRequest(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/topics/", false); + uri.AppendPath(topicName, true); + uri.AppendPath("/eventsubscriptions/", false); + uri.AppendPath(eventSubscriptionName, true); + uri.AppendPath(":acknowledge", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-type", "application/json; charset=utf-8"); + request.Content = content; + return message; + } + + internal HttpMessage CreateReleaseCloudEventsRequest(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/topics/", false); + uri.AppendPath(topicName, true); + uri.AppendPath("/eventsubscriptions/", false); + uri.AppendPath(eventSubscriptionName, true); + uri.AppendPath(":release", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-type", "application/json; charset=utf-8"); + request.Content = content; + return message; + } + + internal HttpMessage CreateRejectCloudEventsRequest(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/topics/", false); + uri.AppendPath(topicName, true); + uri.AppendPath("/eventsubscriptions/", false); + uri.AppendPath(eventSubscriptionName, true); + uri.AppendPath(":reject", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-type", "application/json; charset=utf-8"); + request.Content = content; + return message; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/EventGridClientOptions.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/EventGridClientOptions.cs new file mode 100644 index 0000000000000..d659a1e2402c4 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/Generated/EventGridClientOptions.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.Messaging.EventGrid.Namespaces +{ + /// Client options for EventGridClient. + public partial class EventGridClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2023_06_01_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2023-06-01-preview". + V2023_06_01_Preview = 1, + } + + internal string Version { get; } + + /// Initializes new instance of EventGridClientOptions. + public EventGridClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2023_06_01_Preview => "2023-06-01-preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/properties/AssemblyInfo.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src/properties/AssemblyInfo.cs new file mode 100644 index 0000000000000..b9713494c255b --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/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.Messaging.EventGrid.Namespaces.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.Eventgrid")] diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/stress/README.md b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/stress/README.md new file mode 100644 index 0000000000000..c563a2c84601c --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/stress/README.md @@ -0,0 +1 @@ +For information on reliability testing with the Azure SDK stress test framework, please refer to the [Reliability testing wiki](https://aka.ms/azsdk/stress). \ No newline at end of file diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Azure.Messaging.EventGrid.Namespaces.Tests.csproj b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Azure.Messaging.EventGrid.Namespaces.Tests.csproj new file mode 100644 index 0000000000000..eebae3cda99b2 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Azure.Messaging.EventGrid.Namespaces.Tests.csproj @@ -0,0 +1,25 @@ + + + $(RequiredTargetFrameworks) + + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Generated/Samples/Samples_EventGridClient.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Generated/Samples/Samples_EventGridClient.cs new file mode 100644 index 0000000000000..220d99fc9b0b7 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Generated/Samples/Samples_EventGridClient.cs @@ -0,0 +1,594 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.Messaging.EventGrid.Namespaces.Samples +{ + public class Samples_EventGridClient + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_PublishCloudEvent() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + id = "", + source = "", + type = "", + specversion = "", + }; + + Response response = client.PublishCloudEvent("", RequestContent.Create(data)); + + Console.WriteLine(response.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_PublishCloudEvent_AllParameters() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + id = "", + source = "", + data = new { }, + data_base64 = new { }, + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", + }; + + Response response = client.PublishCloudEvent("", RequestContent.Create(data), new RequestContext()); + + Console.WriteLine(response.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_PublishCloudEvent_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + id = "", + source = "", + type = "", + specversion = "", + }; + + Response response = await client.PublishCloudEventAsync("", RequestContent.Create(data)); + + Console.WriteLine(response.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_PublishCloudEvent_AllParameters_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + id = "", + source = "", + data = new { }, + data_base64 = new { }, + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", + }; + + Response response = await client.PublishCloudEventAsync("", RequestContent.Create(data), new RequestContext()); + + Console.WriteLine(response.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_PublishCloudEvents() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new[] { + new { + id = "", + source = "", + type = "", + specversion = "", + } +}; + + Response response = client.PublishCloudEvents("", RequestContent.Create(data)); + + Console.WriteLine(response.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_PublishCloudEvents_AllParameters() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new[] { + new { + id = "", + source = "", + data = new {}, + data_base64 = new {}, + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", + } +}; + + Response response = client.PublishCloudEvents("", RequestContent.Create(data), new RequestContext()); + + Console.WriteLine(response.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_PublishCloudEvents_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new[] { + new { + id = "", + source = "", + type = "", + specversion = "", + } +}; + + Response response = await client.PublishCloudEventsAsync("", RequestContent.Create(data)); + + Console.WriteLine(response.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_PublishCloudEvents_AllParameters_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new[] { + new { + id = "", + source = "", + data = new {}, + data_base64 = new {}, + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", + } +}; + + Response response = await client.PublishCloudEventsAsync("", RequestContent.Create(data), new RequestContext()); + + Console.WriteLine(response.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ReceiveCloudEvents() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + Response response = client.ReceiveCloudEvents("", ""); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("deliveryCount").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("source").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("specversion").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ReceiveCloudEvents_AllParameters() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + Response response = client.ReceiveCloudEvents("", "", 1234, new TimeSpan(1, 2, 3), new RequestContext()); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("deliveryCount").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("source").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("data").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("data_base64").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("time").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("specversion").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("dataschema").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("datacontenttype").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("subject").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ReceiveCloudEvents_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + Response response = await client.ReceiveCloudEventsAsync("", ""); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("deliveryCount").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("source").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("specversion").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ReceiveCloudEvents_AllParameters_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + Response response = await client.ReceiveCloudEventsAsync("", "", 1234, new TimeSpan(1, 2, 3), new RequestContext()); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("brokerProperties").GetProperty("deliveryCount").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("source").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("data").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("data_base64").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("time").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("specversion").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("dataschema").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("datacontenttype").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("event").GetProperty("subject").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AcknowledgeCloudEvents() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = client.AcknowledgeCloudEvents("", "", RequestContent.Create(data)); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AcknowledgeCloudEvents_AllParameters() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = client.AcknowledgeCloudEvents("", "", RequestContent.Create(data), new RequestContext()); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AcknowledgeCloudEvents_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = await client.AcknowledgeCloudEventsAsync("", "", RequestContent.Create(data)); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AcknowledgeCloudEvents_AllParameters_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = await client.AcknowledgeCloudEventsAsync("", "", RequestContent.Create(data), new RequestContext()); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ReleaseCloudEvents() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = client.ReleaseCloudEvents("", "", RequestContent.Create(data)); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ReleaseCloudEvents_AllParameters() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = client.ReleaseCloudEvents("", "", RequestContent.Create(data), new RequestContext()); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ReleaseCloudEvents_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = await client.ReleaseCloudEventsAsync("", "", RequestContent.Create(data)); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ReleaseCloudEvents_AllParameters_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = await client.ReleaseCloudEventsAsync("", "", RequestContent.Create(data), new RequestContext()); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RejectCloudEvents() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = client.RejectCloudEvents("", "", RequestContent.Create(data)); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_RejectCloudEvents_AllParameters() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = client.RejectCloudEvents("", "", RequestContent.Create(data), new RequestContext()); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RejectCloudEvents_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = await client.RejectCloudEventsAsync("", "", RequestContent.Create(data)); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_RejectCloudEvents_AllParameters_Async() + { + var credential = new AzureKeyCredential(""); + var endpoint = new Uri(""); + var client = new EventGridClient(endpoint, credential); + + var data = new + { + lockTokens = new[] { + "" + }, + }; + + Response response = await client.RejectCloudEventsAsync("", "", RequestContent.Create(data), new RequestContext()); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorCode").ToString()); + Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("errorDescription").ToString()); + Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString()); + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/NamespacesClientTest.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/NamespacesClientTest.cs new file mode 100644 index 0000000000000..561418336d2b9 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/NamespacesClientTest.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.Messaging.EventGrid.Namespaces.Tests +{ + public class NamespacesClientTest: RecordedTestBase + { + public NamespacesClientTest(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/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/NamespacesClientTestEnvironment.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/NamespacesClientTestEnvironment.cs new file mode 100644 index 0000000000000..118c67e66ee2f --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/NamespacesClientTestEnvironment.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.Messaging.EventGrid.Namespaces.Tests +{ + public class NamespacesClientTestEnvironment : TestEnvironment + { + public string Endpoint => GetRecordedVariable("Namespaces_ENDPOINT"); + + // Add other client paramters here as above. + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Samples/README.md b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Samples/README.md new file mode 100644 index 0000000000000..076844c4620ad --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/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/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples) for more explanation about how to use this client library. diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Samples/Sample1_HelloWorld.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Samples/Sample1_HelloWorld.cs new file mode 100644 index 0000000000000..54831cee04b9a --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Samples/Sample1_HelloWorld.cs @@ -0,0 +1,26 @@ +// 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.Messaging.EventGrid.Namespaces.Tests.Samples +{ + public partial class NamespacesSamples: 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. */ + [Test] + [SyncOnly] + public void Scenario() + { + #region Snippet:Azure_Messaging_EventGrid_Namespaces_Scenario + Console.WriteLine("Hello, world!"); + #endregion + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Samples/Sample1_HelloWorldAsync.cs b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Samples/Sample1_HelloWorldAsync.cs new file mode 100644 index 0000000000000..cec683852fbba --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tests/Samples/Sample1_HelloWorldAsync.cs @@ -0,0 +1,28 @@ +// 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.Messaging.EventGrid.Namespaces.Tests.Samples +{ + public partial class NamespacesSamples: 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. */ + [Test] + [AsyncOnly] + public async Task ScenarioAsync() + { + #region Snippet:Azure_Messaging_EventGrid_Namespaces_ScenarioAsync + Console.WriteLine("Hello, world!"); + #endregion + + await Task.Yield(); + } + } +} diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tsp-location.yaml b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tsp-location.yaml new file mode 100644 index 0000000000000..8a64884fbbb7a --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/tsp-location.yaml @@ -0,0 +1,3 @@ +spec-root-dir: /mnt/vss/_work/1/s/azure-rest-api-specs +directory: specification/eventgrid/Azure.Messaging.EventGrid + diff --git a/sdk/eventgrid/ci.yml b/sdk/eventgrid/ci.yml index 932455529af42..05a7641b802f4 100644 --- a/sdk/eventgrid/ci.yml +++ b/sdk/eventgrid/ci.yml @@ -35,6 +35,8 @@ extends: ServiceDirectory: eventgrid ArtifactName: packages Artifacts: + - name: Azure.Messaging.EventGrid.Namespaces + safeName: AzureMessagingEventGridNamespaces - name: Azure.Messaging.EventGrid safeName: AzureMessagingEventGrid - name: Microsoft.Azure.Messaging.EventGrid.CloudNativeCloudEvents