diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/Azure.ResourceManager.Contoso.sln b/sdk/contoso/Azure.ResourceManager.Contoso/Azure.ResourceManager.Contoso.sln
new file mode 100644
index 000000000000..d8be82e2db01
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/Azure.ResourceManager.Contoso.sln
@@ -0,0 +1,48 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.31903.59
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.Contoso", "src\Azure.ResourceManager.Contoso.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU
+ {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/contoso/Azure.ResourceManager.Contoso/metadata.json b/sdk/contoso/Azure.ResourceManager.Contoso/metadata.json
new file mode 100644
index 000000000000..fa58e6445bcb
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/metadata.json
@@ -0,0 +1,5 @@
+{
+ "apiVersions": {
+ "Microsoft.Contoso": "2021-11-01"
+ }
+}
\ No newline at end of file
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Azure.ResourceManager.Contoso.csproj b/sdk/contoso/Azure.ResourceManager.Contoso/src/Azure.ResourceManager.Contoso.csproj
new file mode 100644
index 000000000000..69d22a8d3f0e
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Azure.ResourceManager.Contoso.csproj
@@ -0,0 +1,9 @@
+
+
+ This is the Azure.ResourceManager.Contoso client library for developing .NET applications with rich experience.
+ SDK Code Generation Azure.ResourceManager.Contoso
+ 1.0.0-beta.1
+ Azure.ResourceManager.Contoso
+ true
+
+
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/ArmContosoModelFactory.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/ArmContosoModelFactory.cs
new file mode 100644
index 000000000000..15ffa4316f15
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/ArmContosoModelFactory.cs
@@ -0,0 +1,57 @@
+// 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;
+using Azure.Core;
+using Azure.ResourceManager.Contoso;
+using Azure.ResourceManager.Models;
+
+namespace Azure.ResourceManager.Contoso.Models
+{
+ /// A factory class for creating instances of the models for mocking.
+ public static partial class ArmContosoModelFactory
+ {
+
+ /// Employee resource.
+ /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
+ /// The name of the resource.
+ /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts".
+ /// Azure Resource Manager metadata containing createdBy and modifiedBy information.
+ /// Resource tags.
+ /// The geo-location where the resource lives.
+ /// The resource-specific properties for this resource.
+ /// A new instance for mocking.
+ public static EmployeeData EmployeeData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, EmployeeProperties properties = default)
+ {
+ tags ??= new ChangeTrackingDictionary();
+
+ return new EmployeeData(
+ id,
+ name,
+ resourceType,
+ systemData,
+ additionalBinaryDataProperties: null,
+ tags,
+ location,
+ properties);
+ }
+
+ /// Employee properties.
+ /// Age of employee.
+ /// City of employee.
+ /// Profile of employee.
+ /// The status of the last operation.
+ /// A new instance for mocking.
+ public static EmployeeProperties EmployeeProperties(int? age = default, string city = default, BinaryData profile = default, ProvisioningState? provisioningState = default)
+ {
+ return new EmployeeProperties(age, city, profile, provisioningState, additionalBinaryDataProperties: null);
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupAsyncCollectionResultOfT.cs
new file mode 100644
index 000000000000..e9e9943783f1
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupAsyncCollectionResultOfT.cs
@@ -0,0 +1,81 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager.Contoso.Models;
+
+namespace Azure.ResourceManager.Contoso
+{
+ internal partial class EmployeesGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable
+ {
+ private readonly Employees _client;
+ private readonly Guid _subscriptionId;
+ private readonly string _resourceGroupName;
+ private readonly RequestContext _context;
+
+ /// Initializes a new instance of EmployeesGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection.
+ /// The Employees client used to send requests.
+ /// The ID of the target subscription. The value must be an UUID.
+ /// The name of the resource group. The name is case insensitive.
+ /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
+ public EmployeesGetByResourceGroupAsyncCollectionResultOfT(Employees client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default)
+ {
+ _client = client;
+ _subscriptionId = subscriptionId;
+ _resourceGroupName = resourceGroupName;
+ _context = context;
+ }
+
+ /// Gets the pages of EmployeesGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection.
+ /// A continuation token indicating where to resume paging.
+ /// The number of items per page.
+ /// The pages of EmployeesGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection.
+ public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
+ {
+ Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
+ while (true)
+ {
+ Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false);
+ if (response is null)
+ {
+ yield break;
+ }
+ EmployeeListResult result = EmployeeListResult.FromResponse(response);
+ yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response);
+ nextPage = result.NextLink;
+ if (nextPage == null)
+ {
+ yield break;
+ }
+ }
+ }
+
+ /// Get next page.
+ /// The number of items per page.
+ /// The next link to use for the next page of results.
+ private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink)
+ {
+ HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context);
+ using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("EmployeeCollection.GetAll");
+ scope.Start();
+ try
+ {
+ return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupCollectionResultOfT.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupCollectionResultOfT.cs
new file mode 100644
index 000000000000..227c4c10852d
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetByResourceGroupCollectionResultOfT.cs
@@ -0,0 +1,80 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager.Contoso.Models;
+
+namespace Azure.ResourceManager.Contoso
+{
+ internal partial class EmployeesGetByResourceGroupCollectionResultOfT : Pageable
+ {
+ private readonly Employees _client;
+ private readonly Guid _subscriptionId;
+ private readonly string _resourceGroupName;
+ private readonly RequestContext _context;
+
+ /// Initializes a new instance of EmployeesGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection.
+ /// The Employees client used to send requests.
+ /// The ID of the target subscription. The value must be an UUID.
+ /// The name of the resource group. The name is case insensitive.
+ /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
+ public EmployeesGetByResourceGroupCollectionResultOfT(Employees client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default)
+ {
+ _client = client;
+ _subscriptionId = subscriptionId;
+ _resourceGroupName = resourceGroupName;
+ _context = context;
+ }
+
+ /// Gets the pages of EmployeesGetByResourceGroupCollectionResultOfT as an enumerable collection.
+ /// A continuation token indicating where to resume paging.
+ /// The number of items per page.
+ /// The pages of EmployeesGetByResourceGroupCollectionResultOfT as an enumerable collection.
+ public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
+ {
+ Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
+ while (true)
+ {
+ Response response = GetNextResponse(pageSizeHint, nextPage);
+ if (response is null)
+ {
+ yield break;
+ }
+ EmployeeListResult result = EmployeeListResult.FromResponse(response);
+ yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response);
+ nextPage = result.NextLink;
+ if (nextPage == null)
+ {
+ yield break;
+ }
+ }
+ }
+
+ /// Get next page.
+ /// The number of items per page.
+ /// The next link to use for the next page of results.
+ private Response GetNextResponse(int? pageSizeHint, Uri nextLink)
+ {
+ HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context);
+ using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("EmployeeCollection.GetAll");
+ scope.Start();
+ try
+ {
+ return _client.Pipeline.ProcessMessage(message, _context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionAsyncCollectionResultOfT.cs
new file mode 100644
index 000000000000..7d36bf4583fb
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionAsyncCollectionResultOfT.cs
@@ -0,0 +1,78 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager.Contoso.Models;
+
+namespace Azure.ResourceManager.Contoso
+{
+ internal partial class EmployeesGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable
+ {
+ private readonly Employees _client;
+ private readonly Guid _subscriptionId;
+ private readonly RequestContext _context;
+
+ /// Initializes a new instance of EmployeesGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection.
+ /// The Employees client used to send requests.
+ /// The ID of the target subscription. The value must be an UUID.
+ /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
+ public EmployeesGetBySubscriptionAsyncCollectionResultOfT(Employees client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default)
+ {
+ _client = client;
+ _subscriptionId = subscriptionId;
+ _context = context;
+ }
+
+ /// Gets the pages of EmployeesGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection.
+ /// A continuation token indicating where to resume paging.
+ /// The number of items per page.
+ /// The pages of EmployeesGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection.
+ public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
+ {
+ Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
+ while (true)
+ {
+ Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false);
+ if (response is null)
+ {
+ yield break;
+ }
+ EmployeeListResult result = EmployeeListResult.FromResponse(response);
+ yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response);
+ nextPage = result.NextLink;
+ if (nextPage == null)
+ {
+ yield break;
+ }
+ }
+ }
+
+ /// Get next page.
+ /// The number of items per page.
+ /// The next link to use for the next page of results.
+ private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink)
+ {
+ HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context);
+ using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableContosoSubscriptionResource.GetEmployees");
+ scope.Start();
+ try
+ {
+ return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionCollectionResultOfT.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionCollectionResultOfT.cs
new file mode 100644
index 000000000000..b5fb8fb0e65f
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/CollectionResults/EmployeesGetBySubscriptionCollectionResultOfT.cs
@@ -0,0 +1,77 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager.Contoso.Models;
+
+namespace Azure.ResourceManager.Contoso
+{
+ internal partial class EmployeesGetBySubscriptionCollectionResultOfT : Pageable
+ {
+ private readonly Employees _client;
+ private readonly Guid _subscriptionId;
+ private readonly RequestContext _context;
+
+ /// Initializes a new instance of EmployeesGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection.
+ /// The Employees client used to send requests.
+ /// The ID of the target subscription. The value must be an UUID.
+ /// The request options, which can override default behaviors of the client pipeline on a per-call basis.
+ public EmployeesGetBySubscriptionCollectionResultOfT(Employees client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default)
+ {
+ _client = client;
+ _subscriptionId = subscriptionId;
+ _context = context;
+ }
+
+ /// Gets the pages of EmployeesGetBySubscriptionCollectionResultOfT as an enumerable collection.
+ /// A continuation token indicating where to resume paging.
+ /// The number of items per page.
+ /// The pages of EmployeesGetBySubscriptionCollectionResultOfT as an enumerable collection.
+ public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint)
+ {
+ Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null;
+ while (true)
+ {
+ Response response = GetNextResponse(pageSizeHint, nextPage);
+ if (response is null)
+ {
+ yield break;
+ }
+ EmployeeListResult result = EmployeeListResult.FromResponse(response);
+ yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response);
+ nextPage = result.NextLink;
+ if (nextPage == null)
+ {
+ yield break;
+ }
+ }
+ }
+
+ /// Get next page.
+ /// The number of items per page.
+ /// The next link to use for the next page of results.
+ private Response GetNextResponse(int? pageSizeHint, Uri nextLink)
+ {
+ HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context);
+ using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableContosoSubscriptionResource.GetEmployees");
+ scope.Start();
+ try
+ {
+ return _client.Pipeline.ProcessMessage(message, _context);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeCollection.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeCollection.cs
new file mode 100644
index 000000000000..ad4d96066853
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeCollection.cs
@@ -0,0 +1,580 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Resources;
+
+namespace Azure.ResourceManager.Contoso
+{
+ ///
+ /// A class representing a collection of and their operations.
+ /// Each in the collection will belong to the same instance of .
+ /// To get a instance call the GetEmployees method from an instance of .
+ ///
+ public partial class EmployeeCollection : ArmCollection, IEnumerable, IAsyncEnumerable
+ {
+ private readonly ClientDiagnostics _employeesClientDiagnostics;
+ private readonly Employees _employeesRestClient;
+
+ /// Initializes a new instance of EmployeeCollection for mocking.
+ protected EmployeeCollection()
+ {
+ }
+
+ /// Initializes a new instance of class.
+ /// The client parameters to use in these operations.
+ /// The identifier of the resource that is the target of operations.
+ internal EmployeeCollection(ArmClient client, ResourceIdentifier id) : base(client, id)
+ {
+ TryGetApiVersion(EmployeeResource.ResourceType, out string employeeApiVersion);
+ _employeesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Contoso", EmployeeResource.ResourceType.Namespace, Diagnostics);
+ _employeesRestClient = new Employees(_employeesClientDiagnostics, Pipeline, Endpoint, employeeApiVersion ?? "2021-11-01");
+ ValidateResourceId(id);
+ }
+
+ ///
+ [Conditional("DEBUG")]
+ internal static void ValidateResourceId(ResourceIdentifier id)
+ {
+ if (id.ResourceType != ResourceGroupResource.ResourceType)
+ {
+ throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id);
+ }
+ }
+
+ ///
+ /// Create a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_CreateOrUpdate.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// The name of the Employee.
+ /// Resource create parameters.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string employeeName, EmployeeData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName));
+ Argument.AssertNotNull(data, nameof(data));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.CreateOrUpdate");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, EmployeeData.ToRequestContent(data), context);
+ Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ ContosoArmOperation operation = new ContosoArmOperation(
+ new EmployeeOperationSource(Client),
+ _employeesClientDiagnostics,
+ Pipeline,
+ message.Request,
+ response,
+ OperationFinalStateVia.AzureAsyncOperation);
+ if (waitUntil == WaitUntil.Completed)
+ {
+ await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
+ }
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Create a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_CreateOrUpdate.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// The name of the Employee.
+ /// Resource create parameters.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string employeeName, EmployeeData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName));
+ Argument.AssertNotNull(data, nameof(data));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.CreateOrUpdate");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, EmployeeData.ToRequestContent(data), context);
+ Response response = Pipeline.ProcessMessage(message, context);
+ ContosoArmOperation operation = new ContosoArmOperation(
+ new EmployeeOperationSource(Client),
+ _employeesClientDiagnostics,
+ Pipeline,
+ message.Request,
+ response,
+ OperationFinalStateVia.AzureAsyncOperation);
+ if (waitUntil == WaitUntil.Completed)
+ {
+ operation.WaitForCompletion(cancellationToken);
+ }
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Get a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Get.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The name of the Employee.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual async Task> GetAsync(string employeeName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.Get");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context);
+ Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ if (response.Value == null)
+ {
+ throw new RequestFailedException(response.GetRawResponse());
+ }
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Get a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Get.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The name of the Employee.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual Response Get(string employeeName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.Get");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context);
+ Response result = Pipeline.ProcessMessage(message, context);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ if (response.Value == null)
+ {
+ throw new RequestFailedException(response.GetRawResponse());
+ }
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// List Employee resources by resource group
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_ListByResourceGroup.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The cancellation token to use.
+ /// A collection of that may take multiple service requests to iterate over.
+ public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default)
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ return new AsyncPageableWrapper(new EmployeesGetByResourceGroupAsyncCollectionResultOfT(_employeesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new EmployeeResource(Client, data));
+ }
+
+ ///
+ /// List Employee resources by resource group
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_ListByResourceGroup.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The cancellation token to use.
+ /// A collection of that may take multiple service requests to iterate over.
+ public virtual Pageable GetAll(CancellationToken cancellationToken = default)
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ return new PageableWrapper(new EmployeesGetByResourceGroupCollectionResultOfT(_employeesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new EmployeeResource(Client, data));
+ }
+
+ ///
+ /// Checks to see if the resource exists in azure.
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Get.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The name of the Employee.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual async Task> ExistsAsync(string employeeName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.Exists");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context);
+ await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false);
+ Response result = message.Response;
+ Response response = default;
+ switch (result.Status)
+ {
+ case 200:
+ response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ break;
+ case 404:
+ response = Response.FromValue((EmployeeData)null, result);
+ break;
+ default:
+ throw new RequestFailedException(result);
+ }
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Checks to see if the resource exists in azure.
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Get.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The name of the Employee.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual Response Exists(string employeeName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.Exists");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context);
+ Pipeline.Send(message, context.CancellationToken);
+ Response result = message.Response;
+ Response response = default;
+ switch (result.Status)
+ {
+ case 200:
+ response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ break;
+ case 404:
+ response = Response.FromValue((EmployeeData)null, result);
+ break;
+ default:
+ throw new RequestFailedException(result);
+ }
+ return Response.FromValue(response.Value != null, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Tries to get details for this resource from the service.
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Get.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The name of the Employee.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual async Task> GetIfExistsAsync(string employeeName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.GetIfExists");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context);
+ await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false);
+ Response result = message.Response;
+ Response response = default;
+ switch (result.Status)
+ {
+ case 200:
+ response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ break;
+ case 404:
+ response = Response.FromValue((EmployeeData)null, result);
+ break;
+ default:
+ throw new RequestFailedException(result);
+ }
+ if (response.Value == null)
+ {
+ return new NoValueResponse(response.GetRawResponse());
+ }
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Tries to get details for this resource from the service.
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Get.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The name of the Employee.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ public virtual NullableResponse GetIfExists(string employeeName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeCollection.GetIfExists");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, employeeName, context);
+ Pipeline.Send(message, context.CancellationToken);
+ Response result = message.Response;
+ Response response = default;
+ switch (result.Status)
+ {
+ case 200:
+ response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ break;
+ case 404:
+ response = Response.FromValue((EmployeeData)null, result);
+ break;
+ default:
+ throw new RequestFailedException(result);
+ }
+ if (response.Value == null)
+ {
+ return new NoValueResponse(response.GetRawResponse());
+ }
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetAll().GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetAll().GetEnumerator();
+ }
+
+ /// The cancellation token to use.
+ IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken)
+ {
+ return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken);
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.Serialization.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.Serialization.cs
new file mode 100644
index 000000000000..d44441c50548
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.Serialization.cs
@@ -0,0 +1,229 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.Json;
+using Azure;
+using Azure.Core;
+using Azure.ResourceManager.Contoso.Models;
+using Azure.ResourceManager.Models;
+
+namespace Azure.ResourceManager.Contoso
+{
+ /// Employee resource.
+ public partial class EmployeeData : TrackedResourceData, IJsonModel
+ {
+ /// Initializes a new instance of for deserialization.
+ internal EmployeeData()
+ {
+ }
+
+ /// The data to parse.
+ /// The client options for reading and writing models.
+ protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options)
+ {
+ string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ switch (format)
+ {
+ case "J":
+ using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions))
+ {
+ return DeserializeEmployeeData(document.RootElement, options);
+ }
+ default:
+ throw new FormatException($"The model {nameof(EmployeeData)} does not support reading '{options.Format}' format.");
+ }
+ }
+
+ /// The client options for reading and writing models.
+ protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options)
+ {
+ string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ switch (format)
+ {
+ case "J":
+ return ModelReaderWriter.Write(this, options, AzureResourceManagerContosoContext.Default);
+ default:
+ throw new FormatException($"The model {nameof(EmployeeData)} does not support writing '{options.Format}' format.");
+ }
+ }
+
+ /// The client options for reading and writing models.
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);
+
+ /// The data to parse.
+ /// The client options for reading and writing models.
+ EmployeeData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EmployeeData)PersistableModelCreateCore(data, options);
+
+ /// The client options for reading and writing models.
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
+
+ /// The to serialize into .
+ internal static RequestContent ToRequestContent(EmployeeData employeeData)
+ {
+ if (employeeData == null)
+ {
+ return null;
+ }
+ return RequestContent.Create(employeeData, ModelSerializationExtensions.WireOptions);
+ }
+
+ /// The to deserialize the from.
+ internal static EmployeeData FromResponse(Response response)
+ {
+ using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions);
+ return DeserializeEmployeeData(document.RootElement, ModelSerializationExtensions.WireOptions);
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ writer.WriteStartObject();
+ JsonModelWriteCore(writer, options);
+ writer.WriteEndObject();
+ }
+
+ /// The JSON writer.
+ /// The client options for reading and writing models.
+ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
+ {
+ string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(EmployeeData)} does not support writing '{format}' format.");
+ }
+ base.JsonModelWriteCore(writer, options);
+ if (Optional.IsDefined(Properties))
+ {
+ writer.WritePropertyName("properties"u8);
+ writer.WriteObjectValue(Properties, options);
+ }
+ }
+
+ /// The JSON reader.
+ /// The client options for reading and writing models.
+ EmployeeData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EmployeeData)JsonModelCreateCore(ref reader, options);
+
+ /// The JSON reader.
+ /// The client options for reading and writing models.
+ protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
+ {
+ string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format;
+ if (format != "J")
+ {
+ throw new FormatException($"The model {nameof(EmployeeData)} does not support reading '{format}' format.");
+ }
+ using JsonDocument document = JsonDocument.ParseValue(ref reader);
+ return DeserializeEmployeeData(document.RootElement, options);
+ }
+
+ /// The JSON element to deserialize.
+ /// The client options for reading and writing models.
+ internal static EmployeeData DeserializeEmployeeData(JsonElement element, ModelReaderWriterOptions options)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ ResourceIdentifier id = default;
+ string name = default;
+ ResourceType resourceType = default;
+ SystemData systemData = default;
+ IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary();
+ IDictionary tags = default;
+ AzureLocation location = default;
+ EmployeeProperties properties = default;
+ foreach (var prop in element.EnumerateObject())
+ {
+ if (prop.NameEquals("id"u8))
+ {
+ if (prop.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ id = new ResourceIdentifier(prop.Value.GetString());
+ continue;
+ }
+ if (prop.NameEquals("name"u8))
+ {
+ name = prop.Value.GetString();
+ continue;
+ }
+ if (prop.NameEquals("type"u8))
+ {
+ if (prop.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ resourceType = new ResourceType(prop.Value.GetString());
+ continue;
+ }
+ if (prop.NameEquals("systemData"u8))
+ {
+ if (prop.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerContosoContext.Default);
+ continue;
+ }
+ if (prop.NameEquals("tags"u8))
+ {
+ if (prop.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ Dictionary dictionary = new Dictionary();
+ foreach (var prop0 in prop.Value.EnumerateObject())
+ {
+ if (prop0.Value.ValueKind == JsonValueKind.Null)
+ {
+ dictionary.Add(prop0.Name, null);
+ }
+ else
+ {
+ dictionary.Add(prop0.Name, prop0.Value.GetString());
+ }
+ }
+ tags = dictionary;
+ continue;
+ }
+ if (prop.NameEquals("location"u8))
+ {
+ location = new AzureLocation(prop.Value.GetString());
+ continue;
+ }
+ if (prop.NameEquals("properties"u8))
+ {
+ if (prop.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ properties = EmployeeProperties.DeserializeEmployeeProperties(prop.Value, options);
+ continue;
+ }
+ if (options.Format != "W")
+ {
+ additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText()));
+ }
+ }
+ return new EmployeeData(
+ id,
+ name,
+ resourceType,
+ systemData,
+ additionalBinaryDataProperties,
+ tags ?? new ChangeTrackingDictionary(),
+ location,
+ properties);
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.cs
new file mode 100644
index 000000000000..7f8e0b7c6ebf
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeData.cs
@@ -0,0 +1,46 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using Azure.Core;
+using Azure.ResourceManager.Contoso.Models;
+using Azure.ResourceManager.Models;
+
+namespace Azure.ResourceManager.Contoso
+{
+ /// Employee resource.
+ public partial class EmployeeData : TrackedResourceData
+ {
+ /// Keeps track of any properties unknown to the library.
+ private protected readonly IDictionary _additionalBinaryDataProperties;
+
+ /// Initializes a new instance of .
+ /// The geo-location where the resource lives.
+ public EmployeeData(AzureLocation location) : base(location)
+ {
+ }
+
+ /// Initializes a new instance of .
+ /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
+ /// The name of the resource.
+ /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts".
+ /// Azure Resource Manager metadata containing createdBy and modifiedBy information.
+ /// Keeps track of any properties unknown to the library.
+ /// Resource tags.
+ /// The geo-location where the resource lives.
+ /// The resource-specific properties for this resource.
+ internal EmployeeData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, EmployeeProperties properties) : base(id, name, resourceType, systemData, tags, location)
+ {
+ _additionalBinaryDataProperties = additionalBinaryDataProperties;
+ Properties = properties;
+ }
+
+ /// The resource-specific properties for this resource.
+ public EmployeeProperties Properties { get; set; }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.Serialization.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.Serialization.cs
new file mode 100644
index 000000000000..e71f1c6d90b3
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.Serialization.cs
@@ -0,0 +1,39 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Text.Json;
+
+namespace Azure.ResourceManager.Contoso
+{
+ ///
+ public partial class EmployeeResource : IJsonModel
+ {
+ private static IJsonModel s_dataDeserializationInstance;
+
+ private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new EmployeeData();
+
+ /// The writer to serialize the model to.
+ /// The client options for reading and writing models.
+ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options);
+
+ /// The reader for deserializing the model.
+ /// The client options for reading and writing models.
+ EmployeeData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options);
+
+ /// The client options for reading and writing models.
+ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerContosoContext.Default);
+
+ /// The binary data to be processed.
+ /// The client options for reading and writing models.
+ EmployeeData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerContosoContext.Default);
+
+ /// The client options for reading and writing models.
+ string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options);
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.cs
new file mode 100644
index 000000000000..db9f07bb1808
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/EmployeeResource.cs
@@ -0,0 +1,667 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Resources;
+
+namespace Azure.ResourceManager.Contoso
+{
+ ///
+ /// A class representing a Employee along with the instance operations that can be performed on it.
+ /// If you have a you can construct a from an instance of using the GetResource method.
+ /// Otherwise you can get one from its parent resource using the GetEmployees method.
+ ///
+ public partial class EmployeeResource : ArmResource
+ {
+ private readonly ClientDiagnostics _employeesClientDiagnostics;
+ private readonly Employees _employeesRestClient;
+ private readonly EmployeeData _data;
+ /// Gets the resource type for the operations.
+ public static readonly ResourceType ResourceType = "Microsoft.Contoso/employees";
+
+ /// Initializes a new instance of EmployeeResource for mocking.
+ protected EmployeeResource()
+ {
+ }
+
+ /// Initializes a new instance of class.
+ /// The client parameters to use in these operations.
+ /// The resource that is the target of operations.
+ internal EmployeeResource(ArmClient client, EmployeeData data) : this(client, data.Id)
+ {
+ HasData = true;
+ _data = data;
+ }
+
+ /// Initializes a new instance of class.
+ /// The client parameters to use in these operations.
+ /// The identifier of the resource that is the target of operations.
+ internal EmployeeResource(ArmClient client, ResourceIdentifier id) : base(client, id)
+ {
+ TryGetApiVersion(ResourceType, out string employeeApiVersion);
+ _employeesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Contoso", ResourceType.Namespace, Diagnostics);
+ _employeesRestClient = new Employees(_employeesClientDiagnostics, Pipeline, Endpoint, employeeApiVersion ?? "2021-11-01");
+ ValidateResourceId(id);
+ }
+
+ /// Gets whether or not the current instance has data.
+ public virtual bool HasData { get; }
+
+ /// Gets the data representing this Feature.
+ public virtual EmployeeData Data
+ {
+ get
+ {
+ if (!HasData)
+ {
+ throw new InvalidOperationException("The current instance does not have data, you must call Get first.");
+ }
+ return _data;
+ }
+ }
+
+ /// Generate the resource identifier for this resource.
+ /// The subscriptionId.
+ /// The resourceGroupName.
+ /// The employeeName.
+ public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string employeeName)
+ {
+ string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}";
+ return new ResourceIdentifier(resourceId);
+ }
+
+ ///
+ [Conditional("DEBUG")]
+ internal static void ValidateResourceId(ResourceIdentifier id)
+ {
+ if (id.ResourceType != ResourceType)
+ {
+ throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id);
+ }
+ }
+
+ ///
+ /// Get a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Get.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ /// -
+ /// Resource.
+ /// .
+ ///
+ ///
+ ///
+ /// The cancellation token to use.
+ public virtual async Task> GetAsync(CancellationToken cancellationToken = default)
+ {
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.Get");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context);
+ Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ if (response.Value == null)
+ {
+ throw new RequestFailedException(response.GetRawResponse());
+ }
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Get a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Get.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ /// -
+ /// Resource.
+ /// .
+ ///
+ ///
+ ///
+ /// The cancellation token to use.
+ public virtual Response Get(CancellationToken cancellationToken = default)
+ {
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.Get");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context);
+ Response result = Pipeline.ProcessMessage(message, context);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ if (response.Value == null)
+ {
+ throw new RequestFailedException(response.GetRawResponse());
+ }
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Update a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Update.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ /// -
+ /// Resource.
+ /// .
+ ///
+ ///
+ ///
+ /// The resource properties to be updated.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual async Task> UpdateAsync(EmployeeData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(data, nameof(data));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.Update");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, EmployeeData.ToRequestContent(data), context);
+ Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ if (response.Value == null)
+ {
+ throw new RequestFailedException(response.GetRawResponse());
+ }
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Update a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Update.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ /// -
+ /// Resource.
+ /// .
+ ///
+ ///
+ ///
+ /// The resource properties to be updated.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual Response Update(EmployeeData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(data, nameof(data));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.Update");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, EmployeeData.ToRequestContent(data), context);
+ Response result = Pipeline.ProcessMessage(message, context);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ if (response.Value == null)
+ {
+ throw new RequestFailedException(response.GetRawResponse());
+ }
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Delete a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Delete.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ /// -
+ /// Resource.
+ /// .
+ ///
+ ///
+ ///
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// The cancellation token to use.
+ public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default)
+ {
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.Delete");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context);
+ Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ ContosoArmOperation operation = new ContosoArmOperation(_employeesClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ {
+ await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false);
+ }
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Delete a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Delete.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ /// -
+ /// Resource.
+ /// .
+ ///
+ ///
+ ///
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// The cancellation token to use.
+ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default)
+ {
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.Delete");
+ scope.Start();
+ try
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context);
+ Response response = Pipeline.ProcessMessage(message, context);
+ ContosoArmOperation operation = new ContosoArmOperation(_employeesClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ {
+ operation.WaitForCompletionResponse(cancellationToken);
+ }
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Add a tag to the current resource.
+ /// The key for the tag.
+ /// The value for the tag.
+ /// The cancellation token to use.
+ /// or is null.
+ public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(key, nameof(key));
+ Argument.AssertNotNull(value, nameof(value));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.AddTag");
+ scope.Start();
+ try
+ {
+ if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false))
+ {
+ Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false);
+ originalTags.Value.Data.TagValues[key] = value;
+ await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false);
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context);
+ Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ else
+ {
+ EmployeeData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data;
+ EmployeeData patch = new EmployeeData();
+ foreach (KeyValuePair tag in current.Tags)
+ {
+ patch.Tags.Add(tag);
+ }
+ patch.Tags[key] = value;
+ Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(result.Value, result.GetRawResponse());
+ }
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Add a tag to the current resource.
+ /// The key for the tag.
+ /// The value for the tag.
+ /// The cancellation token to use.
+ /// or is null.
+ public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(key, nameof(key));
+ Argument.AssertNotNull(value, nameof(value));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.AddTag");
+ scope.Start();
+ try
+ {
+ if (CanUseTagResource(cancellationToken))
+ {
+ Response originalTags = GetTagResource().Get(cancellationToken);
+ originalTags.Value.Data.TagValues[key] = value;
+ GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken);
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context);
+ Response result = Pipeline.ProcessMessage(message, context);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ else
+ {
+ EmployeeData current = Get(cancellationToken: cancellationToken).Value.Data;
+ EmployeeData patch = new EmployeeData();
+ foreach (KeyValuePair tag in current.Tags)
+ {
+ patch.Tags.Add(tag);
+ }
+ patch.Tags[key] = value;
+ Response result = Update(patch, cancellationToken: cancellationToken);
+ return Response.FromValue(result.Value, result.GetRawResponse());
+ }
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Replace the tags on the resource with the given set.
+ /// The tags to set on the resource.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(tags, nameof(tags));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.SetTags");
+ scope.Start();
+ try
+ {
+ if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false))
+ {
+ await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false);
+ Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false);
+ originalTags.Value.Data.TagValues.ReplaceWith(tags);
+ await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false);
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context);
+ Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ else
+ {
+ EmployeeData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data;
+ EmployeeData patch = new EmployeeData();
+ patch.Tags.ReplaceWith(tags);
+ Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(result.Value, result.GetRawResponse());
+ }
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Replace the tags on the resource with the given set.
+ /// The tags to set on the resource.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(tags, nameof(tags));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.SetTags");
+ scope.Start();
+ try
+ {
+ if (CanUseTagResource(cancellationToken))
+ {
+ GetTagResource().Delete(WaitUntil.Completed, cancellationToken);
+ Response originalTags = GetTagResource().Get(cancellationToken);
+ originalTags.Value.Data.TagValues.ReplaceWith(tags);
+ GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken);
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context);
+ Response result = Pipeline.ProcessMessage(message, context);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ else
+ {
+ EmployeeData current = Get(cancellationToken: cancellationToken).Value.Data;
+ EmployeeData patch = new EmployeeData();
+ patch.Tags.ReplaceWith(tags);
+ Response result = Update(patch, cancellationToken: cancellationToken);
+ return Response.FromValue(result.Value, result.GetRawResponse());
+ }
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Removes a tag by key from the resource.
+ /// The key for the tag.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(key, nameof(key));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.RemoveTag");
+ scope.Start();
+ try
+ {
+ if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false))
+ {
+ Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false);
+ originalTags.Value.Data.TagValues.Remove(key);
+ await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false);
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context);
+ Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ else
+ {
+ EmployeeData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data;
+ EmployeeData patch = new EmployeeData();
+ foreach (KeyValuePair tag in current.Tags)
+ {
+ patch.Tags.Add(tag);
+ }
+ patch.Tags.Remove(key);
+ Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Response.FromValue(result.Value, result.GetRawResponse());
+ }
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ /// Removes a tag by key from the resource.
+ /// The key for the tag.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(key, nameof(key));
+
+ using DiagnosticScope scope = _employeesClientDiagnostics.CreateScope("EmployeeResource.RemoveTag");
+ scope.Start();
+ try
+ {
+ if (CanUseTagResource(cancellationToken))
+ {
+ Response originalTags = GetTagResource().Get(cancellationToken);
+ originalTags.Value.Data.TagValues.Remove(key);
+ GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken);
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ HttpMessage message = _employeesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context);
+ Response result = Pipeline.ProcessMessage(message, context);
+ Response response = Response.FromValue(EmployeeData.FromResponse(result), result);
+ return Response.FromValue(new EmployeeResource(Client, response.Value), response.GetRawResponse());
+ }
+ else
+ {
+ EmployeeData current = Get(cancellationToken: cancellationToken).Value.Data;
+ EmployeeData patch = new EmployeeData();
+ foreach (KeyValuePair tag in current.Tags)
+ {
+ patch.Tags.Add(tag);
+ }
+ patch.Tags.Remove(key);
+ Response result = Update(patch, cancellationToken: cancellationToken);
+ return Response.FromValue(result.Value, result.GetRawResponse());
+ }
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/ContosoExtensions.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/ContosoExtensions.cs
new file mode 100644
index 000000000000..41a8b69f174b
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/ContosoExtensions.cs
@@ -0,0 +1,149 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Contoso.Mocking;
+using Azure.ResourceManager.Resources;
+
+namespace Azure.ResourceManager.Contoso
+{
+ /// A class to add extension methods to Azure.ResourceManager.Contoso.
+ public static partial class ContosoExtensions
+ {
+ ///
+ private static MockableContosoArmClient GetMockableContosoArmClient(ArmClient client)
+ {
+ return client.GetCachedClient(client0 => new MockableContosoArmClient(client0, ResourceIdentifier.Root));
+ }
+
+ ///
+ private static MockableContosoResourceGroupResource GetMockableContosoResourceGroupResource(ResourceGroupResource resourceGroupResource)
+ {
+ return resourceGroupResource.GetCachedClient(client => new MockableContosoResourceGroupResource(client, resourceGroupResource.Id));
+ }
+
+ ///
+ private static MockableContosoSubscriptionResource GetMockableContosoSubscriptionResource(SubscriptionResource subscriptionResource)
+ {
+ return subscriptionResource.GetCachedClient(client => new MockableContosoSubscriptionResource(client, subscriptionResource.Id));
+ }
+
+ ///
+ /// Gets an object representing a along with the instance operations that can be performed on it but with no data.
+ /// -
+ /// Mocking.
+ /// To mock this method, please mock instead.
+ ///
+ ///
+ /// The the method will execute against.
+ /// The resource ID of the resource to get.
+ /// is null.
+ /// Returns a object.
+ public static EmployeeResource GetEmployeeResource(this ArmClient client, ResourceIdentifier id)
+ {
+ Argument.AssertNotNull(client, nameof(client));
+
+ return GetMockableContosoArmClient(client).GetEmployeeResource(id);
+ }
+
+ ///
+ /// Gets a collection of Employees in the
+ /// -
+ /// Mocking.
+ /// To mock this method, please mock instead.
+ ///
+ ///
+ /// The the method will execute against.
+ /// is null.
+ /// An object representing collection of Employees and their operations over a EmployeeResource.
+ public static EmployeeCollection GetEmployees(this ResourceGroupResource resourceGroupResource)
+ {
+ Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource));
+
+ return GetMockableContosoResourceGroupResource(resourceGroupResource).GetEmployees();
+ }
+
+ ///
+ /// Get a Employee
+ /// -
+ /// Mocking.
+ /// To mock this method, please mock instead.
+ ///
+ ///
+ /// The the method will execute against.
+ /// The name of the Employee.
+ /// The cancellation token to use.
+ /// is null.
+ [ForwardsClientCalls]
+ public static async Task> GetEmployeeAsync(this ResourceGroupResource resourceGroupResource, string employeeName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource));
+
+ return await GetMockableContosoResourceGroupResource(resourceGroupResource).GetEmployeeAsync(employeeName, cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// Get a Employee
+ /// -
+ /// Mocking.
+ /// To mock this method, please mock instead.
+ ///
+ ///
+ /// The the method will execute against.
+ /// The name of the Employee.
+ /// The cancellation token to use.
+ /// is null.
+ [ForwardsClientCalls]
+ public static Response GetEmployee(this ResourceGroupResource resourceGroupResource, string employeeName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource));
+
+ return GetMockableContosoResourceGroupResource(resourceGroupResource).GetEmployee(employeeName, cancellationToken);
+ }
+
+ ///
+ /// List Employee resources by subscription ID
+ /// -
+ /// Mocking.
+ /// To mock this method, please mock instead.
+ ///
+ ///
+ /// The the method will execute against.
+ /// The cancellation token to use.
+ /// is null.
+ /// A collection of that may take multiple service requests to iterate over.
+ public static AsyncPageable GetEmployeesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
+
+ return GetMockableContosoSubscriptionResource(subscriptionResource).GetEmployeesAsync(cancellationToken);
+ }
+
+ ///
+ /// List Employee resources by subscription ID
+ /// -
+ /// Mocking.
+ /// To mock this method, please mock instead.
+ ///
+ ///
+ /// The the method will execute against.
+ /// The cancellation token to use.
+ /// is null.
+ /// A collection of that may take multiple service requests to iterate over.
+ public static Pageable GetEmployees(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource));
+
+ return GetMockableContosoSubscriptionResource(subscriptionResource).GetEmployees(cancellationToken);
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoArmClient.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoArmClient.cs
new file mode 100644
index 000000000000..3450bca08072
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoArmClient.cs
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using Azure.Core;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Contoso;
+
+namespace Azure.ResourceManager.Contoso.Mocking
+{
+ /// A class to add extension methods to .
+ public partial class MockableContosoArmClient : ArmResource
+ {
+ /// Initializes a new instance of MockableContosoArmClient for mocking.
+ protected MockableContosoArmClient()
+ {
+ }
+
+ /// Initializes a new instance of class.
+ /// The client parameters to use in these operations.
+ /// The identifier of the resource that is the target of operations.
+ internal MockableContosoArmClient(ArmClient client, ResourceIdentifier id) : base(client, id)
+ {
+ }
+
+ /// Gets an object representing a along with the instance operations that can be performed on it but with no data.
+ /// The resource ID of the resource to get.
+ /// Returns a object.
+ public virtual EmployeeResource GetEmployeeResource(ResourceIdentifier id)
+ {
+ EmployeeResource.ValidateResourceId(id);
+ return new EmployeeResource(Client, id);
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoResourceGroupResource.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoResourceGroupResource.cs
new file mode 100644
index 000000000000..a50ea1e839b7
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoResourceGroupResource.cs
@@ -0,0 +1,99 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Contoso;
+using Azure.ResourceManager.Resources;
+
+namespace Azure.ResourceManager.Contoso.Mocking
+{
+ /// A class to add extension methods to .
+ public partial class MockableContosoResourceGroupResource : ArmResource
+ {
+ /// Initializes a new instance of MockableContosoResourceGroupResource for mocking.
+ protected MockableContosoResourceGroupResource()
+ {
+ }
+
+ /// Initializes a new instance of class.
+ /// The client parameters to use in these operations.
+ /// The identifier of the resource that is the target of operations.
+ internal MockableContosoResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id)
+ {
+ }
+
+ /// Gets a collection of Employees in the .
+ /// An object representing collection of Employees and their operations over a EmployeeResource.
+ public virtual EmployeeCollection GetEmployees()
+ {
+ return GetCachedClient(client => new EmployeeCollection(client, Id));
+ }
+
+ ///
+ /// Get a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Get.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The name of the Employee.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ [ForwardsClientCalls]
+ public virtual async Task> GetEmployeeAsync(string employeeName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName));
+
+ return await GetEmployees().GetAsync(employeeName, cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// Get a Employee
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_Get.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The name of the Employee.
+ /// The cancellation token to use.
+ /// is null.
+ /// is an empty string, and was expected to be non-empty.
+ [ForwardsClientCalls]
+ public virtual Response GetEmployee(string employeeName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(employeeName, nameof(employeeName));
+
+ return GetEmployees().Get(employeeName, cancellationToken);
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoSubscriptionResource.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoSubscriptionResource.cs
new file mode 100644
index 000000000000..0cea4cbf9e82
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Extensions/MockableContosoSubscriptionResource.cs
@@ -0,0 +1,97 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Threading;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Contoso;
+using Azure.ResourceManager.Resources;
+
+namespace Azure.ResourceManager.Contoso.Mocking
+{
+ /// A class to add extension methods to .
+ public partial class MockableContosoSubscriptionResource : ArmResource
+ {
+ private ClientDiagnostics _employeesClientDiagnostics;
+ private Employees _employeesRestClient;
+
+ /// Initializes a new instance of MockableContosoSubscriptionResource for mocking.
+ protected MockableContosoSubscriptionResource()
+ {
+ }
+
+ /// Initializes a new instance of class.
+ /// The client parameters to use in these operations.
+ /// The identifier of the resource that is the target of operations.
+ internal MockableContosoSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id)
+ {
+ }
+
+ private ClientDiagnostics EmployeesClientDiagnostics => _employeesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Contoso.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics);
+
+ private Employees EmployeesRestClient => _employeesRestClient ??= new Employees(EmployeesClientDiagnostics, Pipeline, Endpoint, "2021-11-01");
+
+ ///
+ /// List Employee resources by subscription ID
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/providers/Microsoft.Contoso/employees.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_ListBySubscription.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The cancellation token to use.
+ /// A collection of that may take multiple service requests to iterate over.
+ public virtual AsyncPageable GetEmployeesAsync(CancellationToken cancellationToken = default)
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ return new AsyncPageableWrapper(new EmployeesGetBySubscriptionAsyncCollectionResultOfT(EmployeesRestClient, Guid.Parse(Id.SubscriptionId), context), data => new EmployeeResource(Client, data));
+ }
+
+ ///
+ /// List Employee resources by subscription ID
+ ///
+ /// -
+ /// Request Path.
+ /// /subscriptions/{subscriptionId}/providers/Microsoft.Contoso/employees.
+ ///
+ /// -
+ /// Operation Id.
+ /// Employees_ListBySubscription.
+ ///
+ /// -
+ /// Default Api Version.
+ /// 2021-11-01.
+ ///
+ ///
+ ///
+ /// The cancellation token to use.
+ /// A collection of that may take multiple service requests to iterate over.
+ public virtual Pageable GetEmployees(CancellationToken cancellationToken = default)
+ {
+ RequestContext context = new RequestContext
+ {
+ CancellationToken = cancellationToken
+ };
+ return new PageableWrapper(new EmployeesGetBySubscriptionCollectionResultOfT(EmployeesRestClient, Guid.Parse(Id.SubscriptionId), context), data => new EmployeeResource(Client, data));
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/Argument.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/Argument.cs
new file mode 100644
index 000000000000..8261d31c3590
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/Argument.cs
@@ -0,0 +1,113 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Azure.ResourceManager.Contoso
+{
+ internal static partial class Argument
+ {
+ /// The value.
+ /// The name.
+ public static void AssertNotNull(T value, string name)
+ {
+ if (value is null)
+ {
+ throw new ArgumentNullException(name);
+ }
+ }
+
+ /// The value.
+ /// The name.
+ public static void AssertNotNull(T? value, string name)
+ where T : struct
+ {
+ if (!value.HasValue)
+ {
+ throw new ArgumentNullException(name);
+ }
+ }
+
+ /// The value.
+ /// The name.
+ public static void AssertNotNullOrEmpty(IEnumerable value, string name)
+ {
+ if (value is null)
+ {
+ throw new ArgumentNullException(name);
+ }
+ if (value is ICollection collectionOfT && collectionOfT.Count == 0)
+ {
+ throw new ArgumentException("Value cannot be an empty collection.", name);
+ }
+ if (value is ICollection collection && collection.Count == 0)
+ {
+ throw new ArgumentException("Value cannot be an empty collection.", name);
+ }
+ using IEnumerator e = value.GetEnumerator();
+ if (!e.MoveNext())
+ {
+ throw new ArgumentException("Value cannot be an empty collection.", name);
+ }
+ }
+
+ /// The value.
+ /// The name.
+ public static void AssertNotNullOrEmpty(string value, string name)
+ {
+ if (value is null)
+ {
+ throw new ArgumentNullException(name);
+ }
+ if (value.Length == 0)
+ {
+ throw new ArgumentException("Value cannot be an empty string.", name);
+ }
+ }
+
+ /// The value.
+ /// The name.
+ public static void AssertNotNullOrWhiteSpace(string value, string name)
+ {
+ if (value is null)
+ {
+ throw new ArgumentNullException(name);
+ }
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name);
+ }
+ }
+
+ /// The value.
+ /// The minimum value.
+ /// The maximum value.
+ /// The name.
+ public static void AssertInRange(T value, T minimum, T maximum, string name)
+ where T : notnull, IComparable
+ {
+ if (minimum.CompareTo(value) > 0)
+ {
+ throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed.");
+ }
+ if (maximum.CompareTo(value) < 0)
+ {
+ throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed.");
+ }
+ }
+
+ /// The value.
+ /// The name.
+ public static string CheckNotNullOrEmpty(string value, string name)
+ {
+ AssertNotNullOrEmpty(value, name);
+ return value;
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/AsyncPageableWrapper.cs
new file mode 100644
index 000000000000..c1a22dcfc8b5
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/AsyncPageableWrapper.cs
@@ -0,0 +1,48 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Azure;
+
+namespace Azure.ResourceManager.Contoso
+{
+ internal partial class AsyncPageableWrapper : AsyncPageable
+ {
+ /// The source async pageable value of type AsyncPageable<T>.
+ private AsyncPageable _source;
+ /// The converter function from T to U.
+ private Func _converter;
+
+ /// Initializes a new instance of the AsyncPageableWrapper class.
+ /// The source async pageable value of type AsyncPageable<T>.
+ /// The converter function from T to U.
+ public AsyncPageableWrapper(AsyncPageable source, Func converter)
+ {
+ _source = source;
+ _converter = converter;
+ }
+
+ /// Converts the pages from AsyncPageable to Page.
+ /// A continuation token from a previous response.
+ /// An optional hint to specify the desired size of each page.
+ /// An enumerable of pages containing converted items of type U.
+ public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint)
+ {
+ await foreach (Page page in _source.AsPages(continuationToken, pageSizeHint).ConfigureAwait(false))
+ {
+ List convertedItems = new List();
+ foreach (T item in page.Values)
+ {
+ convertedItems.Add(_converter.Invoke(item));
+ }
+ yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse());
+ }
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ChangeTrackingDictionary.cs
new file mode 100644
index 000000000000..da6e2e13a2a9
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ChangeTrackingDictionary.cs
@@ -0,0 +1,189 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Azure.ResourceManager.Contoso
+{
+ internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary
+ where TKey : notnull
+ {
+ private IDictionary _innerDictionary;
+
+ public ChangeTrackingDictionary()
+ {
+ }
+
+ /// The inner dictionary.
+ public ChangeTrackingDictionary(IDictionary dictionary)
+ {
+ if (dictionary == null)
+ {
+ return;
+ }
+ _innerDictionary = new Dictionary(dictionary);
+ }
+
+ /// The inner dictionary.
+ public ChangeTrackingDictionary(IReadOnlyDictionary dictionary)
+ {
+ if (dictionary == null)
+ {
+ return;
+ }
+ _innerDictionary = new Dictionary();
+ foreach (var pair in dictionary)
+ {
+ _innerDictionary.Add(pair);
+ }
+ }
+
+ /// Gets the IsUndefined.
+ public bool IsUndefined => _innerDictionary == null;
+
+ /// Gets the Count.
+ public int Count => IsUndefined ? 0 : EnsureDictionary().Count;
+
+ /// Gets the IsReadOnly.
+ public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly;
+
+ /// Gets the Keys.
+ public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys;
+
+ /// Gets the Values.
+ public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values;
+
+ /// Gets or sets the value associated with the specified key.
+ public TValue this[TKey key]
+ {
+ get
+ {
+ if (IsUndefined)
+ {
+ throw new KeyNotFoundException(nameof(key));
+ }
+ return EnsureDictionary()[key];
+ }
+ set
+ {
+ EnsureDictionary()[key] = value;
+ }
+ }
+
+ /// Gets the Keys.
+ IEnumerable IReadOnlyDictionary.Keys => Keys;
+
+ /// Gets the Values.
+ IEnumerable IReadOnlyDictionary.Values => Values;
+
+ public IEnumerator> GetEnumerator()
+ {
+ if (IsUndefined)
+ {
+ IEnumerator> enumerateEmpty()
+ {
+ yield break;
+ }
+ return enumerateEmpty();
+ }
+ return EnsureDictionary().GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ /// The item to add.
+ public void Add(KeyValuePair item)
+ {
+ EnsureDictionary().Add(item);
+ }
+
+ public void Clear()
+ {
+ EnsureDictionary().Clear();
+ }
+
+ /// The item to search for.
+ public bool Contains(KeyValuePair item)
+ {
+ if (IsUndefined)
+ {
+ return false;
+ }
+ return EnsureDictionary().Contains(item);
+ }
+
+ /// The array to copy.
+ /// The index.
+ public void CopyTo(KeyValuePair[] array, int index)
+ {
+ if (IsUndefined)
+ {
+ return;
+ }
+ EnsureDictionary().CopyTo(array, index);
+ }
+
+ /// The item to remove.
+ public bool Remove(KeyValuePair item)
+ {
+ if (IsUndefined)
+ {
+ return false;
+ }
+ return EnsureDictionary().Remove(item);
+ }
+
+ /// The key.
+ /// The value to add.
+ public void Add(TKey key, TValue value)
+ {
+ EnsureDictionary().Add(key, value);
+ }
+
+ /// The key to search for.
+ public bool ContainsKey(TKey key)
+ {
+ if (IsUndefined)
+ {
+ return false;
+ }
+ return EnsureDictionary().ContainsKey(key);
+ }
+
+ /// The key.
+ public bool Remove(TKey key)
+ {
+ if (IsUndefined)
+ {
+ return false;
+ }
+ return EnsureDictionary().Remove(key);
+ }
+
+ /// The key to search for.
+ /// The value.
+ public bool TryGetValue(TKey key, out TValue value)
+ {
+ if (IsUndefined)
+ {
+ value = default;
+ return false;
+ }
+ return EnsureDictionary().TryGetValue(key, out value);
+ }
+
+ public IDictionary EnsureDictionary()
+ {
+ return _innerDictionary ??= new Dictionary();
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ChangeTrackingList.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ChangeTrackingList.cs
new file mode 100644
index 000000000000..e0fb3a3b648f
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ChangeTrackingList.cs
@@ -0,0 +1,168 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Azure.ResourceManager.Contoso
+{
+ internal partial class ChangeTrackingList : IList, IReadOnlyList
+ {
+ private IList _innerList;
+
+ public ChangeTrackingList()
+ {
+ }
+
+ /// The inner list.
+ public ChangeTrackingList(IList innerList)
+ {
+ if (innerList != null)
+ {
+ _innerList = innerList;
+ }
+ }
+
+ /// The inner list.
+ public ChangeTrackingList(IReadOnlyList innerList)
+ {
+ if (innerList != null)
+ {
+ _innerList = innerList.ToList();
+ }
+ }
+
+ /// Gets the IsUndefined.
+ public bool IsUndefined => _innerList == null;
+
+ /// Gets the Count.
+ public int Count => IsUndefined ? 0 : EnsureList().Count;
+
+ /// Gets the IsReadOnly.
+ public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly;
+
+ /// Gets or sets the value associated with the specified key.
+ public T this[int index]
+ {
+ get
+ {
+ if (IsUndefined)
+ {
+ throw new ArgumentOutOfRangeException(nameof(index));
+ }
+ return EnsureList()[index];
+ }
+ set
+ {
+ if (IsUndefined)
+ {
+ throw new ArgumentOutOfRangeException(nameof(index));
+ }
+ EnsureList()[index] = value;
+ }
+ }
+
+ public void Reset()
+ {
+ _innerList = null;
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ if (IsUndefined)
+ {
+ IEnumerator enumerateEmpty()
+ {
+ yield break;
+ }
+ return enumerateEmpty();
+ }
+ return EnsureList().GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ /// The item to add.
+ public void Add(T item)
+ {
+ EnsureList().Add(item);
+ }
+
+ public void Clear()
+ {
+ EnsureList().Clear();
+ }
+
+ /// The item.
+ public bool Contains(T item)
+ {
+ if (IsUndefined)
+ {
+ return false;
+ }
+ return EnsureList().Contains(item);
+ }
+
+ /// The array to copy to.
+ /// The array index.
+ public void CopyTo(T[] array, int arrayIndex)
+ {
+ if (IsUndefined)
+ {
+ return;
+ }
+ EnsureList().CopyTo(array, arrayIndex);
+ }
+
+ /// The item.
+ public bool Remove(T item)
+ {
+ if (IsUndefined)
+ {
+ return false;
+ }
+ return EnsureList().Remove(item);
+ }
+
+ /// The item.
+ public int IndexOf(T item)
+ {
+ if (IsUndefined)
+ {
+ return -1;
+ }
+ return EnsureList().IndexOf(item);
+ }
+
+ /// The inner list.
+ /// The item.
+ public void Insert(int index, T item)
+ {
+ EnsureList().Insert(index, item);
+ }
+
+ /// The inner list.
+ public void RemoveAt(int index)
+ {
+ if (IsUndefined)
+ {
+ throw new ArgumentOutOfRangeException(nameof(index));
+ }
+ EnsureList().RemoveAt(index);
+ }
+
+ public IList EnsureList()
+ {
+ return _innerList ??= new List();
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ClientPipelineExtensions.cs
new file mode 100644
index 000000000000..2adf07b2bc39
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ClientPipelineExtensions.cs
@@ -0,0 +1,72 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Threading;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+
+namespace Azure.ResourceManager.Contoso
+{
+ internal static partial class ClientPipelineExtensions
+ {
+ public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context)
+ {
+ (CancellationToken userCancellationToken, ErrorOptions errorOptions) = context.Parse();
+ await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false);
+
+ if (message.Response.IsError && (errorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow)
+ {
+ throw new RequestFailedException(message.Response);
+ }
+
+ return message.Response;
+ }
+
+ public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context)
+ {
+ (CancellationToken userCancellationToken, ErrorOptions errorOptions) = context.Parse();
+ pipeline.Send(message, userCancellationToken);
+
+ if (message.Response.IsError && (errorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow)
+ {
+ throw new RequestFailedException(message.Response);
+ }
+
+ return message.Response;
+ }
+
+ public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context)
+ {
+ Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ switch (response.Status)
+ {
+ case >= 200 and < 300:
+ return Response.FromValue(true, response);
+ case >= 400 and < 500:
+ return Response.FromValue(false, response);
+ default:
+ return new ErrorResult(response, new RequestFailedException(response));
+ }
+ }
+
+ public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context)
+ {
+ Response response = pipeline.ProcessMessage(message, context);
+ switch (response.Status)
+ {
+ case >= 200 and < 300:
+ return Response.FromValue(true, response);
+ case >= 400 and < 500:
+ return Response.FromValue(false, response);
+ default:
+ return new ErrorResult(response, new RequestFailedException(response));
+ }
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenMemberAttribute.cs
new file mode 100644
index 000000000000..72778edeb7e4
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenMemberAttribute.cs
@@ -0,0 +1,20 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+
+namespace Microsoft.TypeSpec.Generator.Customizations
+{
+ [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))]
+ internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute
+ {
+ /// The original name of the member.
+ public CodeGenMemberAttribute(string originalName) : base(originalName)
+ {
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenSerializationAttribute.cs
new file mode 100644
index 000000000000..dfcabf517497
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenSerializationAttribute.cs
@@ -0,0 +1,48 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+
+namespace Microsoft.TypeSpec.Generator.Customizations
+{
+ [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)]
+ internal partial class CodeGenSerializationAttribute : Attribute
+ {
+ /// The property name which these hooks apply to.
+ public CodeGenSerializationAttribute(string propertyName)
+ {
+ PropertyName = propertyName;
+ }
+
+ /// The property name which these hooks apply to.
+ /// The serialization name of the property.
+ public CodeGenSerializationAttribute(string propertyName, string serializationName)
+ {
+ PropertyName = propertyName;
+ SerializationName = serializationName;
+ }
+
+ /// Gets or sets the property name which these hooks should apply to.
+ public string PropertyName { get; }
+
+ /// Gets or sets the serialization name of the property.
+ public string SerializationName { get; set; }
+
+ ///
+ /// Gets or sets the method name to use when serializing the property value (property name excluded).
+ /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer);
+ ///
+ public string SerializationValueHook { get; set; }
+
+ ///
+ /// Gets or sets the method name to use when deserializing the property value from the JSON.
+ /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required
+ /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional
+ ///
+ public string DeserializationValueHook { get; set; }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenSuppressAttribute.cs
new file mode 100644
index 000000000000..38d536e69173
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenSuppressAttribute.cs
@@ -0,0 +1,29 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+
+namespace Microsoft.TypeSpec.Generator.Customizations
+{
+ [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)]
+ internal partial class CodeGenSuppressAttribute : Attribute
+ {
+ /// The member to suppress.
+ /// The types of the parameters of the member.
+ public CodeGenSuppressAttribute(string member, params Type[] parameters)
+ {
+ Member = member;
+ Parameters = parameters;
+ }
+
+ /// Gets the Member.
+ public string Member { get; }
+
+ /// Gets the Parameters.
+ public Type[] Parameters { get; }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenTypeAttribute.cs
new file mode 100644
index 000000000000..f36b5f513173
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/CodeGenTypeAttribute.cs
@@ -0,0 +1,24 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+
+namespace Microsoft.TypeSpec.Generator.Customizations
+{
+ [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))]
+ internal partial class CodeGenTypeAttribute : Attribute
+ {
+ /// The original name of the type.
+ public CodeGenTypeAttribute(string originalName)
+ {
+ OriginalName = originalName;
+ }
+
+ /// Gets the OriginalName.
+ public string OriginalName { get; }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ErrorResult.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ErrorResult.cs
new file mode 100644
index 000000000000..f373edd78036
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ErrorResult.cs
@@ -0,0 +1,32 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using Azure;
+
+namespace Azure.ResourceManager.Contoso
+{
+ internal partial class ErrorResult : Response
+ {
+ private readonly Response _response;
+ private readonly RequestFailedException _exception;
+
+ public ErrorResult(Response response, RequestFailedException exception)
+ {
+ _response = response;
+ _exception = exception;
+ }
+
+ /// Gets the Value.
+ public override T Value => throw _exception;
+
+ ///
+ public override Response GetRawResponse()
+ {
+ return _response;
+ }
+ }
+}
diff --git a/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ModelSerializationExtensions.cs
new file mode 100644
index 000000000000..c92c52df1907
--- /dev/null
+++ b/sdk/contoso/Azure.ResourceManager.Contoso/src/Generated/Internal/ModelSerializationExtensions.cs
@@ -0,0 +1,268 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ClientModel.Primitives;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Globalization;
+using System.Runtime.InteropServices;
+using System.Text.Json;
+
+namespace Azure.ResourceManager.Contoso
+{
+ internal static partial class ModelSerializationExtensions
+ {
+ internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W");
+ internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions
+ {
+ MaxDepth = 256
+ };
+
+ public static object GetObject(this JsonElement element)
+ {
+ switch (element.ValueKind)
+ {
+ case JsonValueKind.String:
+ return element.GetString();
+ case JsonValueKind.Number:
+ if (element.TryGetInt32(out int intValue))
+ {
+ return intValue;
+ }
+ if (element.TryGetInt64(out long longValue))
+ {
+ return longValue;
+ }
+ return element.GetDouble();
+ case JsonValueKind.True:
+ return true;
+ case JsonValueKind.False:
+ return false;
+ case JsonValueKind.Undefined:
+ case JsonValueKind.Null:
+ return null;
+ case JsonValueKind.Object:
+ Dictionary dictionary = new Dictionary();
+ foreach (var jsonProperty in element.EnumerateObject())
+ {
+ dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject());
+ }
+ return dictionary;
+ case JsonValueKind.Array:
+ List