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..391d7e850673
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/Azure.Messaging.EventGrid.Namespaces.sln
@@ -0,0 +1,54 @@
+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
+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..8b33f0fedccc
--- /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
\ No newline at end of file
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..469ad554f6f8
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/README.md
@@ -0,0 +1,107 @@
+# 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.
+
+### Service API versions
+
+The client library targets the latest service API version by default. A client instance accepts an optional service API version parameter from its options to specify which API version service to communicate.
+
+#### Select a service API version
+
+You have the flexibility to explicitly select a supported service API version when instantiating a client by configuring its associated options. This ensures that the client can communicate with services using the specified API version.
+
+For example,
+
+```C# Snippet:CreateClientForSpecificApiVersion
+Uri endpoint = new Uri("");
+DefaultAzureCredential credential = new DefaultAzureCredential();
+ClientOptions options = new ClientOptions(ClientOptions.ServiceVersion.)
+var client = new Client(endpoint, credential, options);
+```
+
+When selecting an API version, it's important to verify that there are no breaking changes compared to the latest API version. If there are significant differences, API calls may fail due to incompatibility.
+
+Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy.
+
+## 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
+
+
\ No newline at end of file
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/api/Azure.Messaging.EventGrid.Namespaces.net8.0.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/api/Azure.Messaging.EventGrid.Namespaces.net8.0.cs
new file mode 100644
index 000000000000..19ab2d90251f
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/api/Azure.Messaging.EventGrid.Namespaces.net8.0.cs
@@ -0,0 +1,131 @@
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class AcknowledgeResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
+ {
+ internal AcknowledgeResult() { }
+ public System.Collections.Generic.IReadOnlyList FailedLockTokens { get { throw null; } }
+ public System.Collections.Generic.IReadOnlyList SucceededLockTokens { get { throw null; } }
+ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.AcknowledgeResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.AcknowledgeResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ }
+ public partial class AzureMessagingEventGridNamespacesClientOptions : Azure.Core.ClientOptions
+ {
+ public AzureMessagingEventGridNamespacesClientOptions(Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions.ServiceVersion version = Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions.ServiceVersion.V2024_06_01) { }
+ public enum ServiceVersion
+ {
+ V2023_11_01 = 1,
+ V2024_06_01 = 2,
+ }
+ }
+ public partial class EventGridReceiverClient
+ {
+ protected EventGridReceiverClient() { }
+ public EventGridReceiverClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { }
+ public EventGridReceiverClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions options) { }
+ public EventGridReceiverClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { }
+ public EventGridReceiverClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions options) { }
+ public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } }
+ }
+ public partial class EventGridSenderClient
+ {
+ protected EventGridSenderClient() { }
+ public EventGridSenderClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { }
+ public EventGridSenderClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions options) { }
+ public EventGridSenderClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { }
+ public EventGridSenderClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions options) { }
+ public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } }
+ }
+ public partial class FailedLockToken : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
+ {
+ internal FailedLockToken() { }
+ public Azure.ResponseError Error { get { throw null; } }
+ public string LockToken { get { throw null; } }
+ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.FailedLockToken System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.FailedLockToken System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ }
+ public static partial class MessagingEventGridNamespacesModelFactory
+ {
+ public static Azure.Messaging.EventGrid.Namespaces.AcknowledgeResult AcknowledgeResult(System.Collections.Generic.IEnumerable failedLockTokens = null, System.Collections.Generic.IEnumerable succeededLockTokens = null) { throw null; }
+ public static Azure.Messaging.EventGrid.Namespaces.FailedLockToken FailedLockToken(string lockToken = null, Azure.ResponseError error = null) { throw null; }
+ public static Azure.Messaging.EventGrid.Namespaces.RejectResult RejectResult(System.Collections.Generic.IEnumerable failedLockTokens = null, System.Collections.Generic.IEnumerable succeededLockTokens = null) { throw null; }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseResult ReleaseResult(System.Collections.Generic.IEnumerable failedLockTokens = null, System.Collections.Generic.IEnumerable succeededLockTokens = null) { throw null; }
+ public static Azure.Messaging.EventGrid.Namespaces.RenewLocksResult RenewLocksResult(System.Collections.Generic.IEnumerable failedLockTokens = null, System.Collections.Generic.IEnumerable succeededLockTokens = null) { throw null; }
+ }
+ public partial class RejectResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
+ {
+ internal RejectResult() { }
+ public System.Collections.Generic.IReadOnlyList FailedLockTokens { get { throw null; } }
+ public System.Collections.Generic.IReadOnlyList SucceededLockTokens { get { throw null; } }
+ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.RejectResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.RejectResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ }
+ [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
+ public readonly partial struct ReleaseDelay : System.IEquatable
+ {
+ private readonly object _dummy;
+ private readonly int _dummyPrimitive;
+ public ReleaseDelay(string value) { throw null; }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseDelay NoDelay { get { throw null; } }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseDelay OneHour { get { throw null; } }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseDelay OneMinute { get { throw null; } }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseDelay TenMinutes { get { throw null; } }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseDelay TenSeconds { get { throw null; } }
+ public bool Equals(Azure.Messaging.EventGrid.Namespaces.ReleaseDelay other) { throw null; }
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ public override bool Equals(object obj) { throw null; }
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ public override int GetHashCode() { throw null; }
+ public static bool operator ==(Azure.Messaging.EventGrid.Namespaces.ReleaseDelay left, Azure.Messaging.EventGrid.Namespaces.ReleaseDelay right) { throw null; }
+ public static implicit operator Azure.Messaging.EventGrid.Namespaces.ReleaseDelay (string value) { throw null; }
+ public static bool operator !=(Azure.Messaging.EventGrid.Namespaces.ReleaseDelay left, Azure.Messaging.EventGrid.Namespaces.ReleaseDelay right) { throw null; }
+ public override string ToString() { throw null; }
+ }
+ public partial class ReleaseResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
+ {
+ internal ReleaseResult() { }
+ public System.Collections.Generic.IReadOnlyList FailedLockTokens { get { throw null; } }
+ public System.Collections.Generic.IReadOnlyList SucceededLockTokens { get { throw null; } }
+ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.ReleaseResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.ReleaseResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ }
+ public partial class RenewLocksResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
+ {
+ internal RenewLocksResult() { }
+ public System.Collections.Generic.IReadOnlyList FailedLockTokens { get { throw null; } }
+ public System.Collections.Generic.IReadOnlyList SucceededLockTokens { get { throw null; } }
+ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.RenewLocksResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.RenewLocksResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ }
+}
+namespace Microsoft.Extensions.Azure
+{
+ public static partial class MessagingEventGridNamespacesClientBuilderExtensions
+ {
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridReceiverClient(this TBuilder builder, System.Uri endpoint) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithCredential { throw null; }
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridReceiverClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; }
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridReceiverClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; }
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridSenderClient(this TBuilder builder, System.Uri endpoint) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithCredential { throw null; }
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridSenderClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; }
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridSenderClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/api/Azure.Messaging.EventGrid.Namespaces.netstandard2.0.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/api/Azure.Messaging.EventGrid.Namespaces.netstandard2.0.cs
new file mode 100644
index 000000000000..19ab2d90251f
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/api/Azure.Messaging.EventGrid.Namespaces.netstandard2.0.cs
@@ -0,0 +1,131 @@
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class AcknowledgeResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
+ {
+ internal AcknowledgeResult() { }
+ public System.Collections.Generic.IReadOnlyList FailedLockTokens { get { throw null; } }
+ public System.Collections.Generic.IReadOnlyList SucceededLockTokens { get { throw null; } }
+ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.AcknowledgeResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.AcknowledgeResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ }
+ public partial class AzureMessagingEventGridNamespacesClientOptions : Azure.Core.ClientOptions
+ {
+ public AzureMessagingEventGridNamespacesClientOptions(Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions.ServiceVersion version = Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions.ServiceVersion.V2024_06_01) { }
+ public enum ServiceVersion
+ {
+ V2023_11_01 = 1,
+ V2024_06_01 = 2,
+ }
+ }
+ public partial class EventGridReceiverClient
+ {
+ protected EventGridReceiverClient() { }
+ public EventGridReceiverClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { }
+ public EventGridReceiverClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions options) { }
+ public EventGridReceiverClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { }
+ public EventGridReceiverClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions options) { }
+ public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } }
+ }
+ public partial class EventGridSenderClient
+ {
+ protected EventGridSenderClient() { }
+ public EventGridSenderClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { }
+ public EventGridSenderClient(System.Uri endpoint, Azure.AzureKeyCredential credential, Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions options) { }
+ public EventGridSenderClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { }
+ public EventGridSenderClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Messaging.EventGrid.Namespaces.AzureMessagingEventGridNamespacesClientOptions options) { }
+ public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } }
+ }
+ public partial class FailedLockToken : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
+ {
+ internal FailedLockToken() { }
+ public Azure.ResponseError Error { get { throw null; } }
+ public string LockToken { get { throw null; } }
+ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.FailedLockToken System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.FailedLockToken System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ }
+ public static partial class MessagingEventGridNamespacesModelFactory
+ {
+ public static Azure.Messaging.EventGrid.Namespaces.AcknowledgeResult AcknowledgeResult(System.Collections.Generic.IEnumerable failedLockTokens = null, System.Collections.Generic.IEnumerable succeededLockTokens = null) { throw null; }
+ public static Azure.Messaging.EventGrid.Namespaces.FailedLockToken FailedLockToken(string lockToken = null, Azure.ResponseError error = null) { throw null; }
+ public static Azure.Messaging.EventGrid.Namespaces.RejectResult RejectResult(System.Collections.Generic.IEnumerable failedLockTokens = null, System.Collections.Generic.IEnumerable succeededLockTokens = null) { throw null; }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseResult ReleaseResult(System.Collections.Generic.IEnumerable failedLockTokens = null, System.Collections.Generic.IEnumerable succeededLockTokens = null) { throw null; }
+ public static Azure.Messaging.EventGrid.Namespaces.RenewLocksResult RenewLocksResult(System.Collections.Generic.IEnumerable failedLockTokens = null, System.Collections.Generic.IEnumerable succeededLockTokens = null) { throw null; }
+ }
+ public partial class RejectResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
+ {
+ internal RejectResult() { }
+ public System.Collections.Generic.IReadOnlyList FailedLockTokens { get { throw null; } }
+ public System.Collections.Generic.IReadOnlyList SucceededLockTokens { get { throw null; } }
+ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.RejectResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.RejectResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ }
+ [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
+ public readonly partial struct ReleaseDelay : System.IEquatable
+ {
+ private readonly object _dummy;
+ private readonly int _dummyPrimitive;
+ public ReleaseDelay(string value) { throw null; }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseDelay NoDelay { get { throw null; } }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseDelay OneHour { get { throw null; } }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseDelay OneMinute { get { throw null; } }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseDelay TenMinutes { get { throw null; } }
+ public static Azure.Messaging.EventGrid.Namespaces.ReleaseDelay TenSeconds { get { throw null; } }
+ public bool Equals(Azure.Messaging.EventGrid.Namespaces.ReleaseDelay other) { throw null; }
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ public override bool Equals(object obj) { throw null; }
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ public override int GetHashCode() { throw null; }
+ public static bool operator ==(Azure.Messaging.EventGrid.Namespaces.ReleaseDelay left, Azure.Messaging.EventGrid.Namespaces.ReleaseDelay right) { throw null; }
+ public static implicit operator Azure.Messaging.EventGrid.Namespaces.ReleaseDelay (string value) { throw null; }
+ public static bool operator !=(Azure.Messaging.EventGrid.Namespaces.ReleaseDelay left, Azure.Messaging.EventGrid.Namespaces.ReleaseDelay right) { throw null; }
+ public override string ToString() { throw null; }
+ }
+ public partial class ReleaseResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
+ {
+ internal ReleaseResult() { }
+ public System.Collections.Generic.IReadOnlyList FailedLockTokens { get { throw null; } }
+ public System.Collections.Generic.IReadOnlyList SucceededLockTokens { get { throw null; } }
+ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.ReleaseResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.ReleaseResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ }
+ public partial class RenewLocksResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
+ {
+ internal RenewLocksResult() { }
+ public System.Collections.Generic.IReadOnlyList FailedLockTokens { get { throw null; } }
+ public System.Collections.Generic.IReadOnlyList SucceededLockTokens { get { throw null; } }
+ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.RenewLocksResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
+ Azure.Messaging.EventGrid.Namespaces.RenewLocksResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
+ }
+}
+namespace Microsoft.Extensions.Azure
+{
+ public static partial class MessagingEventGridNamespacesClientBuilderExtensions
+ {
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridReceiverClient(this TBuilder builder, System.Uri endpoint) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithCredential { throw null; }
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridReceiverClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; }
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridReceiverClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; }
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridSenderClient(this TBuilder builder, System.Uri endpoint) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithCredential { throw null; }
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridSenderClient(this TBuilder builder, System.Uri endpoint, Azure.AzureKeyCredential credential) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilder { throw null; }
+ public static Azure.Core.Extensions.IAzureClientBuilder AddEventGridSenderClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; }
+ }
+}
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..63c432e943e1
--- /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/AcknowledgeRequest.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeRequest.Serialization.cs
new file mode 100644
index 000000000000..3a9b9f5a0937
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeRequest.Serialization.cs
@@ -0,0 +1,152 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ internal partial class AcknowledgeRequest : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AcknowledgeRequest)} does not support writing '{format}' format.");
+ }
+
+ writer.WritePropertyName("lockTokens"u8);
+ writer.WriteStartArray();
+ foreach (var item in LockTokens)
+ {
+ writer.WriteStringValue(item);
+ }
+ writer.WriteEndArray();
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ AcknowledgeRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AcknowledgeRequest)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAcknowledgeRequest(document.RootElement, options);
+ }
+
+ internal static AcknowledgeRequest DeserializeAcknowledgeRequest(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ IReadOnlyList lockTokens = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("lockTokens"u8))
+ {
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(item.GetString());
+ }
+ lockTokens = array;
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new AcknowledgeRequest(lockTokens, serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(AcknowledgeRequest)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AcknowledgeRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAcknowledgeRequest(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AcknowledgeRequest)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static AcknowledgeRequest FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAcknowledgeRequest(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeRequest.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeRequest.cs
new file mode 100644
index 000000000000..da487d167f8b
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeRequest.cs
@@ -0,0 +1,76 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// The AcknowledgeRequest.
+ internal partial class AcknowledgeRequest
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ /// Array of lock tokens.
+ /// is null.
+ internal AcknowledgeRequest(IEnumerable lockTokens)
+ {
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ LockTokens = lockTokens.ToList();
+ }
+
+ /// Initializes a new instance of .
+ /// Array of lock tokens.
+ /// Keeps track of any properties unknown to the library.
+ internal AcknowledgeRequest(IReadOnlyList lockTokens, IDictionary serializedAdditionalRawData)
+ {
+ LockTokens = lockTokens;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal AcknowledgeRequest()
+ {
+ }
+
+ /// Array of lock tokens.
+ public IReadOnlyList LockTokens { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeResult.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeResult.Serialization.cs
new file mode 100644
index 000000000000..87709aa7147d
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeResult.Serialization.cs
@@ -0,0 +1,170 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class AcknowledgeResult : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AcknowledgeResult)} does not support writing '{format}' format.");
+ }
+
+ writer.WritePropertyName("failedLockTokens"u8);
+ writer.WriteStartArray();
+ foreach (var item in FailedLockTokens)
+ {
+ writer.WriteObjectValue(item, options);
+ }
+ writer.WriteEndArray();
+ writer.WritePropertyName("succeededLockTokens"u8);
+ writer.WriteStartArray();
+ foreach (var item in SucceededLockTokens)
+ {
+ writer.WriteStringValue(item);
+ }
+ writer.WriteEndArray();
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ AcknowledgeResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(AcknowledgeResult)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeAcknowledgeResult(document.RootElement, options);
+ }
+
+ internal static AcknowledgeResult DeserializeAcknowledgeResult(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ IReadOnlyList failedLockTokens = default;
+ IReadOnlyList succeededLockTokens = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("failedLockTokens"u8))
+ {
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(FailedLockToken.DeserializeFailedLockToken(item, options));
+ }
+ failedLockTokens = array;
+ continue;
+ }
+ if (property.NameEquals("succeededLockTokens"u8))
+ {
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(item.GetString());
+ }
+ succeededLockTokens = array;
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new AcknowledgeResult(failedLockTokens, succeededLockTokens, serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(AcknowledgeResult)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ AcknowledgeResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAcknowledgeResult(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(AcknowledgeResult)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static AcknowledgeResult FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeAcknowledgeResult(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeResult.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeResult.cs
new file mode 100644
index 000000000000..a30895c4a023
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeResult.cs
@@ -0,0 +1,83 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// The result of the Acknowledge operation.
+ public partial class AcknowledgeResult
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ /// Array of FailedLockToken for failed cloud events. Each FailedLockToken includes the lock token along with the related error information (namely, the error code and description).
+ /// Array of lock tokens for the successfully acknowledged cloud events.
+ /// or is null.
+ internal AcknowledgeResult(IEnumerable failedLockTokens, IEnumerable succeededLockTokens)
+ {
+ Argument.AssertNotNull(failedLockTokens, nameof(failedLockTokens));
+ Argument.AssertNotNull(succeededLockTokens, nameof(succeededLockTokens));
+
+ FailedLockTokens = failedLockTokens.ToList();
+ SucceededLockTokens = succeededLockTokens.ToList();
+ }
+
+ /// Initializes a new instance of .
+ /// Array of FailedLockToken for failed cloud events. Each FailedLockToken includes the lock token along with the related error information (namely, the error code and description).
+ /// Array of lock tokens for the successfully acknowledged cloud events.
+ /// Keeps track of any properties unknown to the library.
+ internal AcknowledgeResult(IReadOnlyList failedLockTokens, IReadOnlyList succeededLockTokens, IDictionary serializedAdditionalRawData)
+ {
+ FailedLockTokens = failedLockTokens;
+ SucceededLockTokens = succeededLockTokens;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal AcknowledgeResult()
+ {
+ }
+
+ /// Array of FailedLockToken for failed cloud events. Each FailedLockToken includes the lock token along with the related error information (namely, the error code and description).
+ public IReadOnlyList FailedLockTokens { get; }
+ /// Array of lock tokens for the successfully acknowledged cloud events.
+ public IReadOnlyList SucceededLockTokens { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AzureMessagingEventGridNamespacesClientOptions.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AzureMessagingEventGridNamespacesClientOptions.cs
new file mode 100644
index 000000000000..028d63a6a191
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AzureMessagingEventGridNamespacesClientOptions.cs
@@ -0,0 +1,40 @@
+// 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 Azure.Messaging.EventGrid.Namespaces library clients.
+ public partial class AzureMessagingEventGridNamespacesClientOptions : ClientOptions
+ {
+ private const ServiceVersion LatestVersion = ServiceVersion.V2024_06_01;
+
+ /// The version of the service to use.
+ public enum ServiceVersion
+ {
+ /// Service version "2023-11-01".
+ V2023_11_01 = 1,
+ /// Service version "2024-06-01".
+ V2024_06_01 = 2,
+ }
+
+ internal string Version { get; }
+
+ /// Initializes new instance of AzureMessagingEventGridNamespacesClientOptions.
+ public AzureMessagingEventGridNamespacesClientOptions(ServiceVersion version = LatestVersion)
+ {
+ Version = version switch
+ {
+ ServiceVersion.V2023_11_01 => "2023-11-01",
+ ServiceVersion.V2024_06_01 => "2024-06-01",
+ _ => throw new NotSupportedException()
+ };
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/BrokerProperties.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/BrokerProperties.Serialization.cs
new file mode 100644
index 000000000000..bc10318d0710
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/BrokerProperties.Serialization.cs
@@ -0,0 +1,150 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ internal partial class BrokerProperties : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(BrokerProperties)} does not support writing '{format}' format.");
+ }
+
+ writer.WritePropertyName("lockToken"u8);
+ writer.WriteStringValue(LockToken);
+ writer.WritePropertyName("deliveryCount"u8);
+ writer.WriteNumberValue(DeliveryCount);
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ BrokerProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(BrokerProperties)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeBrokerProperties(document.RootElement, options);
+ }
+
+ internal static BrokerProperties DeserializeBrokerProperties(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string lockToken = default;
+ int deliveryCount = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("lockToken"u8))
+ {
+ lockToken = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("deliveryCount"u8))
+ {
+ deliveryCount = property.Value.GetInt32();
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new BrokerProperties(lockToken, deliveryCount, serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(BrokerProperties)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ BrokerProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeBrokerProperties(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(BrokerProperties)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static BrokerProperties FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeBrokerProperties(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/BrokerProperties.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/BrokerProperties.cs
new file mode 100644
index 000000000000..78d00f1266d5
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/BrokerProperties.cs
@@ -0,0 +1,81 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Properties of the Event Broker operation.
+ internal partial class BrokerProperties
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ /// The token of the lock on the event.
+ /// The attempt count for delivering the event.
+ /// is null.
+ internal BrokerProperties(string lockToken, int deliveryCount)
+ {
+ Argument.AssertNotNull(lockToken, nameof(lockToken));
+
+ LockToken = lockToken;
+ DeliveryCount = deliveryCount;
+ }
+
+ /// Initializes a new instance of .
+ /// The token of the lock on the event.
+ /// The attempt count for delivering the event.
+ /// Keeps track of any properties unknown to the library.
+ internal BrokerProperties(string lockToken, int deliveryCount, IDictionary serializedAdditionalRawData)
+ {
+ LockToken = lockToken;
+ DeliveryCount = deliveryCount;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal BrokerProperties()
+ {
+ }
+
+ /// The token of the lock on the event.
+ public string LockToken { get; }
+ /// The attempt count for delivering the event.
+ public int DeliveryCount { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/CloudEvent.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/CloudEvent.Serialization.cs
new file mode 100644
index 000000000000..054c9263ef81
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/CloudEvent.Serialization.cs
@@ -0,0 +1,262 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ internal partial class CloudEvent : IUtf8JsonSerializable, IJsonModel
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions);
+
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(CloudEvent)} does not support writing '{format}' format.");
+ }
+
+ writer.WritePropertyName("id"u8);
+ writer.WriteStringValue(Id);
+ writer.WritePropertyName("source"u8);
+ writer.WriteStringValue(Source);
+ if (Optional.IsDefined(Data))
+ {
+ writer.WritePropertyName("data"u8);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(Data);
+#else
+ using (JsonDocument document = JsonDocument.Parse(Data, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ if (Optional.IsDefined(DataBase64))
+ {
+ writer.WritePropertyName("data_base64"u8);
+ writer.WriteBase64StringValue(DataBase64.ToArray(), "D");
+ }
+ writer.WritePropertyName("type"u8);
+ writer.WriteStringValue(Type);
+ if (Optional.IsDefined(Time))
+ {
+ writer.WritePropertyName("time"u8);
+ writer.WriteStringValue(Time.Value, "O");
+ }
+ writer.WritePropertyName("specversion"u8);
+ writer.WriteStringValue(Specversion);
+ if (Optional.IsDefined(Dataschema))
+ {
+ writer.WritePropertyName("dataschema"u8);
+ writer.WriteStringValue(Dataschema);
+ }
+ if (Optional.IsDefined(Datacontenttype))
+ {
+ writer.WritePropertyName("datacontenttype"u8);
+ writer.WriteStringValue(Datacontenttype);
+ }
+ if (Optional.IsDefined(Subject))
+ {
+ writer.WritePropertyName("subject"u8);
+ writer.WriteStringValue(Subject);
+ }
+ if (options.Format != "W" && _serializedAdditionalRawData != null)
+ {
+ foreach (var item in _serializedAdditionalRawData)
+ {
+ writer.WritePropertyName(item.Key);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(item.Value);
+#else
+ using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ JsonSerializer.Serialize(writer, document.RootElement);
+ }
+#endif
+ }
+ }
+ }
+
+ CloudEvent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(CloudEvent)} does not support reading '{format}' format.");
+ }
+
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeCloudEvent(document.RootElement, options);
+ }
+
+ internal static CloudEvent DeserializeCloudEvent(JsonElement element, ModelReaderWriterOptions options = null)
+ {
+ options ??= ModelSerializationExtensions.WireOptions;
+
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string id = default;
+ string source = default;
+ BinaryData data = default;
+ BinaryData dataBase64 = default;
+ string type = default;
+ DateTimeOffset? time = default;
+ string specversion = default;
+ string dataschema = default;
+ string datacontenttype = default;
+ string subject = default;
+ IDictionary serializedAdditionalRawData = default;
+ Dictionary rawDataDictionary = new Dictionary();
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("id"u8))
+ {
+ id = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("source"u8))
+ {
+ source = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("data"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ data = BinaryData.FromString(property.Value.GetRawText());
+ continue;
+ }
+ if (property.NameEquals("data_base64"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ dataBase64 = BinaryData.FromBytes(property.Value.GetBytesFromBase64("D"));
+ continue;
+ }
+ if (property.NameEquals("type"u8))
+ {
+ type = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("time"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ time = property.Value.GetDateTimeOffset("O");
+ continue;
+ }
+ if (property.NameEquals("specversion"u8))
+ {
+ specversion = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("dataschema"u8))
+ {
+ dataschema = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("datacontenttype"u8))
+ {
+ datacontenttype = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("subject"u8))
+ {
+ subject = property.Value.GetString();
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText()));
+ }
+ }
+ serializedAdditionalRawData = rawDataDictionary;
+ return new CloudEvent(
+ id,
+ source,
+ data,
+ dataBase64,
+ type,
+ time,
+ specversion,
+ dataschema,
+ datacontenttype,
+ subject,
+ serializedAdditionalRawData);
+ }
+
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options);
+ default:
+ throw new FormatException($"The model {nameof(CloudEvent)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ CloudEvent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options)
+ {
+ var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+
+ switch (format)
+ {
+ case "J":
+ {
+ using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeCloudEvent(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(CloudEvent)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static CloudEvent FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeCloudEvent(document.RootElement);
+ }
+
+ /// Convert into a .
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions);
+ return content;
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/CloudEvent.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/CloudEvent.cs
new file mode 100644
index 000000000000..6d49af6075dd
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/CloudEvent.cs
@@ -0,0 +1,164 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Properties of an event published to an Azure Messaging EventGrid Namespace topic using the CloudEvent 1.0 Schema.
+ internal partial class CloudEvent
+ {
+ ///
+ /// Keeps track of any properties unknown to the library.
+ ///
+ /// To assign an object to the value of this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ private IDictionary _serializedAdditionalRawData;
+
+ /// Initializes a new instance of .
+ /// An identifier for the event. The combination of id and source must be unique for each distinct event.
+ /// Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event.
+ /// Type of event related to the originating occurrence.
+ /// The version of the CloudEvents specification which the event uses.
+ /// , , or is null.
+ public CloudEvent(string id, string source, string type, string specversion)
+ {
+ Argument.AssertNotNull(id, nameof(id));
+ Argument.AssertNotNull(source, nameof(source));
+ Argument.AssertNotNull(type, nameof(type));
+ Argument.AssertNotNull(specversion, nameof(specversion));
+
+ Id = id;
+ Source = source;
+ Type = type;
+ Specversion = specversion;
+ }
+
+ /// Initializes a new instance of .
+ /// An identifier for the event. The combination of id and source must be unique for each distinct event.
+ /// Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event.
+ /// Event data specific to the event type.
+ /// Event data specific to the event type, encoded as a base64 string.
+ /// Type of event related to the originating occurrence.
+ /// The time (in UTC) the event was generated, in RFC3339 format.
+ /// The version of the CloudEvents specification which the event uses.
+ /// Identifies the schema that data adheres to.
+ /// Content type of data value.
+ /// This describes the subject of the event in the context of the event producer (identified by source).
+ /// Keeps track of any properties unknown to the library.
+ internal CloudEvent(string id, string source, BinaryData data, BinaryData dataBase64, string type, DateTimeOffset? time, string specversion, string dataschema, string datacontenttype, string subject, IDictionary serializedAdditionalRawData)
+ {
+ Id = id;
+ Source = source;
+ Data = data;
+ DataBase64 = dataBase64;
+ Type = type;
+ Time = time;
+ Specversion = specversion;
+ Dataschema = dataschema;
+ Datacontenttype = datacontenttype;
+ Subject = subject;
+ _serializedAdditionalRawData = serializedAdditionalRawData;
+ }
+
+ /// Initializes a new instance of for deserialization.
+ internal CloudEvent()
+ {
+ }
+
+ /// An identifier for the event. The combination of id and source must be unique for each distinct event.
+ public string Id { get; set; }
+ /// Identifies the context in which an event happened. The combination of id and source must be unique for each distinct event.
+ public string Source { get; set; }
+ ///
+ /// Event data specific to the event type.
+ ///
+ /// To assign an object to this property use .
+ ///
+ ///
+ /// To assign an already formatted json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ public BinaryData Data { get; set; }
+ ///
+ /// Event data specific to the event type, encoded as a base64 string.
+ ///
+ /// To assign a byte[] to this property use .
+ /// The byte[] will be serialized to a Base64 encoded string.
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromBytes(new byte[] { 1, 2, 3 })
+ /// Creates a payload of "AQID".
+ ///
+ ///
+ ///
+ ///
+ public BinaryData DataBase64 { get; set; }
+ /// Type of event related to the originating occurrence.
+ public string Type { get; set; }
+ /// The time (in UTC) the event was generated, in RFC3339 format.
+ public DateTimeOffset? Time { get; set; }
+ /// The version of the CloudEvents specification which the event uses.
+ public string Specversion { get; set; }
+ /// Identifies the schema that data adheres to.
+ public string Dataschema { get; set; }
+ /// Content type of data value.
+ public string Datacontenttype { get; set; }
+ /// This describes the subject of the event in the context of the event producer (identified by source).
+ public string Subject { get; set; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridReceiverClient.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridReceiverClient.cs
new file mode 100644
index 000000000000..43b45c5c3811
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridReceiverClient.cs
@@ -0,0 +1,840 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure.Core;
+using Azure.Core.Pipeline;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ // Data plane generated client.
+ /// The EventGridReceiver service client.
+ public partial class EventGridReceiverClient
+ {
+ 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 EventGridReceiverClient for mocking.
+ protected EventGridReceiverClient()
+ {
+ }
+
+ /// Initializes a new instance of EventGridReceiverClient.
+ /// 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 EventGridReceiverClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AzureMessagingEventGridNamespacesClientOptions())
+ {
+ }
+
+ /// Initializes a new instance of EventGridReceiverClient.
+ /// 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 EventGridReceiverClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AzureMessagingEventGridNamespacesClientOptions())
+ {
+ }
+
+ /// Initializes a new instance of EventGridReceiverClient.
+ /// 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 EventGridReceiverClient(Uri endpoint, AzureKeyCredential credential, AzureMessagingEventGridNamespacesClientOptions options)
+ {
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNull(credential, nameof(credential));
+ options ??= new AzureMessagingEventGridNamespacesClientOptions();
+
+ 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 EventGridReceiverClient.
+ /// 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 EventGridReceiverClient(Uri endpoint, TokenCredential credential, AzureMessagingEventGridNamespacesClientOptions options)
+ {
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNull(credential, nameof(credential));
+ options ??= new AzureMessagingEventGridNamespacesClientOptions();
+
+ 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;
+ }
+
+ /// Receive a batch of Cloud Events from a subscription.
+ /// 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 cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual async Task> ReceiveAsync(string topicName, string eventSubscriptionName, int? maxEvents = null, TimeSpan? maxWaitTime = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await ReceiveAsync(topicName, eventSubscriptionName, maxEvents, maxWaitTime, context).ConfigureAwait(false);
+ return Response.FromValue(ReceiveResult.FromResponse(response), response);
+ }
+
+ /// Receive a batch of Cloud Events from a subscription.
+ /// 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 cancellation token to use.
+ /// or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual Response Receive(string topicName, string eventSubscriptionName, int? maxEvents = null, TimeSpan? maxWaitTime = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = Receive(topicName, eventSubscriptionName, maxEvents, maxWaitTime, context);
+ return Response.FromValue(ReceiveResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Receive a batch of Cloud Events from a subscription.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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.
+ internal virtual async Task ReceiveAsync(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("EventGridReceiverClient.Receive");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateReceiveRequest(topicName, eventSubscriptionName, maxEvents, maxWaitTime, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Receive a batch of Cloud Events from a subscription.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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.
+ internal virtual Response Receive(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("EventGridReceiverClient.Receive");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateReceiveRequest(topicName, eventSubscriptionName, maxEvents, maxWaitTime, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Acknowledge a batch of Cloud Events. The response will include the set of successfully acknowledged lock tokens, along with other failed lock tokens with their corresponding error information. Successfully acknowledged events will no longer be available to be received by any consumer.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// Array of lock tokens.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual async Task> AcknowledgeAsync(string topicName, string eventSubscriptionName, IEnumerable lockTokens, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ AcknowledgeRequest acknowledgeRequest = new AcknowledgeRequest(lockTokens.ToList(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await AcknowledgeAsync(topicName, eventSubscriptionName, acknowledgeRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(AcknowledgeResult.FromResponse(response), response);
+ }
+
+ /// Acknowledge a batch of Cloud Events. The response will include the set of successfully acknowledged lock tokens, along with other failed lock tokens with their corresponding error information. Successfully acknowledged events will no longer be available to be received by any consumer.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// Array of lock tokens.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual Response Acknowledge(string topicName, string eventSubscriptionName, IEnumerable lockTokens, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ AcknowledgeRequest acknowledgeRequest = new AcknowledgeRequest(lockTokens.ToList(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = Acknowledge(topicName, eventSubscriptionName, acknowledgeRequest.ToRequestContent(), context);
+ return Response.FromValue(AcknowledgeResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Acknowledge a batch of Cloud Events. The response will include the set of successfully acknowledged lock tokens, along with other failed lock tokens with their corresponding error information. Successfully acknowledged events will no longer be available to be received by any consumer.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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.
+ internal virtual async Task AcknowledgeAsync(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("EventGridReceiverClient.Acknowledge");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateAcknowledgeRequest(topicName, eventSubscriptionName, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Acknowledge a batch of Cloud Events. The response will include the set of successfully acknowledged lock tokens, along with other failed lock tokens with their corresponding error information. Successfully acknowledged events will no longer be available to be received by any consumer.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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.
+ internal virtual Response Acknowledge(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("EventGridReceiverClient.Acknowledge");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateAcknowledgeRequest(topicName, eventSubscriptionName, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along with other failed lock tokens with their corresponding error information. Successfully released events can be received by consumers.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// Array of lock tokens.
+ /// Release cloud events with the specified delay in seconds.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual async Task> ReleaseAsync(string topicName, string eventSubscriptionName, IEnumerable lockTokens, ReleaseDelay? releaseDelayInSeconds = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ ReleaseRequest releaseRequest = new ReleaseRequest(lockTokens.ToList(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await ReleaseAsync(topicName, eventSubscriptionName, releaseRequest.ToRequestContent(), releaseDelayInSeconds?.ToString(), context).ConfigureAwait(false);
+ return Response.FromValue(ReleaseResult.FromResponse(response), response);
+ }
+
+ /// Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along with other failed lock tokens with their corresponding error information. Successfully released events can be received by consumers.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// Array of lock tokens.
+ /// Release cloud events with the specified delay in seconds.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual Response Release(string topicName, string eventSubscriptionName, IEnumerable lockTokens, ReleaseDelay? releaseDelayInSeconds = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ ReleaseRequest releaseRequest = new ReleaseRequest(lockTokens.ToList(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = Release(topicName, eventSubscriptionName, releaseRequest.ToRequestContent(), releaseDelayInSeconds?.ToString(), context);
+ return Response.FromValue(ReleaseResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along with other failed lock tokens with their corresponding error information. Successfully released events can be received by consumers.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// The content to send as the body of the request.
+ /// Release cloud events with the specified delay in seconds. Allowed values: "0" | "10" | "60" | "600" | "3600".
+ /// 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.
+ internal virtual async Task ReleaseAsync(string topicName, string eventSubscriptionName, RequestContent content, string releaseDelayInSeconds = null, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridReceiverClient.Release");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateReleaseRequest(topicName, eventSubscriptionName, content, releaseDelayInSeconds, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Release a batch of Cloud Events. The response will include the set of successfully released lock tokens, along with other failed lock tokens with their corresponding error information. Successfully released events can be received by consumers.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// The content to send as the body of the request.
+ /// Release cloud events with the specified delay in seconds. Allowed values: "0" | "10" | "60" | "600" | "3600".
+ /// 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.
+ internal virtual Response Release(string topicName, string eventSubscriptionName, RequestContent content, string releaseDelayInSeconds = null, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridReceiverClient.Release");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateReleaseRequest(topicName, eventSubscriptionName, content, releaseDelayInSeconds, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Reject a batch of Cloud Events. The response will include the set of successfully rejected lock tokens, along with other failed lock tokens with their corresponding error information. Successfully rejected events will be dead-lettered and can no longer be received by a consumer.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// Array of lock tokens.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual async Task> RejectAsync(string topicName, string eventSubscriptionName, IEnumerable lockTokens, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ RejectRequest rejectRequest = new RejectRequest(lockTokens.ToList(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await RejectAsync(topicName, eventSubscriptionName, rejectRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(RejectResult.FromResponse(response), response);
+ }
+
+ /// Reject a batch of Cloud Events. The response will include the set of successfully rejected lock tokens, along with other failed lock tokens with their corresponding error information. Successfully rejected events will be dead-lettered and can no longer be received by a consumer.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// Array of lock tokens.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual Response Reject(string topicName, string eventSubscriptionName, IEnumerable lockTokens, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ RejectRequest rejectRequest = new RejectRequest(lockTokens.ToList(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = Reject(topicName, eventSubscriptionName, rejectRequest.ToRequestContent(), context);
+ return Response.FromValue(RejectResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Reject a batch of Cloud Events. The response will include the set of successfully rejected lock tokens, along with other failed lock tokens with their corresponding error information. Successfully rejected events will be dead-lettered and can no longer be received by a consumer.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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.
+ internal virtual async Task RejectAsync(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("EventGridReceiverClient.Reject");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateRejectRequest(topicName, eventSubscriptionName, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Reject a batch of Cloud Events. The response will include the set of successfully rejected lock tokens, along with other failed lock tokens with their corresponding error information. Successfully rejected events will be dead-lettered and can no longer be received by a consumer.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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.
+ internal virtual Response Reject(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("EventGridReceiverClient.Reject");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateRejectRequest(topicName, eventSubscriptionName, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens, along with other failed lock tokens with their corresponding error information. Successfully renewed locks will ensure that the associated event is only available to the consumer that holds the renewed lock.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// Array of lock tokens.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual async Task> RenewLocksAsync(string topicName, string eventSubscriptionName, IEnumerable lockTokens, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ RenewLocksRequest renewLocksRequest = new RenewLocksRequest(lockTokens.ToList(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await RenewLocksAsync(topicName, eventSubscriptionName, renewLocksRequest.ToRequestContent(), context).ConfigureAwait(false);
+ return Response.FromValue(RenewLocksResult.FromResponse(response), response);
+ }
+
+ /// Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens, along with other failed lock tokens with their corresponding error information. Successfully renewed locks will ensure that the associated event is only available to the consumer that holds the renewed lock.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// Array of lock tokens.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ internal virtual Response RenewLocks(string topicName, string eventSubscriptionName, IEnumerable lockTokens, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ RenewLocksRequest renewLocksRequest = new RenewLocksRequest(lockTokens.ToList(), null);
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = RenewLocks(topicName, eventSubscriptionName, renewLocksRequest.ToRequestContent(), context);
+ return Response.FromValue(RenewLocksResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens, along with other failed lock tokens with their corresponding error information. Successfully renewed locks will ensure that the associated event is only available to the consumer that holds the renewed lock.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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.
+ internal virtual async Task RenewLocksAsync(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("EventGridReceiverClient.RenewLocks");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateRenewLocksRequest(topicName, eventSubscriptionName, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Renew locks for a batch of Cloud Events. The response will include the set of successfully renewed lock tokens, along with other failed lock tokens with their corresponding error information. Successfully renewed locks will ensure that the associated event is only available to the consumer that holds the renewed lock.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// 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.
+ internal virtual Response RenewLocks(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("EventGridReceiverClient.RenewLocks");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateRenewLocksRequest(topicName, eventSubscriptionName, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ internal HttpMessage CreateReceiveRequest(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 CreateAcknowledgeRequest(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 CreateReleaseRequest(string topicName, string eventSubscriptionName, RequestContent content, string releaseDelayInSeconds, 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);
+ if (releaseDelayInSeconds != null)
+ {
+ uri.AppendQuery("releaseDelayInSeconds", releaseDelayInSeconds, true);
+ }
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
+ }
+
+ internal HttpMessage CreateRejectRequest(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;
+ }
+
+ internal HttpMessage CreateRenewLocksRequest(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(":renewLock", 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 RequestContext DefaultRequestContext = new RequestContext();
+ internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default)
+ {
+ if (!cancellationToken.CanBeCanceled)
+ {
+ return DefaultRequestContext;
+ }
+
+ return new RequestContext() { CancellationToken = cancellationToken };
+ }
+
+ private static ResponseClassifier _responseClassifier200;
+ private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 });
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridSenderClient.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridSenderClient.cs
new file mode 100644
index 000000000000..7823b6e8d6e3
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridSenderClient.cs
@@ -0,0 +1,375 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure.Core;
+using Azure.Core.Pipeline;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ // Data plane generated client.
+ /// The EventGridSender service client.
+ public partial class EventGridSenderClient
+ {
+ 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 EventGridSenderClient for mocking.
+ protected EventGridSenderClient()
+ {
+ }
+
+ /// Initializes a new instance of EventGridSenderClient.
+ /// 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 EventGridSenderClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AzureMessagingEventGridNamespacesClientOptions())
+ {
+ }
+
+ /// Initializes a new instance of EventGridSenderClient.
+ /// 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 EventGridSenderClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AzureMessagingEventGridNamespacesClientOptions())
+ {
+ }
+
+ /// Initializes a new instance of EventGridSenderClient.
+ /// 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 EventGridSenderClient(Uri endpoint, AzureKeyCredential credential, AzureMessagingEventGridNamespacesClientOptions options)
+ {
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNull(credential, nameof(credential));
+ options ??= new AzureMessagingEventGridNamespacesClientOptions();
+
+ 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 EventGridSenderClient.
+ /// 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 EventGridSenderClient(Uri endpoint, TokenCredential credential, AzureMessagingEventGridNamespacesClientOptions options)
+ {
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNull(credential, nameof(credential));
+ options ??= new AzureMessagingEventGridNamespacesClientOptions();
+
+ 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;
+ }
+
+ /// Publish a single Cloud Event to a namespace topic.
+ /// Topic Name.
+ /// Single Cloud Event being published.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ internal virtual async Task> SendAsync(string topicName, CloudEvent @event, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNull(@event, nameof(@event));
+
+ using RequestContent content = @event.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = await SendAsync(topicName, content, context).ConfigureAwait(false);
+ return Response.FromValue(PublishResult.FromResponse(response), response);
+ }
+
+ /// Publish a single Cloud Event to a namespace topic.
+ /// Topic Name.
+ /// Single Cloud Event being published.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ internal virtual Response Send(string topicName, CloudEvent @event, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNull(@event, nameof(@event));
+
+ using RequestContent content = @event.ToRequestContent();
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Response response = Send(topicName, content, context);
+ return Response.FromValue(PublishResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Publish a single Cloud Event to a namespace topic.
+ ///
+ /// -
+ ///
+ /// This