From 57e612c5acf4c87dc9092643997e43fd6a156825 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 29 Sep 2023 17:43:56 +0000 Subject: [PATCH] CodeGen from PR 26030 in Azure/azure-rest-api-specs Josh love msft patch 2 (#26030) * Update tspconfig.yaml * Update tspconfig.yaml --- .../Azure.Messaging.EventGrid.Namespaces.sln | 56 ++ .../Azure.Messaging.EventGridV2/CHANGELOG.md | 11 + .../Directory.Build.props | 6 + .../Azure.Messaging.EventGridV2/README.md | 86 +++ ...zure.Messaging.EventGrid.Namespaces.csproj | 20 + .../src/Generated/Docs/EventGridClient.xml | 549 ++++++++++++++ .../src/Generated/EventGridClient.cs | 677 ++++++++++++++++++ .../src/Generated/EventGridClientOptions.cs | 37 + ...ntGridNamespacesClientBuilderExtensions.cs | 46 ++ .../src/Properties/AssemblyInfo.cs | 11 + ...essaging.EventGrid.Namespaces.Tests.csproj | 29 + .../Samples/Samples_EventGridClient.cs | 601 ++++++++++++++++ .../tsp-location.yaml | 5 + 13 files changed, 2134 insertions(+) create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/Azure.Messaging.EventGrid.Namespaces.sln create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/CHANGELOG.md create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/Directory.Build.props create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/README.md create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/src/Azure.Messaging.EventGrid.Namespaces.csproj create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/Docs/EventGridClient.xml create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridClient.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridClientOptions.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/MessagingEventGridNamespacesClientBuilderExtensions.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/src/Properties/AssemblyInfo.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Azure.Messaging.EventGrid.Namespaces.Tests.csproj create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Generated/Samples/Samples_EventGridClient.cs create mode 100644 sdk/eventgrid/Azure.Messaging.EventGridV2/tsp-location.yaml diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/Azure.Messaging.EventGrid.Namespaces.sln b/sdk/eventgrid/Azure.Messaging.EventGridV2/Azure.Messaging.EventGrid.Namespaces.sln new file mode 100644 index 000000000000..072dd53b1526 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/Azure.Messaging.EventGrid.Namespaces.sln @@ -0,0 +1,56 @@ +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("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Messaging.EventGrid.Namespaces", "src\Azure.Messaging.EventGrid.Namespaces.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Messaging.EventGrid.Namespaces.Tests", "tests\Azure.Messaging.EventGrid.Namespaces.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +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 + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.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.EventGridV2/CHANGELOG.md b/sdk/eventgrid/Azure.Messaging.EventGridV2/CHANGELOG.md new file mode 100644 index 000000000000..13dd08af78ab --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/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.EventGridV2/Directory.Build.props b/sdk/eventgrid/Azure.Messaging.EventGridV2/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/README.md b/sdk/eventgrid/Azure.Messaging.EventGridV2/README.md new file mode 100644 index 000000000000..474ce96876c2 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/README.md @@ -0,0 +1,86 @@ +# Azure.Messaging.EventGrid.Namespaces client library for .NET + +Azure.Messaging.EventGrid.Namespaces is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [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) | [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). + +## 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) diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Azure.Messaging.EventGrid.Namespaces.csproj b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Azure.Messaging.EventGrid.Namespaces.csproj new file mode 100644 index 000000000000..d33377f0e189 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Azure.Messaging.EventGrid.Namespaces.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.Messaging.EventGrid.Namespaces client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.Messaging.EventGrid.Namespaces for Azure Data Plane + 1.0.0-beta.1 + Azure.Messaging.EventGrid.Namespaces + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/Docs/EventGridClient.xml b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/Docs/EventGridClient.xml new file mode 100644 index 000000000000..8e194209253c --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/Docs/EventGridClient.xml @@ -0,0 +1,549 @@ + + + + + +This sample shows how to call PublishCloudEventAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + id = "", + source = "", + type = "", + specversion = "", +}); +Response response = await client.PublishCloudEventAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call PublishCloudEventAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + id = "", + source = "", + data = new object(), + data_base64 = new object(), + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", +}); +Response response = await client.PublishCloudEventAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call PublishCloudEvent and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + id = "", + source = "", + type = "", + specversion = "", +}); +Response response = client.PublishCloudEvent("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call PublishCloudEvent with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + id = "", + source = "", + data = new object(), + data_base64 = new object(), + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", +}); +Response response = client.PublishCloudEvent("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call PublishCloudEventsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new object[] +{ + new + { + id = "", + source = "", + type = "", + specversion = "", + } +}); +Response response = await client.PublishCloudEventsAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call PublishCloudEventsAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new object[] +{ + new + { + id = "", + source = "", + data = new object(), + data_base64 = new object(), + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", + } +}); +Response response = await client.PublishCloudEventsAsync("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call PublishCloudEvents and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new object[] +{ + new + { + id = "", + source = "", + type = "", + specversion = "", + } +}); +Response response = client.PublishCloudEvents("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> +This sample shows how to call PublishCloudEvents with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new object[] +{ + new + { + id = "", + source = "", + data = new object(), + data_base64 = new object(), + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", + } +}); +Response response = client.PublishCloudEvents("", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call ReceiveCloudEventsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +Response response = await client.ReceiveCloudEventsAsync("", "", null, null, null); + +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 parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +Response response = await client.ReceiveCloudEventsAsync("", "", 1234, TimeSpan.FromSeconds(10), null); + +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 and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +Response response = client.ReceiveCloudEvents("", "", null, null, null); + +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 parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +Response response = client.ReceiveCloudEvents("", "", 1234, TimeSpan.FromSeconds(10), null); + +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 and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = await client.AcknowledgeCloudEventsAsync("", "", content); + +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 AcknowledgeCloudEventsAsync with all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = await client.AcknowledgeCloudEventsAsync("", "", content); + +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 and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = client.AcknowledgeCloudEvents("", "", content); + +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 all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = client.AcknowledgeCloudEvents("", "", content); + +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 and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = await client.ReleaseCloudEventsAsync("", "", content); + +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 all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = await client.ReleaseCloudEventsAsync("", "", content); + +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 and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = client.ReleaseCloudEvents("", "", content); + +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 all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = client.ReleaseCloudEvents("", "", content); + +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 and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = await client.RejectCloudEventsAsync("", "", content); + +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 all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = await client.RejectCloudEventsAsync("", "", content); + +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 and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = client.RejectCloudEvents("", "", content); + +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 all parameters and request content and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +EventGridClient client = new EventGridClient(endpoint, credential); + +RequestContent content = RequestContent.Create(new +{ + lockTokens = new object[] + { + "" + }, +}); +Response response = client.RejectCloudEvents("", "", content); + +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.EventGridV2/src/Generated/EventGridClient.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridClient.cs new file mode 100644 index 000000000000..6dc428560c54 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridClient.cs @@ -0,0 +1,677 @@ +// 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 = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "SharedAccessKey"; + private static readonly string[] AuthorizationScopes = new string[] { "https://eventgrid.azure.net/.default" }; + private readonly TokenCredential _tokenCredential; + 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. + /// or is null. + public EventGridClient(Uri endpoint, TokenCredential 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, AuthorizationApiKeyPrefix) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// 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, TokenCredential credential, EventGridClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new EventGridClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, 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, TimeSpan? maxWaitTime, RequestContext context) + { + 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, TimeSpan? maxWaitTime, RequestContext context) + { + 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"); + 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"); + 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"); + 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.EventGridV2/src/Generated/EventGridClientOptions.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridClientOptions.cs new file mode 100644 index 000000000000..d659a1e2402c --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/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.EventGridV2/src/Generated/MessagingEventGridNamespacesClientBuilderExtensions.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/MessagingEventGridNamespacesClientBuilderExtensions.cs new file mode 100644 index 000000000000..78650a246d3d --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/MessagingEventGridNamespacesClientBuilderExtensions.cs @@ -0,0 +1,46 @@ +// 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 MessagingEventGridNamespacesClientBuilderExtensions + { + /// 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 host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net. + public static IAzureClientBuilder AddEventGridClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new EventGridClient(endpoint, cred, 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.EventGridV2/src/Properties/AssemblyInfo.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..65a47f9167f2 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.Messaging.EventGrid.Namespaces.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.Template")] diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Azure.Messaging.EventGrid.Namespaces.Tests.csproj b/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Azure.Messaging.EventGrid.Namespaces.Tests.csproj new file mode 100644 index 000000000000..a1761d0185be --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Azure.Messaging.EventGrid.Namespaces.Tests.csproj @@ -0,0 +1,29 @@ + + + $(RequiredTargetFrameworks) + + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Generated/Samples/Samples_EventGridClient.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Generated/Samples/Samples_EventGridClient.cs new file mode 100644 index 000000000000..2456e8ff263e --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Generated/Samples/Samples_EventGridClient.cs @@ -0,0 +1,601 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using Azure.Messaging.EventGrid.Namespaces; +using NUnit.Framework; + +namespace Azure.Messaging.EventGrid.Namespaces.Samples +{ + public partial class Samples_EventGridClient + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_PublishCloudEvent_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + id = "", + source = "", + type = "", + specversion = "", + }); + Response response = client.PublishCloudEvent("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_PublishCloudEvent_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + id = "", + source = "", + type = "", + specversion = "", + }); + Response response = await client.PublishCloudEventAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_PublishCloudEvent_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + id = "", + source = "", + data = new object(), + data_base64 = new object(), + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", + }); + Response response = client.PublishCloudEvent("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_PublishCloudEvent_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + id = "", + source = "", + data = new object(), + data_base64 = new object(), + type = "", + time = "2022-05-10T14:57:31.2311892-04:00", + specversion = "", + dataschema = "", + datacontenttype = "", + subject = "", + }); + Response response = await client.PublishCloudEventAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_PublishCloudEvents_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new object[] + { +new +{ +id = "", +source = "", +type = "", +specversion = "", +} + }); + Response response = client.PublishCloudEvents("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_PublishCloudEvents_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new object[] + { +new +{ +id = "", +source = "", +type = "", +specversion = "", +} + }); + Response response = await client.PublishCloudEventsAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_PublishCloudEvents_AllParameters() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new object[] + { +new +{ +id = "", +source = "", +data = new object(), +data_base64 = new object(), +type = "", +time = "2022-05-10T14:57:31.2311892-04:00", +specversion = "", +dataschema = "", +datacontenttype = "", +subject = "", +} + }); + Response response = client.PublishCloudEvents("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_PublishCloudEvents_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new object[] + { +new +{ +id = "", +source = "", +data = new object(), +data_base64 = new object(), +type = "", +time = "2022-05-10T14:57:31.2311892-04:00", +specversion = "", +dataschema = "", +datacontenttype = "", +subject = "", +} + }); + Response response = await client.PublishCloudEventsAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ReceiveCloudEvents_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + Response response = client.ReceiveCloudEvents("", "", null, null, null); + + 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_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + Response response = await client.ReceiveCloudEventsAsync("", "", null, null, null); + + 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() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + Response response = client.ReceiveCloudEvents("", "", 1234, TimeSpan.FromSeconds(10), null); + + 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_AllParameters_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + Response response = await client.ReceiveCloudEventsAsync("", "", 1234, TimeSpan.FromSeconds(10), null); + + 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_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = client.AcknowledgeCloudEvents("", "", content); + + 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_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = await client.AcknowledgeCloudEventsAsync("", "", content); + + 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() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = client.AcknowledgeCloudEvents("", "", content); + + 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() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = await client.AcknowledgeCloudEventsAsync("", "", content); + + 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_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = client.ReleaseCloudEvents("", "", content); + + 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_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = await client.ReleaseCloudEventsAsync("", "", content); + + 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() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = client.ReleaseCloudEvents("", "", content); + + 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() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = await client.ReleaseCloudEventsAsync("", "", content); + + 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_ShortVersion() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = client.RejectCloudEvents("", "", content); + + 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_ShortVersion_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = await client.RejectCloudEventsAsync("", "", content); + + 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() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = client.RejectCloudEvents("", "", content); + + 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() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + EventGridClient client = new EventGridClient(endpoint, credential); + + RequestContent content = RequestContent.Create(new + { + lockTokens = new object[] + { +"" + }, + }); + Response response = await client.RejectCloudEventsAsync("", "", content); + + 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.EventGridV2/tsp-location.yaml b/sdk/eventgrid/Azure.Messaging.EventGridV2/tsp-location.yaml new file mode 100644 index 000000000000..e83d892c25f6 --- /dev/null +++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/tsp-location.yaml @@ -0,0 +1,5 @@ +repo: Azure/azure-rest-api-specs +additionalDirectories: [] +directory: specification/eventgrid/Azure.Messaging.EventGrid +commit: 58b64dbf8ee221bcbd4414649c7fe13914eb72a1 +