diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/Azure.Messaging.EventGrid.Namespaces.sln b/sdk/eventgrid/Azure.Messaging.EventGridV2/Azure.Messaging.EventGrid.Namespaces.sln
new file mode 100644
index 000000000000..072dd53b1526
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/Azure.Messaging.EventGrid.Namespaces.sln
@@ -0,0 +1,56 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29709.97
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Messaging.EventGrid.Namespaces", "src\Azure.Messaging.EventGrid.Namespaces.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Messaging.EventGrid.Namespaces.Tests", "tests\Azure.Messaging.EventGrid.Namespaces.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE}
+ EndGlobalSection
+EndGlobal
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/CHANGELOG.md b/sdk/eventgrid/Azure.Messaging.EventGridV2/CHANGELOG.md
new file mode 100644
index 000000000000..13dd08af78ab
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/CHANGELOG.md
@@ -0,0 +1,11 @@
+# Release History
+
+## 1.0.0-beta.1 (Unreleased)
+
+### Features Added
+
+### Breaking Changes
+
+### Bugs Fixed
+
+### Other Changes
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/Directory.Build.props b/sdk/eventgrid/Azure.Messaging.EventGridV2/Directory.Build.props
new file mode 100644
index 000000000000..63bd836ad44b
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/Directory.Build.props
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/README.md b/sdk/eventgrid/Azure.Messaging.EventGridV2/README.md
new file mode 100644
index 000000000000..474ce96876c2
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/README.md
@@ -0,0 +1,86 @@
+# Azure.Messaging.EventGrid.Namespaces client library for .NET
+
+Azure.Messaging.EventGrid.Namespaces is a managed service that helps developers get secret simply and securely.
+
+Use the client library for to:
+
+* [Get secret](https://docs.microsoft.com/azure)
+
+[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples]
+
+ [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure)
+
+## Getting started
+
+This section should include everything a developer needs to do to install and create their first client connection *very quickly*.
+
+### Install the package
+
+First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository.
+
+Install the client library for .NET with [NuGet](https://www.nuget.org/ ):
+
+```dotnetcli
+dotnet add package Azure.Messaging.EventGrid.Namespaces --prerelease
+```
+
+### Prerequisites
+
+Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB:
+
+> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`.
+
+### Authenticate the client
+
+If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating.
+
+For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object.
+
+## Key concepts
+
+The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity.
+
+Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of:
+
+### Thread safety
+
+We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads.
+
+### Additional concepts
+
+[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) |
+[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) |
+[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) |
+[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) |
+[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) |
+[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) |
+[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/)
+
+
+## Examples
+
+You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples).
+
+## Troubleshooting
+
+Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery.
+
+Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API.
+
+If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code.
+
+## Next steps
+
+* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory.
+* If appropriate, point users to other packages that might be useful.
+* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for.
+
+## Contributing
+
+This is a template, but your SDK readme should include details on how to contribute code to the repo/package.
+
+
+[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization
+[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide
+
+
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..f9023da517a3
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Azure.Messaging.EventGrid.Namespaces.csproj
@@ -0,0 +1,21 @@
+
+
+ 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/AcknowledgeOptions.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeOptions.Serialization.cs
new file mode 100644
index 000000000000..2784b04527ac
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeOptions.Serialization.cs
@@ -0,0 +1,36 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class AcknowledgeOptions : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("lockTokens"u8);
+ writer.WriteStartArray();
+ foreach (var item in LockTokens)
+ {
+ writer.WriteStringValue(item);
+ }
+ writer.WriteEndArray();
+ writer.WriteEndObject();
+ }
+
+ /// Convert into a Utf8JsonRequestContent.
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this);
+ return content;
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeOptions.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeOptions.cs
new file mode 100644
index 000000000000..d6275efd07df
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeOptions.cs
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Array of lock tokens for the corresponding received Cloud Events to be acknowledged.
+ public partial class AcknowledgeOptions
+ {
+ /// Initializes a new instance of AcknowledgeOptions.
+ /// Array of lock tokens.
+ /// is null.
+ public AcknowledgeOptions(IEnumerable lockTokens)
+ {
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ LockTokens = lockTokens.ToList();
+ }
+
+ /// Initializes a new instance of AcknowledgeOptions.
+ /// Array of lock tokens.
+ internal AcknowledgeOptions(IList lockTokens)
+ {
+ LockTokens = lockTokens;
+ }
+
+ /// Array of lock tokens.
+ public IList 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..976f3f007dfd
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeResult.Serialization.cs
@@ -0,0 +1,58 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class AcknowledgeResult
+ {
+ internal static AcknowledgeResult DeserializeAcknowledgeResult(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ IReadOnlyList failedLockTokens = default;
+ IReadOnlyList succeededLockTokens = default;
+ 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));
+ }
+ 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;
+ }
+ }
+ return new AcknowledgeResult(failedLockTokens, succeededLockTokens);
+ }
+
+ /// 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);
+ return DeserializeAcknowledgeResult(document.RootElement);
+ }
+ }
+}
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..0a96ccf299e8
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/AcknowledgeResult.cs
@@ -0,0 +1,45 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// The result of the Acknowledge operation.
+ public partial class AcknowledgeResult
+ {
+ /// Initializes a new instance of 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).
+ /// 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 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).
+ /// Array of lock tokens for the successfully acknowledged cloud events.
+ internal AcknowledgeResult(IReadOnlyList failedLockTokens, IReadOnlyList succeededLockTokens)
+ {
+ FailedLockTokens = failedLockTokens;
+ SucceededLockTokens = succeededLockTokens;
+ }
+
+ /// 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/BrokerProperties.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/BrokerProperties.Serialization.cs
new file mode 100644
index 000000000000..0e7dbd44f4e6
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/BrokerProperties.Serialization.cs
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ internal partial class BrokerProperties
+ {
+ internal static BrokerProperties DeserializeBrokerProperties(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string lockToken = default;
+ int deliveryCount = default;
+ 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;
+ }
+ }
+ return new BrokerProperties(lockToken, deliveryCount);
+ }
+
+ /// 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);
+ return DeserializeBrokerProperties(document.RootElement);
+ }
+ }
+}
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..f1974e87a223
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/BrokerProperties.cs
@@ -0,0 +1,33 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Properties of the Event Broker operation.
+ internal partial class BrokerProperties
+ {
+ /// Initializes a new instance of BrokerProperties.
+ /// 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;
+ }
+
+ /// 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..9874da3c36e3
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/CloudEvent.Serialization.cs
@@ -0,0 +1,168 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Text.Json;
+using Azure;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ internal partial class CloudEvent : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ 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))
+ {
+ 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);
+ }
+ writer.WriteEndObject();
+ }
+
+ internal static CloudEvent DeserializeCloudEvent(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string id = default;
+ string source = default;
+ Optional data = default;
+ Optional dataBase64 = default;
+ string type = default;
+ Optional time = default;
+ string specversion = default;
+ Optional dataschema = default;
+ Optional datacontenttype = default;
+ Optional subject = default;
+ 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;
+ }
+ }
+ return new CloudEvent(id, source, data.Value, dataBase64.Value, type, Optional.ToNullable(time), specversion, dataschema.Value, datacontenttype.Value, subject.Value);
+ }
+
+ /// 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);
+ return DeserializeCloudEvent(document.RootElement);
+ }
+
+ /// Convert into a Utf8JsonRequestContent.
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this);
+ 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..fa4498fcb1b1
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/CloudEvent.cs
@@ -0,0 +1,125 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+
+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
+ {
+ /// Initializes a new instance of CloudEvent.
+ /// 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 CloudEvent.
+ /// 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).
+ internal CloudEvent(string id, string source, BinaryData data, BinaryData dataBase64, string type, DateTimeOffset? time, string specversion, string dataschema, string datacontenttype, string subject)
+ {
+ Id = id;
+ Source = source;
+ Data = data;
+ DataBase64 = dataBase64;
+ Type = type;
+ Time = time;
+ Specversion = specversion;
+ Dataschema = dataschema;
+ Datacontenttype = datacontenttype;
+ Subject = subject;
+ }
+
+ /// 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/Docs/EventGridClient.xml b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/Docs/EventGridClient.xml
new file mode 100644
index 000000000000..609a4bd24720
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/Docs/EventGridClient.xml
@@ -0,0 +1,549 @@
+
+
+
+
+
+This sample shows how to call AcknowledgeCloudEventsAsync.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+AcknowledgeOptions acknowledgeOptions = new AcknowledgeOptions(new string[] { "" });
+Response response = await client.AcknowledgeCloudEventsAsync("", "", acknowledgeOptions);
+]]>
+This sample shows how to call AcknowledgeCloudEventsAsync with all parameters.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+AcknowledgeOptions acknowledgeOptions = new AcknowledgeOptions(new string[] { "" });
+Response response = await client.AcknowledgeCloudEventsAsync("", "", acknowledgeOptions);
+]]>
+
+
+
+This sample shows how to call AcknowledgeCloudEvents.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+AcknowledgeOptions acknowledgeOptions = new AcknowledgeOptions(new string[] { "" });
+Response response = client.AcknowledgeCloudEvents("", "", acknowledgeOptions);
+]]>
+This sample shows how to call AcknowledgeCloudEvents with all parameters.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+AcknowledgeOptions acknowledgeOptions = new AcknowledgeOptions(new string[] { "" });
+Response response = client.AcknowledgeCloudEvents("", "", acknowledgeOptions);
+]]>
+
+
+
+This sample shows how to call AcknowledgeCloudEventsAsync and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = await client.AcknowledgeCloudEventsAsync("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+This sample shows how to call AcknowledgeCloudEventsAsync with all parameters and request content and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = await client.AcknowledgeCloudEventsAsync("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+
+
+
+This sample shows how to call AcknowledgeCloudEvents and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = client.AcknowledgeCloudEvents("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+This sample shows how to call AcknowledgeCloudEvents with all parameters and request content and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = client.AcknowledgeCloudEvents("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+
+
+
+This sample shows how to call ReleaseCloudEventsAsync.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+ReleaseOptions releaseOptions = new ReleaseOptions(new string[] { "" });
+Response response = await client.ReleaseCloudEventsAsync("", "", releaseOptions);
+]]>
+This sample shows how to call ReleaseCloudEventsAsync with all parameters.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+ReleaseOptions releaseOptions = new ReleaseOptions(new string[] { "" });
+Response response = await client.ReleaseCloudEventsAsync("", "", releaseOptions, releaseDelayInSeconds: ReleaseDelay.By0Seconds);
+]]>
+
+
+
+This sample shows how to call ReleaseCloudEvents.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+ReleaseOptions releaseOptions = new ReleaseOptions(new string[] { "" });
+Response response = client.ReleaseCloudEvents("", "", releaseOptions);
+]]>
+This sample shows how to call ReleaseCloudEvents with all parameters.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+ReleaseOptions releaseOptions = new ReleaseOptions(new string[] { "" });
+Response response = client.ReleaseCloudEvents("", "", releaseOptions, releaseDelayInSeconds: ReleaseDelay.By0Seconds);
+]]>
+
+
+
+This sample shows how to call ReleaseCloudEventsAsync and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = await client.ReleaseCloudEventsAsync("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+This sample shows how to call ReleaseCloudEventsAsync with all parameters and request content and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = await client.ReleaseCloudEventsAsync("", "", content, releaseDelayInSeconds: 0);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+
+
+
+This sample shows how to call ReleaseCloudEvents and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = client.ReleaseCloudEvents("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+This sample shows how to call ReleaseCloudEvents with all parameters and request content and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = client.ReleaseCloudEvents("", "", content, releaseDelayInSeconds: 0);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+
+
+
+This sample shows how to call RejectCloudEventsAsync.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+RejectOptions rejectOptions = new RejectOptions(new string[] { "" });
+Response response = await client.RejectCloudEventsAsync("", "", rejectOptions);
+]]>
+This sample shows how to call RejectCloudEventsAsync with all parameters.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+RejectOptions rejectOptions = new RejectOptions(new string[] { "" });
+Response response = await client.RejectCloudEventsAsync("", "", rejectOptions);
+]]>
+
+
+
+This sample shows how to call RejectCloudEvents.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+RejectOptions rejectOptions = new RejectOptions(new string[] { "" });
+Response response = client.RejectCloudEvents("", "", rejectOptions);
+]]>
+This sample shows how to call RejectCloudEvents with all parameters.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+RejectOptions rejectOptions = new RejectOptions(new string[] { "" });
+Response response = client.RejectCloudEvents("", "", rejectOptions);
+]]>
+
+
+
+This sample shows how to call RejectCloudEventsAsync and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = await client.RejectCloudEventsAsync("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+This sample shows how to call RejectCloudEventsAsync with all parameters and request content and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = await client.RejectCloudEventsAsync("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+
+
+
+This sample shows how to call RejectCloudEvents and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = client.RejectCloudEvents("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+This sample shows how to call RejectCloudEvents with all parameters and request content and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = client.RejectCloudEvents("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+
+
+
+This sample shows how to call RenewCloudEventLocksAsync.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+RenewLockOptions renewLockOptions = new RenewLockOptions(new string[] { "" });
+Response response = await client.RenewCloudEventLocksAsync("", "", renewLockOptions);
+]]>
+This sample shows how to call RenewCloudEventLocksAsync with all parameters.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+RenewLockOptions renewLockOptions = new RenewLockOptions(new string[] { "" });
+Response response = await client.RenewCloudEventLocksAsync("", "", renewLockOptions);
+]]>
+
+
+
+This sample shows how to call RenewCloudEventLocks.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+RenewLockOptions renewLockOptions = new RenewLockOptions(new string[] { "" });
+Response response = client.RenewCloudEventLocks("", "", renewLockOptions);
+]]>
+This sample shows how to call RenewCloudEventLocks with all parameters.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+RenewLockOptions renewLockOptions = new RenewLockOptions(new string[] { "" });
+Response response = client.RenewCloudEventLocks("", "", renewLockOptions);
+]]>
+
+
+
+This sample shows how to call RenewCloudEventLocksAsync and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = await client.RenewCloudEventLocksAsync("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+This sample shows how to call RenewCloudEventLocksAsync with all parameters and request content and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = await client.RenewCloudEventLocksAsync("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+
+
+
+This sample shows how to call RenewCloudEventLocks and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = client.RenewCloudEventLocks("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+This sample shows how to call RenewCloudEventLocks with all parameters and request content and parse the result.
+");
+AzureKeyCredential credential = new AzureKeyCredential("");
+EventGridClient client = new EventGridClient(endpoint, credential);
+
+using RequestContent content = RequestContent.Create(new
+{
+ lockTokens = new object[]
+ {
+ ""
+ },
+});
+Response response = client.RenewCloudEventLocks("", "", content);
+
+JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+]]>
+
+
+
\ No newline at end of file
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridClient.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridClient.cs
new file mode 100644
index 000000000000..6226865d102b
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridClient.cs
@@ -0,0 +1,1124 @@
+// 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;
+using Azure.Core;
+using Azure.Core.Pipeline;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ // Data plane generated client.
+ /// Azure Messaging EventGrid Client.
+ public partial class EventGridClient
+ {
+ private const string AuthorizationHeader = "Authorization";
+ private readonly AzureKeyCredential _keyCredential;
+ private const string AuthorizationApiKeyPrefix = "SharedAccessKey";
+ private static readonly string[] AuthorizationScopes = new string[] { "https://eventgrid.azure.net/.default" };
+ private readonly TokenCredential _tokenCredential;
+ private readonly HttpPipeline _pipeline;
+ private readonly Uri _endpoint;
+ private readonly string _apiVersion;
+
+ /// The ClientDiagnostics is used to provide tracing support for the client library.
+ internal ClientDiagnostics ClientDiagnostics { get; }
+
+ /// The HTTP pipeline for sending and receiving REST requests and responses.
+ public virtual HttpPipeline Pipeline => _pipeline;
+
+ /// Initializes a new instance of EventGridClient for mocking.
+ protected EventGridClient()
+ {
+ }
+
+ /// Initializes a new instance of EventGridClient.
+ /// The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net.
+ /// A credential used to authenticate to an Azure Service.
+ /// or is null.
+ public EventGridClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new EventGridClientOptions())
+ {
+ }
+
+ /// Initializes a new instance of EventGridClient.
+ /// The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net.
+ /// A credential used to authenticate to an Azure Service.
+ /// or is null.
+ public EventGridClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new EventGridClientOptions())
+ {
+ }
+
+ /// Initializes a new instance of EventGridClient.
+ /// The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net.
+ /// A credential used to authenticate to an Azure Service.
+ /// The options for configuring the client.
+ /// or is null.
+ public EventGridClient(Uri endpoint, AzureKeyCredential credential, EventGridClientOptions options)
+ {
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNull(credential, nameof(credential));
+ options ??= new EventGridClientOptions();
+
+ ClientDiagnostics = new ClientDiagnostics(options, true);
+ _keyCredential = credential;
+ _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader, AuthorizationApiKeyPrefix) }, new ResponseClassifier());
+ _endpoint = endpoint;
+ _apiVersion = options.Version;
+ }
+
+ /// Initializes a new instance of EventGridClient.
+ /// The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net.
+ /// A credential used to authenticate to an Azure Service.
+ /// The options for configuring the client.
+ /// or is null.
+ public EventGridClient(Uri endpoint, TokenCredential credential, EventGridClientOptions options)
+ {
+ Argument.AssertNotNull(endpoint, nameof(endpoint));
+ Argument.AssertNotNull(credential, nameof(credential));
+ options ??= new EventGridClientOptions();
+
+ ClientDiagnostics = new ClientDiagnostics(options, true);
+ _tokenCredential = credential;
+ _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier());
+ _endpoint = endpoint;
+ _apiVersion = options.Version;
+ }
+
+ /// Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error.
+ /// 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> PublishCloudEventAsync(string topicName, CloudEvent @event, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNull(@event, nameof(@event));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = @event.ToRequestContent();
+ Response response = await PublishCloudEventAsync(topicName, content, context).ConfigureAwait(false);
+ return Response.FromValue(PublishResult.FromResponse(response), response);
+ }
+
+ /// Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error.
+ /// 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 PublishCloudEvent(string topicName, CloudEvent @event, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNull(@event, nameof(@event));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = @event.ToRequestContent();
+ Response response = PublishCloudEvent(topicName, content, context);
+ return Response.FromValue(PublishResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Topic Name.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual async Task PublishCloudEventAsync(string topicName, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.PublishCloudEvent");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreatePublishCloudEventRequest(topicName, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Topic Name.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual Response PublishCloudEvent(string topicName, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.PublishCloudEvent");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreatePublishCloudEventRequest(topicName, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error.
+ /// Topic Name.
+ /// Array of Cloud Events 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> PublishCloudEventsAsync(string topicName, IEnumerable events, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNull(events, nameof(events));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = RequestContentHelper.FromEnumerable(events);
+ Response response = await PublishCloudEventsAsync(topicName, content, context).ConfigureAwait(false);
+ return Response.FromValue(PublishResult.FromResponse(response), response);
+ }
+
+ /// Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error.
+ /// Topic Name.
+ /// Array of Cloud Events being published.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ internal virtual Response PublishCloudEvents(string topicName, IEnumerable events, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNull(events, nameof(events));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = RequestContentHelper.FromEnumerable(events);
+ Response response = PublishCloudEvents(topicName, content, context);
+ return Response.FromValue(PublishResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Topic Name.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual async Task PublishCloudEventsAsync(string topicName, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.PublishCloudEvents");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreatePublishCloudEventsRequest(topicName, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// Topic Name.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ /// Service returned a non-success status code.
+ /// The response returned from the service.
+ internal virtual Response PublishCloudEvents(string topicName, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.PublishCloudEvents");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreatePublishCloudEventsRequest(topicName, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Receive Batch of Cloud Events from the Event 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> ReceiveCloudEventsAsync(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 ReceiveCloudEventsAsync(topicName, eventSubscriptionName, maxEvents, maxWaitTime, context).ConfigureAwait(false);
+ return Response.FromValue(ReceiveResult.FromResponse(response), response);
+ }
+
+ /// Receive Batch of Cloud Events from the Event 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 ReceiveCloudEvents(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 = ReceiveCloudEvents(topicName, eventSubscriptionName, maxEvents, maxWaitTime, context);
+ return Response.FromValue(ReceiveResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Receive Batch of Cloud Events from the Event Subscription.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// 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 ReceiveCloudEventsAsync(string topicName, string eventSubscriptionName, int? maxEvents, TimeSpan? maxWaitTime, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.ReceiveCloudEvents");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateReceiveCloudEventsRequest(topicName, eventSubscriptionName, maxEvents, maxWaitTime, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Receive Batch of Cloud Events from the Event Subscription.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// 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 ReceiveCloudEvents(string topicName, string eventSubscriptionName, int? maxEvents, TimeSpan? maxWaitTime, RequestContext context)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.ReceiveCloudEvents");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateReceiveCloudEventsRequest(topicName, eventSubscriptionName, maxEvents, maxWaitTime, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// AcknowledgeOptions.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> AcknowledgeCloudEventsAsync(string topicName, string eventSubscriptionName, AcknowledgeOptions acknowledgeOptions, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(acknowledgeOptions, nameof(acknowledgeOptions));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = acknowledgeOptions.ToRequestContent();
+ Response response = await AcknowledgeCloudEventsAsync(topicName, eventSubscriptionName, content, context).ConfigureAwait(false);
+ return Response.FromValue(AcknowledgeResult.FromResponse(response), response);
+ }
+
+ /// Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// AcknowledgeOptions.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response AcknowledgeCloudEvents(string topicName, string eventSubscriptionName, AcknowledgeOptions acknowledgeOptions, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(acknowledgeOptions, nameof(acknowledgeOptions));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = acknowledgeOptions.ToRequestContent();
+ Response response = AcknowledgeCloudEvents(topicName, eventSubscriptionName, content, context);
+ return Response.FromValue(AcknowledgeResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// 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.
+ ///
+ public virtual async Task AcknowledgeCloudEventsAsync(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.AcknowledgeCloudEvents");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateAcknowledgeCloudEventsRequest(topicName, eventSubscriptionName, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// 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.
+ ///
+ public virtual Response AcknowledgeCloudEvents(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.AcknowledgeCloudEvents");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateAcknowledgeCloudEventsRequest(topicName, eventSubscriptionName, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Release batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully released lockTokens, along with other failed lockTokens with their corresponding error information.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// ReleaseOptions.
+ /// 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.
+ ///
+ public virtual async Task> ReleaseCloudEventsAsync(string topicName, string eventSubscriptionName, ReleaseOptions releaseOptions, ReleaseDelay? releaseDelayInSeconds = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(releaseOptions, nameof(releaseOptions));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = releaseOptions.ToRequestContent();
+ Response response = await ReleaseCloudEventsAsync(topicName, eventSubscriptionName, content, releaseDelayInSeconds, context).ConfigureAwait(false);
+ return Response.FromValue(ReleaseResult.FromResponse(response), response);
+ }
+
+ /// Release batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully released lockTokens, along with other failed lockTokens with their corresponding error information.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// ReleaseOptions.
+ /// 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.
+ ///
+ public virtual Response ReleaseCloudEvents(string topicName, string eventSubscriptionName, ReleaseOptions releaseOptions, ReleaseDelay? releaseDelayInSeconds = null, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(releaseOptions, nameof(releaseOptions));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = releaseOptions.ToRequestContent();
+ Response response = ReleaseCloudEvents(topicName, eventSubscriptionName, content, releaseDelayInSeconds, context);
+ return Response.FromValue(ReleaseResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Release batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully released lockTokens, along with other failed lockTokens with their corresponding error information.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// 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.
+ ///
+ public virtual async Task ReleaseCloudEventsAsync(string topicName, string eventSubscriptionName, RequestContent content, int? 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("EventGridClient.ReleaseCloudEvents");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateReleaseCloudEventsRequest(topicName, eventSubscriptionName, content, releaseDelayInSeconds, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Release batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully released lockTokens, along with other failed lockTokens with their corresponding error information.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// 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.
+ ///
+ public virtual Response ReleaseCloudEvents(string topicName, string eventSubscriptionName, RequestContent content, int? 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("EventGridClient.ReleaseCloudEvents");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateReleaseCloudEventsRequest(topicName, eventSubscriptionName, content, releaseDelayInSeconds, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Reject batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully rejected lockTokens, along with other failed lockTokens with their corresponding error information.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// RejectOptions.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> RejectCloudEventsAsync(string topicName, string eventSubscriptionName, RejectOptions rejectOptions, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(rejectOptions, nameof(rejectOptions));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = rejectOptions.ToRequestContent();
+ Response response = await RejectCloudEventsAsync(topicName, eventSubscriptionName, content, context).ConfigureAwait(false);
+ return Response.FromValue(RejectResult.FromResponse(response), response);
+ }
+
+ /// Reject batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully rejected lockTokens, along with other failed lockTokens with their corresponding error information.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// RejectOptions.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response RejectCloudEvents(string topicName, string eventSubscriptionName, RejectOptions rejectOptions, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(rejectOptions, nameof(rejectOptions));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = rejectOptions.ToRequestContent();
+ Response response = RejectCloudEvents(topicName, eventSubscriptionName, content, context);
+ return Response.FromValue(RejectResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Reject batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully rejected lockTokens, along with other failed lockTokens with their corresponding error information.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// 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.
+ ///
+ public virtual async Task RejectCloudEventsAsync(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.RejectCloudEvents");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateRejectCloudEventsRequest(topicName, eventSubscriptionName, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Reject batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully rejected lockTokens, along with other failed lockTokens with their corresponding error information.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// 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.
+ ///
+ public virtual Response RejectCloudEvents(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.RejectCloudEvents");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateRejectCloudEventsRequest(topicName, eventSubscriptionName, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Renew lock for batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully renewed lockTokens, along with other failed lockTokens with their corresponding error information.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// RenewLockOptions.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual async Task> RenewCloudEventLocksAsync(string topicName, string eventSubscriptionName, RenewLockOptions renewLockOptions, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(renewLockOptions, nameof(renewLockOptions));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = renewLockOptions.ToRequestContent();
+ Response response = await RenewCloudEventLocksAsync(topicName, eventSubscriptionName, content, context).ConfigureAwait(false);
+ return Response.FromValue(RenewCloudEventLocksResult.FromResponse(response), response);
+ }
+
+ /// Renew lock for batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully renewed lockTokens, along with other failed lockTokens with their corresponding error information.
+ /// Topic Name.
+ /// Event Subscription Name.
+ /// RenewLockOptions.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// or is an empty string, and was expected to be non-empty.
+ ///
+ public virtual Response RenewCloudEventLocks(string topicName, string eventSubscriptionName, RenewLockOptions renewLockOptions, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(renewLockOptions, nameof(renewLockOptions));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ using RequestContent content = renewLockOptions.ToRequestContent();
+ Response response = RenewCloudEventLocks(topicName, eventSubscriptionName, content, context);
+ return Response.FromValue(RenewCloudEventLocksResult.FromResponse(response), response);
+ }
+
+ ///
+ /// [Protocol Method] Renew lock for batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully renewed lockTokens, along with other failed lockTokens with their corresponding error information.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// 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.
+ ///
+ public virtual async Task RenewCloudEventLocksAsync(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.RenewCloudEventLocks");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateRenewCloudEventLocksRequest(topicName, eventSubscriptionName, content, context);
+ return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Renew lock for batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully renewed lockTokens, along with other failed lockTokens with their corresponding error information.
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// 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.
+ ///
+ public virtual Response RenewCloudEventLocks(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNullOrEmpty(topicName, nameof(topicName));
+ Argument.AssertNotNullOrEmpty(eventSubscriptionName, nameof(eventSubscriptionName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("EventGridClient.RenewCloudEventLocks");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateRenewCloudEventLocksRequest(topicName, eventSubscriptionName, content, context);
+ return _pipeline.ProcessMessage(message, context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ internal HttpMessage CreatePublishCloudEventRequest(string topicName, RequestContent content, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/topics/", false);
+ uri.AppendPath(topicName, true);
+ uri.AppendPath(":publish", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("content-type", "application/cloudevents+json; charset=utf-8");
+ request.Content = content;
+ return message;
+ }
+
+ internal HttpMessage CreatePublishCloudEventsRequest(string topicName, RequestContent content, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/topics/", false);
+ uri.AppendPath(topicName, true);
+ uri.AppendPath(":publish", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("content-type", "application/cloudevents-batch+json; charset=utf-8");
+ request.Content = content;
+ return message;
+ }
+
+ internal HttpMessage CreateReceiveCloudEventsRequest(string topicName, string eventSubscriptionName, int? maxEvents, TimeSpan? maxWaitTime, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/topics/", false);
+ uri.AppendPath(topicName, true);
+ uri.AppendPath("/eventsubscriptions/", false);
+ uri.AppendPath(eventSubscriptionName, true);
+ uri.AppendPath(":receive", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ if (maxEvents != null)
+ {
+ uri.AppendQuery("maxEvents", maxEvents.Value, true);
+ }
+ if (maxWaitTime != null)
+ {
+ uri.AppendQuery("maxWaitTime", maxWaitTime.Value, "%s", true);
+ }
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ return message;
+ }
+
+ internal HttpMessage CreateAcknowledgeCloudEventsRequest(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/topics/", false);
+ uri.AppendPath(topicName, true);
+ uri.AppendPath("/eventsubscriptions/", false);
+ uri.AppendPath(eventSubscriptionName, true);
+ uri.AppendPath(":acknowledge", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
+ }
+
+ internal HttpMessage CreateReleaseCloudEventsRequest(string topicName, string eventSubscriptionName, RequestContent content, int? 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.Value, true);
+ }
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
+ }
+
+ internal HttpMessage CreateRejectCloudEventsRequest(string topicName, string eventSubscriptionName, RequestContent content, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier200);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendPath("/topics/", false);
+ uri.AppendPath(topicName, true);
+ uri.AppendPath("/eventsubscriptions/", false);
+ uri.AppendPath(eventSubscriptionName, true);
+ uri.AppendPath(":reject", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
+ }
+
+ internal HttpMessage CreateRenewCloudEventLocksRequest(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/EventGridClientOptions.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridClientOptions.cs
new file mode 100644
index 000000000000..98f2b33759e6
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/EventGridClientOptions.cs
@@ -0,0 +1,43 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Client options for EventGridClient.
+ public partial class EventGridClientOptions : ClientOptions
+ {
+ private const ServiceVersion LatestVersion = ServiceVersion.V2023_10_01_Preview;
+
+ /// The version of the service to use.
+ public enum ServiceVersion
+ {
+ /// Service version "2023-11-01".
+ V2023_11_01 = 1,
+ /// Service version "2023-06-01-preview".
+ V2023_06_01_Preview = 2,
+ /// Service version "2023-10-01-preview".
+ V2023_10_01_Preview = 3,
+ }
+
+ internal string Version { get; }
+
+ /// Initializes new instance of EventGridClientOptions.
+ public EventGridClientOptions(ServiceVersion version = LatestVersion)
+ {
+ Version = version switch
+ {
+ ServiceVersion.V2023_11_01 => "2023-11-01",
+ ServiceVersion.V2023_06_01_Preview => "2023-06-01-preview",
+ ServiceVersion.V2023_10_01_Preview => "2023-10-01-preview",
+ _ => throw new NotSupportedException()
+ };
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/FailedLockToken.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/FailedLockToken.Serialization.cs
new file mode 100644
index 000000000000..23c2c4c33555
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/FailedLockToken.Serialization.cs
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class FailedLockToken
+ {
+ internal static FailedLockToken DeserializeFailedLockToken(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string lockToken = default;
+ ResponseError error = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("lockToken"u8))
+ {
+ lockToken = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("error"u8))
+ {
+ error = JsonSerializer.Deserialize(property.Value.GetRawText());
+ continue;
+ }
+ }
+ return new FailedLockToken(lockToken, error);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static FailedLockToken FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeFailedLockToken(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/FailedLockToken.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/FailedLockToken.cs
new file mode 100644
index 000000000000..36e288ea86e6
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/FailedLockToken.cs
@@ -0,0 +1,35 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Failed LockToken information.
+ public partial class FailedLockToken
+ {
+ /// Initializes a new instance of FailedLockToken.
+ /// The lock token of an entry in the request.
+ /// Error information of the failed operation result for the lock token in the request.
+ /// or is null.
+ internal FailedLockToken(string lockToken, ResponseError error)
+ {
+ Argument.AssertNotNull(lockToken, nameof(lockToken));
+ Argument.AssertNotNull(error, nameof(error));
+
+ LockToken = lockToken;
+ Error = error;
+ }
+
+ /// The lock token of an entry in the request.
+ public string LockToken { get; }
+ /// Error information of the failed operation result for the lock token in the request.
+ public ResponseError Error { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/MessagingEventGridNamespacesClientBuilderExtensions.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/MessagingEventGridNamespacesClientBuilderExtensions.cs
new file mode 100644
index 000000000000..78650a246d3d
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/MessagingEventGridNamespacesClientBuilderExtensions.cs
@@ -0,0 +1,46 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure;
+using Azure.Core.Extensions;
+using Azure.Messaging.EventGrid.Namespaces;
+
+namespace Microsoft.Extensions.Azure
+{
+ /// Extension methods to add to client builder.
+ public static partial class MessagingEventGridNamespacesClientBuilderExtensions
+ {
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net.
+ /// A credential used to authenticate to an Azure Service.
+ public static IAzureClientBuilder AddEventGridClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential)
+ where TBuilder : IAzureClientFactoryBuilder
+ {
+ return builder.RegisterClientFactory((options) => new EventGridClient(endpoint, credential, options));
+ }
+
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net.
+ public static IAzureClientBuilder AddEventGridClient(this TBuilder builder, Uri endpoint)
+ where TBuilder : IAzureClientFactoryBuilderWithCredential
+ {
+ return builder.RegisterClientFactory((options, cred) => new EventGridClient(endpoint, cred, options));
+ }
+
+ /// Registers a instance.
+ /// The builder to register with.
+ /// The configuration values.
+ public static IAzureClientBuilder AddEventGridClient(this TBuilder builder, TConfiguration configuration)
+ where TBuilder : IAzureClientFactoryBuilderWithConfiguration
+ {
+ return builder.RegisterClientFactory(configuration);
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/MessagingEventGridNamespacesModelFactory.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/MessagingEventGridNamespacesModelFactory.cs
new file mode 100644
index 000000000000..b7774e998a8c
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/MessagingEventGridNamespacesModelFactory.cs
@@ -0,0 +1,85 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Azure;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Model factory for models.
+ public static partial class MessagingEventGridNamespacesModelFactory
+ {
+ /// Initializes a new instance of 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).
+ /// Array of lock tokens for the successfully acknowledged cloud events.
+ /// A new instance for mocking.
+ public static AcknowledgeResult AcknowledgeResult(IEnumerable failedLockTokens = null, IEnumerable succeededLockTokens = null)
+ {
+ failedLockTokens ??= new List();
+ succeededLockTokens ??= new List();
+
+ return new AcknowledgeResult(failedLockTokens?.ToList(), succeededLockTokens?.ToList());
+ }
+
+ /// Initializes a new instance of FailedLockToken.
+ /// The lock token of an entry in the request.
+ /// Error information of the failed operation result for the lock token in the request.
+ /// or is null.
+ /// A new instance for mocking.
+ public static FailedLockToken FailedLockToken(string lockToken = null, ResponseError error = null)
+ {
+ if (lockToken == null)
+ {
+ throw new ArgumentNullException(nameof(lockToken));
+ }
+ if (error == null)
+ {
+ throw new ArgumentNullException(nameof(error));
+ }
+
+ return new FailedLockToken(lockToken, error);
+ }
+
+ /// Initializes a new instance of ReleaseResult.
+ /// 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 released cloud events.
+ /// A new instance for mocking.
+ public static ReleaseResult ReleaseResult(IEnumerable failedLockTokens = null, IEnumerable succeededLockTokens = null)
+ {
+ failedLockTokens ??= new List();
+ succeededLockTokens ??= new List();
+
+ return new ReleaseResult(failedLockTokens?.ToList(), succeededLockTokens?.ToList());
+ }
+
+ /// Initializes a new instance of RejectResult.
+ /// 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 rejected cloud events.
+ /// A new instance for mocking.
+ public static RejectResult RejectResult(IEnumerable failedLockTokens = null, IEnumerable succeededLockTokens = null)
+ {
+ failedLockTokens ??= new List();
+ succeededLockTokens ??= new List();
+
+ return new RejectResult(failedLockTokens?.ToList(), succeededLockTokens?.ToList());
+ }
+
+ /// Initializes a new instance of RenewCloudEventLocksResult.
+ /// 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 renewed locks.
+ /// A new instance for mocking.
+ public static RenewCloudEventLocksResult RenewCloudEventLocksResult(IEnumerable failedLockTokens = null, IEnumerable succeededLockTokens = null)
+ {
+ failedLockTokens ??= new List();
+ succeededLockTokens ??= new List();
+
+ return new RenewCloudEventLocksResult(failedLockTokens?.ToList(), succeededLockTokens?.ToList());
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/PublishResult.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/PublishResult.Serialization.cs
new file mode 100644
index 000000000000..1693e1527872
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/PublishResult.Serialization.cs
@@ -0,0 +1,35 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ internal partial class PublishResult
+ {
+ internal static PublishResult DeserializePublishResult(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ foreach (var property in element.EnumerateObject())
+ {
+ }
+ return new PublishResult();
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static PublishResult FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializePublishResult(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/PublishResult.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/PublishResult.cs
new file mode 100644
index 000000000000..a98b8da1a46b
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/PublishResult.cs
@@ -0,0 +1,18 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// The result of the Publish operation.
+ internal partial class PublishResult
+ {
+ /// Initializes a new instance of PublishResult.
+ internal PublishResult()
+ {
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveDetails.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveDetails.Serialization.cs
new file mode 100644
index 000000000000..84c05b1a09a6
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveDetails.Serialization.cs
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ internal partial class ReceiveDetails
+ {
+ internal static ReceiveDetails DeserializeReceiveDetails(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ BrokerProperties brokerProperties = default;
+ CloudEvent @event = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("brokerProperties"u8))
+ {
+ brokerProperties = BrokerProperties.DeserializeBrokerProperties(property.Value);
+ continue;
+ }
+ if (property.NameEquals("event"u8))
+ {
+ @event = CloudEvent.DeserializeCloudEvent(property.Value);
+ continue;
+ }
+ }
+ return new ReceiveDetails(brokerProperties, @event);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ReceiveDetails FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeReceiveDetails(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveDetails.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveDetails.cs
new file mode 100644
index 000000000000..987b2016d77a
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveDetails.cs
@@ -0,0 +1,34 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Receive operation details per Cloud Event.
+ internal partial class ReceiveDetails
+ {
+ /// Initializes a new instance of ReceiveDetails.
+ /// The Event Broker details.
+ /// Cloud Event details.
+ /// or is null.
+ internal ReceiveDetails(BrokerProperties brokerProperties, CloudEvent @event)
+ {
+ Argument.AssertNotNull(brokerProperties, nameof(brokerProperties));
+ Argument.AssertNotNull(@event, nameof(@event));
+
+ BrokerProperties = brokerProperties;
+ Event = @event;
+ }
+
+ /// The Event Broker details.
+ public BrokerProperties BrokerProperties { get; }
+ /// Cloud Event details.
+ public CloudEvent Event { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveResult.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveResult.Serialization.cs
new file mode 100644
index 000000000000..823500689e42
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveResult.Serialization.cs
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ internal partial class ReceiveResult
+ {
+ internal static ReceiveResult DeserializeReceiveResult(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ IReadOnlyList value = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("value"u8))
+ {
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(ReceiveDetails.DeserializeReceiveDetails(item));
+ }
+ value = array;
+ continue;
+ }
+ }
+ return new ReceiveResult(value);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ReceiveResult FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeReceiveResult(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveResult.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveResult.cs
new file mode 100644
index 000000000000..f2b93dcdd3e2
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReceiveResult.cs
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Details of the Receive operation response.
+ internal partial class ReceiveResult
+ {
+ /// Initializes a new instance of ReceiveResult.
+ /// Array of receive responses, one per cloud event.
+ /// is null.
+ internal ReceiveResult(IEnumerable value)
+ {
+ Argument.AssertNotNull(value, nameof(value));
+
+ Value = value.ToList();
+ }
+
+ /// Initializes a new instance of ReceiveResult.
+ /// Array of receive responses, one per cloud event.
+ internal ReceiveResult(IReadOnlyList value)
+ {
+ Value = value;
+ }
+
+ /// Array of receive responses, one per cloud event.
+ public IReadOnlyList Value { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectOptions.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectOptions.Serialization.cs
new file mode 100644
index 000000000000..ae6640fd1e5e
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectOptions.Serialization.cs
@@ -0,0 +1,36 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class RejectOptions : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("lockTokens"u8);
+ writer.WriteStartArray();
+ foreach (var item in LockTokens)
+ {
+ writer.WriteStringValue(item);
+ }
+ writer.WriteEndArray();
+ writer.WriteEndObject();
+ }
+
+ /// Convert into a Utf8JsonRequestContent.
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this);
+ return content;
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectOptions.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectOptions.cs
new file mode 100644
index 000000000000..7aca19abc84c
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectOptions.cs
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Array of lock tokens for the corresponding received Cloud Events to be rejected.
+ public partial class RejectOptions
+ {
+ /// Initializes a new instance of RejectOptions.
+ /// Array of lock tokens.
+ /// is null.
+ public RejectOptions(IEnumerable lockTokens)
+ {
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ LockTokens = lockTokens.ToList();
+ }
+
+ /// Initializes a new instance of RejectOptions.
+ /// Array of lock tokens.
+ internal RejectOptions(IList lockTokens)
+ {
+ LockTokens = lockTokens;
+ }
+
+ /// Array of lock tokens.
+ public IList LockTokens { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectResult.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectResult.Serialization.cs
new file mode 100644
index 000000000000..f959c58f00ed
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectResult.Serialization.cs
@@ -0,0 +1,58 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class RejectResult
+ {
+ internal static RejectResult DeserializeRejectResult(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ IReadOnlyList failedLockTokens = default;
+ IReadOnlyList succeededLockTokens = default;
+ 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));
+ }
+ 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;
+ }
+ }
+ return new RejectResult(failedLockTokens, succeededLockTokens);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static RejectResult FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeRejectResult(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectResult.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectResult.cs
new file mode 100644
index 000000000000..2c71b0bea24f
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RejectResult.cs
@@ -0,0 +1,45 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// The result of the Reject operation.
+ public partial class RejectResult
+ {
+ /// Initializes a new instance of RejectResult.
+ /// 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 rejected cloud events.
+ /// or is null.
+ internal RejectResult(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 RejectResult.
+ /// 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 rejected cloud events.
+ internal RejectResult(IReadOnlyList failedLockTokens, IReadOnlyList succeededLockTokens)
+ {
+ FailedLockTokens = failedLockTokens;
+ SucceededLockTokens = succeededLockTokens;
+ }
+
+ /// 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 rejected cloud events.
+ public IReadOnlyList SucceededLockTokens { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseDelay.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseDelay.cs
new file mode 100644
index 000000000000..57a8e8369732
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseDelay.cs
@@ -0,0 +1,63 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Supported delays for release operation.
+ public readonly partial struct ReleaseDelay : IEquatable
+ {
+ private readonly int _value;
+
+ /// Initializes a new instance of .
+ public ReleaseDelay(int value)
+ {
+ _value = value;
+ }
+
+ private const int By0SecondsValue = 0;
+ private const int By10SecondsValue = 10;
+ private const int By60SecondsValue = 60;
+ private const int By600SecondsValue = 600;
+ private const int By3600SecondsValue = 3600;
+
+ /// Release the event after 0 seconds.
+ public static ReleaseDelay By0Seconds { get; } = new ReleaseDelay(By0SecondsValue);
+ /// Release the event after 10 seconds.
+ public static ReleaseDelay By10Seconds { get; } = new ReleaseDelay(By10SecondsValue);
+ /// Release the event after 60 seconds.
+ public static ReleaseDelay By60Seconds { get; } = new ReleaseDelay(By60SecondsValue);
+ /// Release the event after 600 seconds.
+ public static ReleaseDelay By600Seconds { get; } = new ReleaseDelay(By600SecondsValue);
+ /// Release the event after 3600 seconds.
+ public static ReleaseDelay By3600Seconds { get; } = new ReleaseDelay(By3600SecondsValue);
+
+ internal int ToSerialInt32() => _value;
+
+ /// Determines if two values are the same.
+ public static bool operator ==(ReleaseDelay left, ReleaseDelay right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(ReleaseDelay left, ReleaseDelay right) => !left.Equals(right);
+ /// Converts a string to a .
+ public static implicit operator ReleaseDelay(int value) => new ReleaseDelay(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is ReleaseDelay other && Equals(other);
+ ///
+ public bool Equals(ReleaseDelay other) => Equals(_value, other._value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override int GetHashCode() => _value.GetHashCode();
+ ///
+ public override string ToString() => _value.ToString(CultureInfo.InvariantCulture);
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseOptions.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseOptions.Serialization.cs
new file mode 100644
index 000000000000..b33f2d8c8aa4
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseOptions.Serialization.cs
@@ -0,0 +1,36 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class ReleaseOptions : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("lockTokens"u8);
+ writer.WriteStartArray();
+ foreach (var item in LockTokens)
+ {
+ writer.WriteStringValue(item);
+ }
+ writer.WriteEndArray();
+ writer.WriteEndObject();
+ }
+
+ /// Convert into a Utf8JsonRequestContent.
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this);
+ return content;
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseOptions.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseOptions.cs
new file mode 100644
index 000000000000..b891b92a8262
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseOptions.cs
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Array of lock tokens for the corresponding received Cloud Events to be released.
+ public partial class ReleaseOptions
+ {
+ /// Initializes a new instance of ReleaseOptions.
+ /// Array of lock tokens.
+ /// is null.
+ public ReleaseOptions(IEnumerable lockTokens)
+ {
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ LockTokens = lockTokens.ToList();
+ }
+
+ /// Initializes a new instance of ReleaseOptions.
+ /// Array of lock tokens.
+ internal ReleaseOptions(IList lockTokens)
+ {
+ LockTokens = lockTokens;
+ }
+
+ /// Array of lock tokens.
+ public IList LockTokens { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseResult.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseResult.Serialization.cs
new file mode 100644
index 000000000000..e3f4cac4cbf1
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseResult.Serialization.cs
@@ -0,0 +1,58 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class ReleaseResult
+ {
+ internal static ReleaseResult DeserializeReleaseResult(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ IReadOnlyList failedLockTokens = default;
+ IReadOnlyList succeededLockTokens = default;
+ 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));
+ }
+ 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;
+ }
+ }
+ return new ReleaseResult(failedLockTokens, succeededLockTokens);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ReleaseResult FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeReleaseResult(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseResult.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseResult.cs
new file mode 100644
index 000000000000..e7c2460e6747
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/ReleaseResult.cs
@@ -0,0 +1,45 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// The result of the Release operation.
+ public partial class ReleaseResult
+ {
+ /// Initializes a new instance of ReleaseResult.
+ /// 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 released cloud events.
+ /// or is null.
+ internal ReleaseResult(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 ReleaseResult.
+ /// 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 released cloud events.
+ internal ReleaseResult(IReadOnlyList failedLockTokens, IReadOnlyList succeededLockTokens)
+ {
+ FailedLockTokens = failedLockTokens;
+ SucceededLockTokens = succeededLockTokens;
+ }
+
+ /// 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 released cloud events.
+ public IReadOnlyList SucceededLockTokens { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewCloudEventLocksResult.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewCloudEventLocksResult.Serialization.cs
new file mode 100644
index 000000000000..f6cdaa7cb667
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewCloudEventLocksResult.Serialization.cs
@@ -0,0 +1,58 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class RenewCloudEventLocksResult
+ {
+ internal static RenewCloudEventLocksResult DeserializeRenewCloudEventLocksResult(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ IReadOnlyList failedLockTokens = default;
+ IReadOnlyList succeededLockTokens = default;
+ 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));
+ }
+ 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;
+ }
+ }
+ return new RenewCloudEventLocksResult(failedLockTokens, succeededLockTokens);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static RenewCloudEventLocksResult FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeRenewCloudEventLocksResult(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewCloudEventLocksResult.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewCloudEventLocksResult.cs
new file mode 100644
index 000000000000..3c524da752a1
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewCloudEventLocksResult.cs
@@ -0,0 +1,45 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// The result of the RenewLock operation.
+ public partial class RenewCloudEventLocksResult
+ {
+ /// Initializes a new instance of RenewCloudEventLocksResult.
+ /// 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 renewed locks.
+ /// or is null.
+ internal RenewCloudEventLocksResult(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 RenewCloudEventLocksResult.
+ /// 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 renewed locks.
+ internal RenewCloudEventLocksResult(IReadOnlyList failedLockTokens, IReadOnlyList succeededLockTokens)
+ {
+ FailedLockTokens = failedLockTokens;
+ SucceededLockTokens = succeededLockTokens;
+ }
+
+ /// 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 renewed locks.
+ public IReadOnlyList SucceededLockTokens { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewLockOptions.Serialization.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewLockOptions.Serialization.cs
new file mode 100644
index 000000000000..0c6e0d580398
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewLockOptions.Serialization.cs
@@ -0,0 +1,36 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ public partial class RenewLockOptions : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("lockTokens"u8);
+ writer.WriteStartArray();
+ foreach (var item in LockTokens)
+ {
+ writer.WriteStringValue(item);
+ }
+ writer.WriteEndArray();
+ writer.WriteEndObject();
+ }
+
+ /// Convert into a Utf8JsonRequestContent.
+ internal virtual RequestContent ToRequestContent()
+ {
+ var content = new Utf8JsonRequestContent();
+ content.JsonWriter.WriteObjectValue(this);
+ return content;
+ }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewLockOptions.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewLockOptions.cs
new file mode 100644
index 000000000000..417777410c03
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Generated/RenewLockOptions.cs
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Azure.Core;
+
+namespace Azure.Messaging.EventGrid.Namespaces
+{
+ /// Array of lock tokens for the corresponding received Cloud Events to be renewed.
+ public partial class RenewLockOptions
+ {
+ /// Initializes a new instance of RenewLockOptions.
+ /// Array of lock tokens.
+ /// is null.
+ public RenewLockOptions(IEnumerable lockTokens)
+ {
+ Argument.AssertNotNull(lockTokens, nameof(lockTokens));
+
+ LockTokens = lockTokens.ToList();
+ }
+
+ /// Initializes a new instance of RenewLockOptions.
+ /// Array of lock tokens.
+ internal RenewLockOptions(IList lockTokens)
+ {
+ LockTokens = lockTokens;
+ }
+
+ /// Array of lock tokens.
+ public IList LockTokens { get; }
+ }
+}
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Properties/AssemblyInfo.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000000..65a47f9167f2
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/src/Properties/AssemblyInfo.cs
@@ -0,0 +1,11 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System.Runtime.CompilerServices;
+
+[assembly: InternalsVisibleTo("Azure.Messaging.EventGrid.Namespaces.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")]
+
+// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment.
+// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers
+// for the list of possible values.
+[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")]
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Azure.Messaging.EventGrid.Namespaces.Tests.csproj b/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Azure.Messaging.EventGrid.Namespaces.Tests.csproj
new file mode 100644
index 000000000000..a1761d0185be
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Azure.Messaging.EventGrid.Namespaces.Tests.csproj
@@ -0,0 +1,29 @@
+
+
+ $(RequiredTargetFrameworks)
+
+
+ $(NoWarn);CS1591
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Generated/Samples/Samples_EventGridClient.cs b/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Generated/Samples/Samples_EventGridClient.cs
new file mode 100644
index 000000000000..226fcf37cee8
--- /dev/null
+++ b/sdk/eventgrid/Azure.Messaging.EventGridV2/tests/Generated/Samples/Samples_EventGridClient.cs
@@ -0,0 +1,613 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.Identity;
+using Azure.Messaging.EventGrid.Namespaces;
+using NUnit.Framework;
+
+namespace Azure.Messaging.EventGrid.Namespaces.Samples
+{
+ public partial class Samples_EventGridClient
+ {
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_AcknowledgeCloudEvents_ShortVersion()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = client.AcknowledgeCloudEvents("", "", content);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_AcknowledgeCloudEvents_ShortVersion_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = await client.AcknowledgeCloudEventsAsync("", "", content);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_AcknowledgeCloudEvents_ShortVersion_Convenience()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ AcknowledgeOptions acknowledgeOptions = new AcknowledgeOptions(new string[] { "" });
+ Response response = client.AcknowledgeCloudEvents("", "", acknowledgeOptions);
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_AcknowledgeCloudEvents_ShortVersion_Convenience_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ AcknowledgeOptions acknowledgeOptions = new AcknowledgeOptions(new string[] { "" });
+ Response response = await client.AcknowledgeCloudEventsAsync("", "", acknowledgeOptions);
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_AcknowledgeCloudEvents_AllParameters()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = client.AcknowledgeCloudEvents("", "", content);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_AcknowledgeCloudEvents_AllParameters_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = await client.AcknowledgeCloudEventsAsync("", "", content);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_AcknowledgeCloudEvents_AllParameters_Convenience()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ AcknowledgeOptions acknowledgeOptions = new AcknowledgeOptions(new string[] { "" });
+ Response response = client.AcknowledgeCloudEvents("", "", acknowledgeOptions);
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_AcknowledgeCloudEvents_AllParameters_Convenience_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ AcknowledgeOptions acknowledgeOptions = new AcknowledgeOptions(new string[] { "" });
+ Response response = await client.AcknowledgeCloudEventsAsync("", "", acknowledgeOptions);
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_ReleaseCloudEvents_ShortVersion()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = client.ReleaseCloudEvents("", "", content);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_ReleaseCloudEvents_ShortVersion_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = await client.ReleaseCloudEventsAsync("", "", content);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_ReleaseCloudEvents_ShortVersion_Convenience()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ ReleaseOptions releaseOptions = new ReleaseOptions(new string[] { "" });
+ Response response = client.ReleaseCloudEvents("", "", releaseOptions);
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_ReleaseCloudEvents_ShortVersion_Convenience_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ ReleaseOptions releaseOptions = new ReleaseOptions(new string[] { "" });
+ Response response = await client.ReleaseCloudEventsAsync("", "", releaseOptions);
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_ReleaseCloudEvents_AllParameters()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = client.ReleaseCloudEvents("", "", content, releaseDelayInSeconds: 0);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_ReleaseCloudEvents_AllParameters_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = await client.ReleaseCloudEventsAsync("", "", content, releaseDelayInSeconds: 0);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_ReleaseCloudEvents_AllParameters_Convenience()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ ReleaseOptions releaseOptions = new ReleaseOptions(new string[] { "" });
+ Response response = client.ReleaseCloudEvents("", "", releaseOptions, releaseDelayInSeconds: ReleaseDelay.By0Seconds);
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_ReleaseCloudEvents_AllParameters_Convenience_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ ReleaseOptions releaseOptions = new ReleaseOptions(new string[] { "" });
+ Response response = await client.ReleaseCloudEventsAsync("", "", releaseOptions, releaseDelayInSeconds: ReleaseDelay.By0Seconds);
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_RejectCloudEvents_ShortVersion()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = client.RejectCloudEvents("", "", content);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_RejectCloudEvents_ShortVersion_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = await client.RejectCloudEventsAsync("", "", content);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_RejectCloudEvents_ShortVersion_Convenience()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ RejectOptions rejectOptions = new RejectOptions(new string[] { "" });
+ Response response = client.RejectCloudEvents("", "", rejectOptions);
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_RejectCloudEvents_ShortVersion_Convenience_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ RejectOptions rejectOptions = new RejectOptions(new string[] { "" });
+ Response response = await client.RejectCloudEventsAsync("", "", rejectOptions);
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_RejectCloudEvents_AllParameters()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = client.RejectCloudEvents("", "", content);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_RejectCloudEvents_AllParameters_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ using RequestContent content = RequestContent.Create(new
+ {
+ lockTokens = new object[]
+ {
+""
+ },
+ });
+ Response response = await client.RejectCloudEventsAsync("", "", content);
+
+ JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
+ Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
+ Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public void Example_RejectCloudEvents_AllParameters_Convenience()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ RejectOptions rejectOptions = new RejectOptions(new string[] { "" });
+ Response response = client.RejectCloudEvents("", "", rejectOptions);
+ }
+
+ [Test]
+ [Ignore("Only validating compilation of examples")]
+ public async Task Example_RejectCloudEvents_AllParameters_Convenience_Async()
+ {
+ Uri endpoint = new Uri("");
+ AzureKeyCredential credential = new AzureKeyCredential("");
+ EventGridClient client = new EventGridClient(endpoint, credential);
+
+ RejectOptions rejectOptions = new RejectOptions(new string[] { "" });
+ Response