diff --git a/sdk/applink/Azure.ResourceManager.AppLink/Azure.ResourceManager.AppLink.sln b/sdk/applink/Azure.ResourceManager.AppLink/Azure.ResourceManager.AppLink.sln new file mode 100644 index 000000000000..638ff52f7ec3 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/Azure.ResourceManager.AppLink.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.AppLink", "src\Azure.ResourceManager.AppLink.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/applink/Azure.ResourceManager.AppLink/metadata.json b/sdk/applink/Azure.ResourceManager.AppLink/metadata.json new file mode 100644 index 000000000000..38a65558b75c --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/metadata.json @@ -0,0 +1,5 @@ +{ + "apiVersions": { + "Microsoft.AppLink": "2025-08-01-preview" + } +} \ No newline at end of file diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Azure.ResourceManager.AppLink.csproj b/sdk/applink/Azure.ResourceManager.AppLink/src/Azure.ResourceManager.AppLink.csproj new file mode 100644 index 000000000000..c89b3b1b204c --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Azure.ResourceManager.AppLink.csproj @@ -0,0 +1,9 @@ + + + This is the Azure.ResourceManager.AppLink client library for developing .NET applications with rich experience. + SDK Code Generation Azure.ResourceManager.AppLink + 1.0.0-beta.1 + Azure.ResourceManager.AppLink + true + + diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkCollection.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkCollection.cs new file mode 100644 index 000000000000..c469428cc404 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkCollection.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.AppLink +{ + /// + /// 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 GetAppLinks method from an instance of . + /// + public partial class AppLinkCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _appLinksClientDiagnostics; + private readonly AppLinks _appLinksRestClient; + + /// Initializes a new instance of AppLinkCollection for mocking. + protected AppLinkCollection() + { + } + + /// 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 AppLinkCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(AppLinkResource.ResourceType, out string appLinkApiVersion); + _appLinksClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", AppLinkResource.ResourceType.Namespace, Diagnostics); + _appLinksRestClient = new AppLinks(_appLinksClientDiagnostics, Pipeline, Endpoint, appLinkApiVersion ?? "2025-08-01-preview"); + 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 an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// 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 AppLink. + /// 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 appLinkName, AppLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, AppLinkData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkOperationSource(Client), + _appLinksClientDiagnostics, + 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 an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// 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 AppLink. + /// 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 appLinkName, AppLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, AppLinkData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkOperationSource(Client), + _appLinksClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List AppLink resources by resource group. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks. + /// + /// + /// Operation Id. + /// AppLinks_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// 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 AppLinksGetByResourceGroupAsyncCollectionResultOfT(_appLinksRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new AppLinkResource(Client, data)); + } + + /// + /// List AppLink resources by resource group. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks. + /// + /// + /// Operation Id. + /// AppLinks_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// 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 AppLinksGetByResourceGroupCollectionResultOfT(_appLinksRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new AppLinkResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkData)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.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkData)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.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(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.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, appLinkName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(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/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.Serialization.cs new file mode 100644 index 000000000000..0275eb270f09 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.Serialization.cs @@ -0,0 +1,245 @@ +// 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.AppLink.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink +{ + /// AppLink resource. + public partial class AppLinkData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AppLinkData() + { + } + + /// 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 DeserializeAppLinkData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkData)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkData)} 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. + AppLinkData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AppLinkData)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(AppLinkData appLinkData) + { + if (appLinkData == null) + { + return null; + } + return RequestContent.Create(appLinkData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static AppLinkData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAppLinkData(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(AppLinkData)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + ((IJsonModel)Identity).Write(writer, options.Format == "W" ? ModelSerializationExtensions.WireV3Options : ModelSerializationExtensions.JsonV3Options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AppLinkData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AppLinkData)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(AppLinkData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkData DeserializeAppLinkData(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; + AppLinkProperties properties = default; + ManagedServiceIdentity identity = 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, AzureResourceManagerAppLinkContext.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 = AppLinkProperties.DeserializeAppLinkProperties(prop.Value, options); + continue; + } + if (prop.NameEquals("identity"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), options.Format == "W" ? ModelSerializationExtensions.WireV3Options : ModelSerializationExtensions.JsonV3Options, AzureResourceManagerAppLinkContext.Default); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + identity); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.cs new file mode 100644 index 000000000000..f6abfb556d2d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkData.cs @@ -0,0 +1,60 @@ +// 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.AppLink.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink +{ + /// AppLink resource. + public partial class AppLinkData : 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 AppLinkData(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. + /// The managed service identities assigned to this resource. + internal AppLinkData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, AppLinkProperties properties, ManagedServiceIdentity identity) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + Identity = identity; + } + + /// The resource-specific properties for this resource. + internal AppLinkProperties Properties { get; set; } + + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + + /// Provisioning state. + public ProvisioningState? AppLinkProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberCollection.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberCollection.cs new file mode 100644 index 000000000000..35b236d3b4aa --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberCollection.cs @@ -0,0 +1,583 @@ +// 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; + +namespace Azure.ResourceManager.AppLink +{ + /// + /// 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 GetAppLinkMembers method from an instance of . + /// + public partial class AppLinkMemberCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _appLinkMembersClientDiagnostics; + private readonly AppLinkMembers _appLinkMembersRestClient; + private readonly ClientDiagnostics _upgradeHistoriesClientDiagnostics; + private readonly UpgradeHistories _upgradeHistoriesRestClient; + + /// Initializes a new instance of AppLinkMemberCollection for mocking. + protected AppLinkMemberCollection() + { + } + + /// 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 AppLinkMemberCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(AppLinkMemberResource.ResourceType, out string appLinkMemberApiVersion); + _appLinkMembersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", AppLinkMemberResource.ResourceType.Namespace, Diagnostics); + _appLinkMembersRestClient = new AppLinkMembers(_appLinkMembersClientDiagnostics, Pipeline, Endpoint, appLinkMemberApiVersion ?? "2025-08-01-preview"); + _upgradeHistoriesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", AppLinkMemberResource.ResourceType.Namespace, Diagnostics); + _upgradeHistoriesRestClient = new UpgradeHistories(_upgradeHistoriesClientDiagnostics, Pipeline, Endpoint, appLinkMemberApiVersion ?? "2025-08-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != AppLinkResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, AppLinkResource.ResourceType), id); + } + } + + /// + /// Create an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// 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 AppLinkMember. + /// 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 appLinkMemberName, AppLinkMemberData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, AppLinkMemberData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkMemberOperationSource(Client), + _appLinkMembersClientDiagnostics, + 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 an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// 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 AppLinkMember. + /// 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 appLinkMemberName, AppLinkMemberData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, AppLinkMemberData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkMemberOperationSource(Client), + _appLinkMembersClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List AppLinkMember resources by AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers. + /// + /// + /// Operation Id. + /// AppLinkMembers_ListByAppLink. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// 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 AppLinkMembersGetByAppLinkAsyncCollectionResultOfT(_appLinkMembersRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new AppLinkMemberResource(Client, data)); + } + + /// + /// List AppLinkMember resources by AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers. + /// + /// + /// Operation Id. + /// AppLinkMembers_ListByAppLink. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// 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 AppLinkMembersGetByAppLinkCollectionResultOfT(_appLinkMembersRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new AppLinkMemberResource(Client, data)); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkMemberData)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.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkMemberData)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.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkMemberData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(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.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, appLinkMemberName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((AppLinkMemberData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(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/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.Serialization.cs new file mode 100644 index 000000000000..1f3a55cb91eb --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.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.AppLink.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink +{ + /// AppLink Member resource. + public partial class AppLinkMemberData : TrackedResourceData, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AppLinkMemberData() + { + } + + /// 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 DeserializeAppLinkMemberData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkMemberData)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkMemberData)} 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. + AppLinkMemberData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AppLinkMemberData)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(AppLinkMemberData appLinkMemberData) + { + if (appLinkMemberData == null) + { + return null; + } + return RequestContent.Create(appLinkMemberData, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + internal static AppLinkMemberData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAppLinkMemberData(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(AppLinkMemberData)} 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. + AppLinkMemberData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AppLinkMemberData)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(AppLinkMemberData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkMemberData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkMemberData DeserializeAppLinkMemberData(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; + AppLinkMemberProperties 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, AzureResourceManagerAppLinkContext.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 = AppLinkMemberProperties.DeserializeAppLinkMemberProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkMemberData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + tags ?? new ChangeTrackingDictionary(), + location, + properties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.cs new file mode 100644 index 000000000000..f92817cf9033 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberData.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.AppLink.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink +{ + /// AppLink Member resource. + public partial class AppLinkMemberData : 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 AppLinkMemberData(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 AppLinkMemberData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, AppLinkMemberProperties properties) : base(id, name, resourceType, systemData, tags, location) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public AppLinkMemberProperties Properties { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.Serialization.cs new file mode 100644 index 000000000000..f0e3746e263d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.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.AppLink +{ + /// + public partial class AppLinkMemberResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new AppLinkMemberData(); + + /// 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. + AppLinkMemberData 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, AzureResourceManagerAppLinkContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + AppLinkMemberData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerAppLinkContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.cs new file mode 100644 index 000000000000..2d0d3c69365d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkMemberResource.cs @@ -0,0 +1,763 @@ +// 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.AppLink.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.AppLink +{ + /// + /// A class representing a AppLinkMember 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 GetAppLinkMembers method. + /// + public partial class AppLinkMemberResource : ArmResource + { + private readonly ClientDiagnostics _appLinkMembersClientDiagnostics; + private readonly AppLinkMembers _appLinkMembersRestClient; + private readonly ClientDiagnostics _upgradeHistoriesClientDiagnostics; + private readonly UpgradeHistories _upgradeHistoriesRestClient; + private readonly AppLinkMemberData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AppLink/appLinks/appLinkMembers"; + + /// Initializes a new instance of AppLinkMemberResource for mocking. + protected AppLinkMemberResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal AppLinkMemberResource(ArmClient client, AppLinkMemberData 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 AppLinkMemberResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string appLinkMemberApiVersion); + _appLinkMembersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", ResourceType.Namespace, Diagnostics); + _appLinkMembersRestClient = new AppLinkMembers(_appLinkMembersClientDiagnostics, Pipeline, Endpoint, appLinkMemberApiVersion ?? "2025-08-01-preview"); + _upgradeHistoriesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", ResourceType.Namespace, Diagnostics); + _upgradeHistoriesRestClient = new UpgradeHistories(_upgradeHistoriesClientDiagnostics, Pipeline, Endpoint, appLinkMemberApiVersion ?? "2025-08-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual AppLinkMemberData 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 appLinkName. + /// The appLinkMemberName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}"; + 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 an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Update. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// 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 resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, AppLinkMemberPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, AppLinkMemberPatch.ToRequestContent(patch), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkMemberOperationSource(Client), + _appLinkMembersClientDiagnostics, + 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; + } + } + + /// + /// Update an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Update. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// 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 resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, AppLinkMemberPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, AppLinkMemberPatch.ToRequestContent(patch), context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkMemberOperationSource(Client), + _appLinkMembersClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Delete. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation(_appLinkMembersClientDiagnostics, 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 an AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}. + /// + /// + /// Operation Id. + /// AppLinkMembers_Delete. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinkMembersRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation(_appLinkMembersClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List UpgradeHistory resources by AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}/upgradeHistories. + /// + /// + /// Operation Id. + /// UpgradeHistories_ListByAppLinkMember. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetByAppLinkMemberAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT( + _upgradeHistoriesRestClient, + Guid.Parse(Id.SubscriptionId), + Id.ResourceGroupName, + Id.Parent.Name, + Id.Name, + context); + } + + /// + /// List UpgradeHistory resources by AppLinkMember. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}/appLinkMembers/{appLinkMemberName}/upgradeHistories. + /// + /// + /// Operation Id. + /// UpgradeHistories_ListByAppLinkMember. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetByAppLinkMember(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT( + _upgradeHistoriesRestClient, + Guid.Parse(Id.SubscriptionId), + Id.ResourceGroupName, + Id.Parent.Name, + Id.Name, + context); + } + + /// 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkMemberPatch patch = new AppLinkMemberPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + ArmOperation result = await UpdateAsync(WaitUntil.Completed, 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkMemberPatch patch = new AppLinkMemberPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + ArmOperation result = Update(WaitUntil.Completed, 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkMemberPatch patch = new AppLinkMemberPatch(); + patch.Tags.ReplaceWith(tags); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkMemberPatch patch = new AppLinkMemberPatch(); + patch.Tags.ReplaceWith(tags); + ArmOperation result = Update(WaitUntil.Completed, 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkMemberPatch patch = new AppLinkMemberPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, 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 = _appLinkMembersClientDiagnostics.CreateScope("AppLinkMemberResource.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 = _appLinkMembersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkMemberData.FromResponse(result), result); + return Response.FromValue(new AppLinkMemberResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkMemberData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkMemberPatch patch = new AppLinkMemberPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.Serialization.cs new file mode 100644 index 000000000000..fc2d1b5f3242 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.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.AppLink +{ + /// + public partial class AppLinkResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new AppLinkData(); + + /// 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. + AppLinkData 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, AzureResourceManagerAppLinkContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + AppLinkData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerAppLinkContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.cs new file mode 100644 index 000000000000..f89e28a4e0e0 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/AppLinkResource.cs @@ -0,0 +1,715 @@ +// 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.AppLink.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.AppLink +{ + /// + /// A class representing a AppLink 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 GetAppLinks method. + /// + public partial class AppLinkResource : ArmResource + { + private readonly ClientDiagnostics _appLinksClientDiagnostics; + private readonly AppLinks _appLinksRestClient; + private readonly AppLinkData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AppLink/appLinks"; + + /// Initializes a new instance of AppLinkResource for mocking. + protected AppLinkResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal AppLinkResource(ArmClient client, AppLinkData 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 AppLinkResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string appLinkApiVersion); + _appLinksClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.AppLink", ResourceType.Namespace, Diagnostics); + _appLinksRestClient = new AppLinks(_appLinksClientDiagnostics, Pipeline, Endpoint, appLinkApiVersion ?? "2025-08-01-preview"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual AppLinkData 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 appLinkName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string appLinkName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}"; + 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 an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Update. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// 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 resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, AppLinkPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, AppLinkPatch.ToRequestContent(patch), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkOperationSource(Client), + _appLinksClientDiagnostics, + 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; + } + } + + /// + /// Update an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Update. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// 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 resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, AppLinkPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, AppLinkPatch.ToRequestContent(patch), context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation( + new AppLinkOperationSource(Client), + _appLinksClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Delete. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + AppLinkArmOperation operation = new AppLinkArmOperation(_appLinksClientDiagnostics, 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 an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Delete. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _appLinksRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + AppLinkArmOperation operation = new AppLinkArmOperation(_appLinksClientDiagnostics, 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkPatch patch = new AppLinkPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + ArmOperation result = await UpdateAsync(WaitUntil.Completed, 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkPatch patch = new AppLinkPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + ArmOperation result = Update(WaitUntil.Completed, 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkPatch patch = new AppLinkPatch(); + patch.Tags.ReplaceWith(tags); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkPatch patch = new AppLinkPatch(); + patch.Tags.ReplaceWith(tags); + ArmOperation result = Update(WaitUntil.Completed, 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + AppLinkPatch patch = new AppLinkPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, 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 = _appLinksClientDiagnostics.CreateScope("AppLinkResource.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 = _appLinksRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(AppLinkData.FromResponse(result), result); + return Response.FromValue(new AppLinkResource(Client, response.Value), response.GetRawResponse()); + } + else + { + AppLinkData current = Get(cancellationToken: cancellationToken).Value.Data; + AppLinkPatch patch = new AppLinkPatch(); + foreach (KeyValuePair tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a collection of AppLinkMembers in the . + /// An object representing collection of AppLinkMembers and their operations over a AppLinkMemberResource. + public virtual AppLinkMemberCollection GetAppLinkMembers() + { + return GetCachedClient(client => new AppLinkMemberCollection(client, Id)); + } + + /// Get an AppLinkMember. + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAppLinkMemberAsync(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + return await GetAppLinkMembers().GetAsync(appLinkMemberName, cancellationToken).ConfigureAwait(false); + } + + /// Get an AppLinkMember. + /// The name of the AppLinkMember. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAppLinkMember(string appLinkMemberName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkMemberName, nameof(appLinkMemberName)); + + return GetAppLinkMembers().Get(appLinkMemberName, cancellationToken); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/ArmAppLinkModelFactory.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/ArmAppLinkModelFactory.cs new file mode 100644 index 000000000000..503b56eb4c0c --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/ArmAppLinkModelFactory.cs @@ -0,0 +1,197 @@ +// 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.AppLink; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// A factory class for creating instances of the models for mocking. + public static partial class ArmAppLinkModelFactory + { + + /// 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. + /// Provisioning state. + /// The managed service identities assigned to this resource. + /// A new instance for mocking. + public static AppLinkData AppLinkData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, ProvisioningState? appLinkProvisioningState = default, ManagedServiceIdentity identity = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new AppLinkData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + appLinkProvisioningState is null ? default : new AppLinkProperties(appLinkProvisioningState, null), + identity); + } + + /// The type used for update operations of the AppLink. + /// Resource tags. + /// A new instance for mocking. + public static AppLinkPatch AppLinkPatch(IDictionary tags = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new AppLinkPatch(tags, additionalBinaryDataProperties: null); + } + + /// AppLink Member 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 AppLinkMemberData AppLinkMemberData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, AppLinkMemberProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new AppLinkMemberData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + properties); + } + + /// Cluster type. + /// Resource ID. + /// Upgrade profile. + /// Metrics endpoint URL. + /// Connectivity profile. + /// Provisioning state. + /// A new instance for mocking. + public static AppLinkMemberProperties AppLinkMemberProperties(ClusterType? clusterType = default, ResourceIdentifier metadataResourceId = default, UpgradeProfile upgradeProfile = default, string observabilityMetricsEndpoint = default, ConnectivityProfile connectivityProfile = default, ProvisioningState? provisioningState = default) + { + return new AppLinkMemberProperties( + clusterType, + metadataResourceId is null ? default : new Metadata(metadataResourceId, null), + upgradeProfile, + observabilityMetricsEndpoint is null ? default : new ObservabilityProfile(new MetricsProfile(observabilityMetricsEndpoint, null), null), + connectivityProfile, + provisioningState, + additionalBinaryDataProperties: null); + } + + /// The type used for update operations of the AppLinkMember. + /// Resource tags. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static AppLinkMemberPatch AppLinkMemberPatch(IDictionary tags = default, AppLinkMemberUpdateProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new AppLinkMemberPatch(tags, properties, additionalBinaryDataProperties: null); + } + + /// AppLinkMember upgrade history. + /// 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. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static UpgradeHistory UpgradeHistory(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, UpgradeHistoryProperties properties = default) + { + return new UpgradeHistory( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// AppLinkMember upgrade history properties. + /// Start timestamp. + /// End timestamp. + /// Upgrade initiator. + /// Version upgraded from. + /// Version upgraded to. + /// Provisioning state. + /// A new instance for mocking. + public static UpgradeHistoryProperties UpgradeHistoryProperties(DateTimeOffset startTimestamp = default, DateTimeOffset? endTimestamp = default, string initiatedBy = default, string fromVersion = default, string toVersion = default, ProvisioningState? provisioningState = default) + { + return new UpgradeHistoryProperties( + startTimestamp, + endTimestamp, + initiatedBy, + fromVersion, + toVersion, + provisioningState, + additionalBinaryDataProperties: null); + } + + /// AppLink available version 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. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static AvailableVersion AvailableVersion(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, AvailableVersionProperties properties = default) + { + return new AvailableVersion( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + properties); + } + + /// Kubernetes version. + /// Release channels. + /// Istio versions. + /// Provisioning state. + /// A new instance for mocking. + public static AvailableVersionProperties AvailableVersionProperties(string kubernetesVersion = default, IEnumerable fullyManagedVersionsReleaseChannels = default, IEnumerable selfManagedVersions = default, ProvisioningState? provisioningState = default) + { + return new AvailableVersionProperties(kubernetesVersion, fullyManagedVersionsReleaseChannels is null ? default : new FullyManagedVersions((fullyManagedVersionsReleaseChannels ?? new ChangeTrackingList()).ToList(), null), selfManagedVersions is null ? default : new SelfManagedVersions((selfManagedVersions ?? new ChangeTrackingList()).ToList(), null), provisioningState, additionalBinaryDataProperties: null); + } + + /// Release channel information. + /// Release channel. + /// Istio version behind release channel. + /// A new instance for mocking. + public static ReleaseChannelInfo ReleaseChannelInfo(string releaseChannel = default, string version = default) + { + return new ReleaseChannelInfo(releaseChannel, version, additionalBinaryDataProperties: null); + } + + /// Version information. + /// Istio version. + /// Available upgrades. + /// A new instance for mocking. + public static VersionInfo VersionInfo(string version = default, IEnumerable upgrades = default) + { + upgrades ??= new ChangeTrackingList(); + + return new VersionInfo(version, upgrades.ToList(), additionalBinaryDataProperties: null); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkAsyncCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..28deaa0782a4 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// 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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinkMembersGetByAppLinkAsyncCollectionResultOfT : AsyncPageable + { + private readonly AppLinkMembers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _appLinkName; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinkMembersGetByAppLinkAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinkMembers 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 name of the AppLink. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AppLinkMembersGetByAppLinkAsyncCollectionResultOfT(AppLinkMembers client, Guid subscriptionId, string resourceGroupName, string appLinkName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _appLinkName = appLinkName; + _context = context; + } + + /// Gets the pages of AppLinkMembersGetByAppLinkAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinkMembersGetByAppLinkAsyncCollectionResultOfT 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; + } + AppLinkMemberListResult result = AppLinkMemberListResult.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.CreateNextGetByAppLinkRequest(nextLink, _subscriptionId, _resourceGroupName, _appLinkName, _context) : _client.CreateGetByAppLinkRequest(_subscriptionId, _resourceGroupName, _appLinkName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AppLinkMemberCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkCollectionResultOfT.cs new file mode 100644 index 000000000000..81d3cb99b1ce --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinkMembersGetByAppLinkCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinkMembersGetByAppLinkCollectionResultOfT : Pageable + { + private readonly AppLinkMembers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _appLinkName; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinkMembersGetByAppLinkCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinkMembers 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 name of the AppLink. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AppLinkMembersGetByAppLinkCollectionResultOfT(AppLinkMembers client, Guid subscriptionId, string resourceGroupName, string appLinkName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _appLinkName = appLinkName; + _context = context; + } + + /// Gets the pages of AppLinkMembersGetByAppLinkCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinkMembersGetByAppLinkCollectionResultOfT 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; + } + AppLinkMemberListResult result = AppLinkMemberListResult.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.CreateNextGetByAppLinkRequest(nextLink, _subscriptionId, _resourceGroupName, _appLinkName, _context) : _client.CreateGetByAppLinkRequest(_subscriptionId, _resourceGroupName, _appLinkName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AppLinkMemberCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..4dc7bc3018d3 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupAsyncCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinksGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly AppLinks _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinksGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinks 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 AppLinksGetByResourceGroupAsyncCollectionResultOfT(AppLinks client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of AppLinksGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinksGetByResourceGroupAsyncCollectionResultOfT 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; + } + AppLinkListResult result = AppLinkListResult.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("AppLinkCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..4aeb1ec9be89 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetByResourceGroupCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinksGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly AppLinks _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinksGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinks 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 AppLinksGetByResourceGroupCollectionResultOfT(AppLinks client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of AppLinksGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinksGetByResourceGroupCollectionResultOfT 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; + } + AppLinkListResult result = AppLinkListResult.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("AppLinkCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..728fc2bb4fe0 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionAsyncCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinksGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly AppLinks _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinksGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinks 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 AppLinksGetBySubscriptionAsyncCollectionResultOfT(AppLinks client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of AppLinksGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinksGetBySubscriptionAsyncCollectionResultOfT 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; + } + AppLinkListResult result = AppLinkListResult.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("MockableAppLinkSubscriptionResource.GetAppLinks"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..2b390ea467f3 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AppLinksGetBySubscriptionCollectionResultOfT.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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinksGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly AppLinks _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of AppLinksGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AppLinks 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 AppLinksGetBySubscriptionCollectionResultOfT(AppLinks client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of AppLinksGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AppLinksGetBySubscriptionCollectionResultOfT 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; + } + AppLinkListResult result = AppLinkListResult.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("MockableAppLinkSubscriptionResource.GetAppLinks"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationAsyncCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..a618f5090acc --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// 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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AvailableVersionsGetByLocationAsyncCollectionResultOfT : AsyncPageable + { + private readonly AvailableVersions _client; + private readonly Guid _subscriptionId; + private readonly AzureLocation _location; + private readonly string _kubernetesVersion; + private readonly RequestContext _context; + + /// Initializes a new instance of AvailableVersionsGetByLocationAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AvailableVersions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AvailableVersionsGetByLocationAsyncCollectionResultOfT(AvailableVersions client, Guid subscriptionId, AzureLocation location, string kubernetesVersion, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _location = location; + _kubernetesVersion = kubernetesVersion; + _context = context; + } + + /// Gets the pages of AvailableVersionsGetByLocationAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AvailableVersionsGetByLocationAsyncCollectionResultOfT 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; + } + AvailableVersionListResult result = AvailableVersionListResult.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.CreateNextGetByLocationRequest(nextLink, _subscriptionId, _location, _kubernetesVersion, _context) : _client.CreateGetByLocationRequest(_subscriptionId, _location, _kubernetesVersion, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableAppLinkSubscriptionResource.GetByLocation"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationCollectionResultOfT.cs new file mode 100644 index 000000000000..c61434d9916a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/AvailableVersionsGetByLocationCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AvailableVersionsGetByLocationCollectionResultOfT : Pageable + { + private readonly AvailableVersions _client; + private readonly Guid _subscriptionId; + private readonly AzureLocation _location; + private readonly string _kubernetesVersion; + private readonly RequestContext _context; + + /// Initializes a new instance of AvailableVersionsGetByLocationCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AvailableVersions client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AvailableVersionsGetByLocationCollectionResultOfT(AvailableVersions client, Guid subscriptionId, AzureLocation location, string kubernetesVersion, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _location = location; + _kubernetesVersion = kubernetesVersion; + _context = context; + } + + /// Gets the pages of AvailableVersionsGetByLocationCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AvailableVersionsGetByLocationCollectionResultOfT 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; + } + AvailableVersionListResult result = AvailableVersionListResult.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.CreateNextGetByLocationRequest(nextLink, _subscriptionId, _location, _kubernetesVersion, _context) : _client.CreateGetByLocationRequest(_subscriptionId, _location, _kubernetesVersion, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableAppLinkSubscriptionResource.GetByLocation"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..f9490c59c316 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT.cs @@ -0,0 +1,87 @@ +// 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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT : AsyncPageable + { + private readonly UpgradeHistories _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _appLinkName; + private readonly string _appLinkMemberName; + private readonly RequestContext _context; + + /// Initializes a new instance of UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The UpgradeHistories 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 name of the AppLink. + /// The name of the AppLinkMember. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT(UpgradeHistories client, Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _appLinkName = appLinkName; + _appLinkMemberName = appLinkMemberName; + _context = context; + } + + /// Gets the pages of UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of UpgradeHistoriesGetByAppLinkMemberAsyncCollectionResultOfT 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; + } + UpgradeHistoryListResult result = UpgradeHistoryListResult.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.CreateNextGetByAppLinkMemberRequest(nextLink, _subscriptionId, _resourceGroupName, _appLinkName, _appLinkMemberName, _context) : _client.CreateGetByAppLinkMemberRequest(_subscriptionId, _resourceGroupName, _appLinkName, _appLinkMemberName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AppLinkMemberResource.GetByAppLinkMember"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT.cs new file mode 100644 index 000000000000..2a3cfa6abdf1 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/CollectionResults/UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT.cs @@ -0,0 +1,86 @@ +// 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.AppLink.Models; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT : Pageable + { + private readonly UpgradeHistories _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _appLinkName; + private readonly string _appLinkMemberName; + private readonly RequestContext _context; + + /// Initializes a new instance of UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The UpgradeHistories 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 name of the AppLink. + /// The name of the AppLinkMember. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT(UpgradeHistories client, Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _appLinkName = appLinkName; + _appLinkMemberName = appLinkMemberName; + _context = context; + } + + /// Gets the pages of UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of UpgradeHistoriesGetByAppLinkMemberCollectionResultOfT 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; + } + UpgradeHistoryListResult result = UpgradeHistoryListResult.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.CreateNextGetByAppLinkMemberRequest(nextLink, _subscriptionId, _resourceGroupName, _appLinkName, _appLinkMemberName, _context) : _client.CreateGetByAppLinkMemberRequest(_subscriptionId, _resourceGroupName, _appLinkName, _appLinkMemberName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AppLinkMemberResource.GetByAppLinkMember"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/AppLinkExtensions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/AppLinkExtensions.cs new file mode 100644 index 000000000000..90d1af79c74e --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/AppLinkExtensions.cs @@ -0,0 +1,208 @@ +// 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.AppLink.Mocking; +using Azure.ResourceManager.AppLink.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.AppLink +{ + /// A class to add extension methods to Azure.ResourceManager.AppLink. + public static partial class AppLinkExtensions + { + /// + private static MockableAppLinkArmClient GetMockableAppLinkArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableAppLinkArmClient(client0, ResourceIdentifier.Root)); + } + + /// + private static MockableAppLinkResourceGroupResource GetMockableAppLinkResourceGroupResource(ResourceGroupResource resourceGroupResource) + { + return resourceGroupResource.GetCachedClient(client => new MockableAppLinkResourceGroupResource(client, resourceGroupResource.Id)); + } + + /// + private static MockableAppLinkSubscriptionResource GetMockableAppLinkSubscriptionResource(SubscriptionResource subscriptionResource) + { + return subscriptionResource.GetCachedClient(client => new MockableAppLinkSubscriptionResource(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 AppLinkResource GetAppLinkResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableAppLinkArmClient(client).GetAppLinkResource(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 AppLinkMemberResource GetAppLinkMemberResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableAppLinkArmClient(client).GetAppLinkMemberResource(id); + } + + /// + /// Gets a collection of AppLinks in the + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// is null. + /// An object representing collection of AppLinks and their operations over a AppLinkResource. + public static AppLinkCollection GetAppLinks(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableAppLinkResourceGroupResource(resourceGroupResource).GetAppLinks(); + } + + /// + /// Get an AppLink. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetAppLinkAsync(this ResourceGroupResource resourceGroupResource, string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableAppLinkResourceGroupResource(resourceGroupResource).GetAppLinkAsync(appLinkName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get an AppLink. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetAppLink(this ResourceGroupResource resourceGroupResource, string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableAppLinkResourceGroupResource(resourceGroupResource).GetAppLink(appLinkName, cancellationToken); + } + + /// + /// List AppLink resources by subscription. + /// + /// 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 GetAppLinksAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableAppLinkSubscriptionResource(subscriptionResource).GetAppLinksAsync(cancellationToken); + } + + /// + /// List AppLink resources by subscription. + /// + /// 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 GetAppLinks(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableAppLinkSubscriptionResource(subscriptionResource).GetAppLinks(cancellationToken); + } + + /// + /// List AvailableVersion resources by location. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetByLocationAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string kubernetesVersion = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableAppLinkSubscriptionResource(subscriptionResource).GetByLocationAsync(location, kubernetesVersion, cancellationToken); + } + + /// + /// List AvailableVersion resources by location. + /// + /// Mocking. + /// To mock this method, please mock instead. + /// + /// + /// The the method will execute against. + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetByLocation(this SubscriptionResource subscriptionResource, AzureLocation location, string kubernetesVersion = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableAppLinkSubscriptionResource(subscriptionResource).GetByLocation(location, kubernetesVersion, cancellationToken); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkArmClient.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkArmClient.cs new file mode 100644 index 000000000000..47d5e9637bb9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkArmClient.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Mocking +{ + /// A class to add extension methods to . + public partial class MockableAppLinkArmClient : ArmResource + { + /// Initializes a new instance of MockableAppLinkArmClient for mocking. + protected MockableAppLinkArmClient() + { + } + + /// 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 MockableAppLinkArmClient(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 AppLinkResource GetAppLinkResource(ResourceIdentifier id) + { + AppLinkResource.ValidateResourceId(id); + return new AppLinkResource(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 AppLinkMemberResource GetAppLinkMemberResource(ResourceIdentifier id) + { + AppLinkMemberResource.ValidateResourceId(id); + return new AppLinkMemberResource(Client, id); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkResourceGroupResource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkResourceGroupResource.cs new file mode 100644 index 000000000000..713babfb64f1 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkResourceGroupResource.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.AppLink; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.AppLink.Mocking +{ + /// A class to add extension methods to . + public partial class MockableAppLinkResourceGroupResource : ArmResource + { + /// Initializes a new instance of MockableAppLinkResourceGroupResource for mocking. + protected MockableAppLinkResourceGroupResource() + { + } + + /// 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 MockableAppLinkResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + /// Gets a collection of AppLinks in the . + /// An object representing collection of AppLinks and their operations over a AppLinkResource. + public virtual AppLinkCollection GetAppLinks() + { + return GetCachedClient(client => new AppLinkCollection(client, Id)); + } + + /// + /// Get an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAppLinkAsync(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + return await GetAppLinks().GetAsync(appLinkName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get an AppLink. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppLink/appLinks/{appLinkName}. + /// + /// + /// Operation Id. + /// AppLinks_Get. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the AppLink. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAppLink(string appLinkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(appLinkName, nameof(appLinkName)); + + return GetAppLinks().Get(appLinkName, cancellationToken); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkSubscriptionResource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkSubscriptionResource.cs new file mode 100644 index 000000000000..fd79526de546 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Extensions/MockableAppLinkSubscriptionResource.cs @@ -0,0 +1,164 @@ +// 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.AppLink; +using Azure.ResourceManager.AppLink.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.AppLink.Mocking +{ + /// A class to add extension methods to . + public partial class MockableAppLinkSubscriptionResource : ArmResource + { + private ClientDiagnostics _appLinksClientDiagnostics; + private AppLinks _appLinksRestClient; + private ClientDiagnostics _availableVersionsClientDiagnostics; + private AvailableVersions _availableVersionsRestClient; + + /// Initializes a new instance of MockableAppLinkSubscriptionResource for mocking. + protected MockableAppLinkSubscriptionResource() + { + } + + /// 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 MockableAppLinkSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics AppLinksClientDiagnostics => _appLinksClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.AppLink.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private AppLinks AppLinksRestClient => _appLinksRestClient ??= new AppLinks(AppLinksClientDiagnostics, Pipeline, Endpoint, "2025-08-01-preview"); + + private ClientDiagnostics AvailableVersionsClientDiagnostics => _availableVersionsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.AppLink.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private AvailableVersions AvailableVersionsRestClient => _availableVersionsRestClient ??= new AvailableVersions(AvailableVersionsClientDiagnostics, Pipeline, Endpoint, "2025-08-01-preview"); + + /// + /// List AppLink resources by subscription. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.AppLink/appLinks. + /// + /// + /// Operation Id. + /// AppLinks_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAppLinksAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new AppLinksGetBySubscriptionAsyncCollectionResultOfT(AppLinksRestClient, Guid.Parse(Id.SubscriptionId), context), data => new AppLinkResource(Client, data)); + } + + /// + /// List AppLink resources by subscription. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.AppLink/appLinks. + /// + /// + /// Operation Id. + /// AppLinks_ListBySubscription. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAppLinks(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new AppLinksGetBySubscriptionCollectionResultOfT(AppLinksRestClient, Guid.Parse(Id.SubscriptionId), context), data => new AppLinkResource(Client, data)); + } + + /// + /// List AvailableVersion resources by location. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.AppLink/locations/{location}/availableVersions. + /// + /// + /// Operation Id. + /// AvailableVersions_ListByLocation. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetByLocationAsync(AzureLocation location, string kubernetesVersion = default, CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AvailableVersionsGetByLocationAsyncCollectionResultOfT(AvailableVersionsRestClient, Guid.Parse(Id.SubscriptionId), location, kubernetesVersion, context); + } + + /// + /// List AvailableVersion resources by location. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.AppLink/locations/{location}/availableVersions. + /// + /// + /// Operation Id. + /// AvailableVersions_ListByLocation. + /// + /// + /// Default Api Version. + /// 2025-08-01-preview. + /// + /// + /// + /// The name of the Azure region. + /// Kubernetes version to filter profiles. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetByLocation(AzureLocation location, string kubernetesVersion = default, CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AvailableVersionsGetByLocationCollectionResultOfT(AvailableVersionsRestClient, Guid.Parse(Id.SubscriptionId), location, kubernetesVersion, context); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/Argument.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..110bc6be59dc --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..5b473d8b11fb --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..2e695b0b6648 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ChangeTrackingList.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..b296171c9430 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..58c333251433 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..72778edeb7e4 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..dfcabf517497 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..38d536e69173 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..f36b5f513173 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ErrorResult.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..39cda0022153 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/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.AppLink +{ + 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/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..15e4da7bade9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,272 @@ +// 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.AppLink +{ + internal static partial class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; + /// The wire v3 options for model serialization. + internal static readonly ModelReaderWriterOptions WireV3Options = new ModelReaderWriterOptions("W|v3"); + /// The JSON v3 options for model serialization. + internal static readonly ModelReaderWriterOptions JsonV3Options = new ModelReaderWriterOptions("J|v3"); + + 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 list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + string text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) + { + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + string value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + public static BinaryData GetUtf8Bytes(this JsonElement element) + { +#if NET9_0_OR_GREATER + return new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(element).ToArray()); +#else + return BinaryData.FromString(element.GetRawText()); +#endif + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/Optional.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..4641b9059bf9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.AppLink +{ + internal static partial class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(string value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/PageableWrapper.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..6214edd384d9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/PageableWrapper.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class PageableWrapper : Pageable + { + /// The source pageable value of type Pageable<T>. + private Pageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the PageableWrapper class. + /// The source pageable value of type Pageable<T>. + /// The converter function from T to U. + public PageableWrapper(Pageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from Pageable 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 IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + foreach (Page page in _source.AsPages(continuationToken, pageSizeHint)) + { + 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/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..0e7c9a73c7f4 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.AppLink +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + + public static void UpdateQuery(this RawRequestUriBuilder builder, string name, string value) + { + string currentQuery = builder.Query; + string searchPattern = string.Concat(name, "="); + int paramStartIndex = -1; + if (currentQuery.StartsWith(string.Concat("?", searchPattern))) + { + paramStartIndex = 1; + } + if (paramStartIndex == -1) + { + string prefixedPattern = string.Concat("&", searchPattern); + int prefixedIndex = currentQuery.IndexOf(prefixedPattern); + if (prefixedIndex >= 0) + { + paramStartIndex = prefixedIndex + 1; + } + } + if (paramStartIndex >= 0) + { + int valueStartIndex = paramStartIndex + searchPattern.Length; + int valueEndIndex = currentQuery.IndexOf('&', valueStartIndex); + if (valueEndIndex == -1) + { + valueEndIndex = currentQuery.Length; + } + string beforeParam = currentQuery.Substring(0, valueStartIndex); + string afterParam = currentQuery.Substring(valueEndIndex); + string newQuery = string.Concat(beforeParam, value, afterParam); + builder.Query = newQuery; + } + else + { + builder.AppendQuery(name, value, true); + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/RequestContextExtensions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..6f16c3bf1e62 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/RequestContextExtensions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; + +namespace Azure.ResourceManager.AppLink +{ + internal static partial class RequestContextExtensions + { + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + public static ValueTuple Parse(this RequestContext context) + { + if (context == null) + { + return (CancellationToken.None, ErrorOptions.Default); + } + return (context.CancellationToken, context.ErrorOptions); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/SerializationFormat.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..5b1e46d3d47d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.AppLink +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/TypeFormatters.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..1b9cb8109ced --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Azure.ResourceManager.AppLink +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperation.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperation.cs new file mode 100644 index 000000000000..3770e445bdd7 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperation.cs @@ -0,0 +1,106 @@ +// 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.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinkArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of AppLinkArmOperation for mocking. + protected AppLinkArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal AppLinkArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + /// + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. + internal AppLinkArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) + { + _nextLinkOperation = nextLinkOperationImplementation; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "AppLinkArmOperation", + null, + new SequentialDelayStrategy()); + } + + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); + + /// + public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperationOfT.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperationOfT.cs new file mode 100644 index 000000000000..a550a1c8046e --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkArmOperationOfT.cs @@ -0,0 +1,113 @@ +// 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.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinkArmOperation : ArmOperation + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of AppLinkArmOperation for mocking. + protected AppLinkArmOperation() + { + } + + /// + /// The operation response. + /// The token to rehydrate the operation. + internal AppLinkArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + /// + /// The instance of . + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. + internal AppLinkArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) + { + _nextLinkOperation = nextLinkOperationImplementation; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "AppLinkArmOperation", + null, + new SequentialDelayStrategy()); + } + + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the Value. + public override T Value => _operation.Value; + + /// Gets the HasValue. + public override bool HasValue => _operation.HasValue; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); + + /// + public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkMemberOperationSource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkMemberOperationSource.cs new file mode 100644 index 000000000000..0ba90387735f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkMemberOperationSource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.AppLink +{ + /// + internal partial class AppLinkMemberOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal AppLinkMemberOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + AppLinkMemberResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + AppLinkMemberData data = AppLinkMemberData.DeserializeAppLinkMemberData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new AppLinkMemberResource(_client, data); + } + + /// The response from the service. + /// The cancellation token to use. + /// + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + AppLinkMemberData data = AppLinkMemberData.DeserializeAppLinkMemberData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new AppLinkMemberResource(_client, data); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkOperationSource.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkOperationSource.cs new file mode 100644 index 000000000000..7f0523dc9569 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/LongRunningOperation/AppLinkOperationSource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.AppLink +{ + /// + internal partial class AppLinkOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal AppLinkOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + AppLinkResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + AppLinkData data = AppLinkData.DeserializeAppLinkData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new AppLinkResource(_client, data); + } + + /// The response from the service. + /// The cancellation token to use. + /// + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + AppLinkData data = AppLinkData.DeserializeAppLinkData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new AppLinkResource(_client, data); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.Serialization.cs new file mode 100644 index 000000000000..0d21a2a93663 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AppLink list operation. + internal partial class AppLinkListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AppLinkListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AppLinkListResult 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 DeserializeAppLinkListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkListResult)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkListResult)} 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. + AppLinkListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AppLinkListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAppLinkListResult(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 virtual 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(AppLinkListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (AppLinkData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AppLinkListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AppLinkListResult 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(AppLinkListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkListResult DeserializeAppLinkListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(AppLinkData.DeserializeAppLinkData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.cs new file mode 100644 index 000000000000..68a84fa2d4dd --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkListResult.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AppLink list operation. + internal partial class AppLinkListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The AppLink items on this page. + internal AppLinkListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The AppLink items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal AppLinkListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The AppLink items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.Serialization.cs new file mode 100644 index 000000000000..2dcbdd836032 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AppLinkMember list operation. + internal partial class AppLinkMemberListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AppLinkMemberListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AppLinkMemberListResult 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 DeserializeAppLinkMemberListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkMemberListResult)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkMemberListResult)} 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. + AppLinkMemberListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AppLinkMemberListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAppLinkMemberListResult(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 virtual 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(AppLinkMemberListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (AppLinkMemberData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AppLinkMemberListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AppLinkMemberListResult 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(AppLinkMemberListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkMemberListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkMemberListResult DeserializeAppLinkMemberListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(AppLinkMemberData.DeserializeAppLinkMemberData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkMemberListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.cs new file mode 100644 index 000000000000..d56795a80979 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberListResult.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AppLinkMember list operation. + internal partial class AppLinkMemberListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The AppLinkMember items on this page. + internal AppLinkMemberListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The AppLinkMember items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal AppLinkMemberListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The AppLinkMember items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberPatch.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberPatch.Serialization.cs new file mode 100644 index 000000000000..d4b1c185213b --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberPatch.Serialization.cs @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The type used for update operations of the AppLinkMember. + public partial class AppLinkMemberPatch : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AppLinkMemberPatch 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 DeserializeAppLinkMemberPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkMemberPatch)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkMemberPatch)} 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. + AppLinkMemberPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => 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(AppLinkMemberPatch appLinkMemberPatch) + { + if (appLinkMemberPatch == null) + { + return null; + } + return RequestContent.Create(appLinkMemberPatch, 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 virtual 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(AppLinkMemberPatch)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AppLinkMemberPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AppLinkMemberPatch 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(AppLinkMemberPatch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkMemberPatch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkMemberPatch DeserializeAppLinkMemberPatch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + AppLinkMemberUpdateProperties properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + 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("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = AppLinkMemberUpdateProperties.DeserializeAppLinkMemberUpdateProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkMemberPatch(tags ?? new ChangeTrackingDictionary(), properties, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberPatch.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberPatch.cs new file mode 100644 index 000000000000..96164ce78bf6 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberPatch.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The type used for update operations of the AppLinkMember. + public partial class AppLinkMemberPatch + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AppLinkMemberPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Resource tags. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal AppLinkMemberPatch(IDictionary tags, AppLinkMemberUpdateProperties properties, IDictionary additionalBinaryDataProperties) + { + Tags = tags; + Properties = properties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Resource tags. + public IDictionary Tags { get; } + + /// The resource-specific properties for this resource. + public AppLinkMemberUpdateProperties Properties { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.Serialization.cs new file mode 100644 index 000000000000..86c4557e7488 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.Serialization.cs @@ -0,0 +1,225 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink Member properties. + public partial class AppLinkMemberProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AppLinkMemberProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AppLinkMemberProperties 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 DeserializeAppLinkMemberProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkMemberProperties)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkMemberProperties)} 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. + AppLinkMemberProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(AppLinkMemberProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ClusterType)) + { + writer.WritePropertyName("clusterType"u8); + writer.WriteStringValue(ClusterType.Value.ToString()); + } + writer.WritePropertyName("metadata"u8); + writer.WriteObjectValue(Metadata, options); + if (Optional.IsDefined(UpgradeProfile)) + { + writer.WritePropertyName("upgradeProfile"u8); + writer.WriteObjectValue(UpgradeProfile, options); + } + if (Optional.IsDefined(ObservabilityProfile)) + { + writer.WritePropertyName("observabilityProfile"u8); + writer.WriteObjectValue(ObservabilityProfile, options); + } + if (Optional.IsDefined(ConnectivityProfile)) + { + writer.WritePropertyName("connectivityProfile"u8); + writer.WriteObjectValue(ConnectivityProfile, options); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AppLinkMemberProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AppLinkMemberProperties 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(AppLinkMemberProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkMemberProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkMemberProperties DeserializeAppLinkMemberProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ClusterType? clusterType = default; + Metadata metadata = default; + UpgradeProfile upgradeProfile = default; + ObservabilityProfile observabilityProfile = default; + ConnectivityProfile connectivityProfile = default; + ProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("clusterType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + clusterType = new ClusterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("metadata"u8)) + { + metadata = Metadata.DeserializeMetadata(prop.Value, options); + continue; + } + if (prop.NameEquals("upgradeProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + upgradeProfile = UpgradeProfile.DeserializeUpgradeProfile(prop.Value, options); + continue; + } + if (prop.NameEquals("observabilityProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + observabilityProfile = ObservabilityProfile.DeserializeObservabilityProfile(prop.Value, options); + continue; + } + if (prop.NameEquals("connectivityProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + connectivityProfile = ConnectivityProfile.DeserializeConnectivityProfile(prop.Value, options); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkMemberProperties( + clusterType, + metadata, + upgradeProfile, + observabilityProfile, + connectivityProfile, + provisioningState, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.cs new file mode 100644 index 000000000000..8d08bfcc1292 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberProperties.cs @@ -0,0 +1,90 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink Member properties. + public partial class AppLinkMemberProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Resource ID. + /// is null. + public AppLinkMemberProperties(ResourceIdentifier metadataResourceId) + { + Argument.AssertNotNull(metadataResourceId, nameof(metadataResourceId)); + + Metadata = new Metadata(metadataResourceId); + } + + /// Initializes a new instance of . + /// Cluster type. + /// AppLink Member Metadata. + /// Upgrade profile. + /// Observability profile. + /// Connectivity profile. + /// Provisioning state. + /// Keeps track of any properties unknown to the library. + internal AppLinkMemberProperties(ClusterType? clusterType, Metadata metadata, UpgradeProfile upgradeProfile, ObservabilityProfile observabilityProfile, ConnectivityProfile connectivityProfile, ProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + ClusterType = clusterType; + Metadata = metadata; + UpgradeProfile = upgradeProfile; + ObservabilityProfile = observabilityProfile; + ConnectivityProfile = connectivityProfile; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Cluster type. + public ClusterType? ClusterType { get; set; } + + /// AppLink Member Metadata. + internal Metadata Metadata { get; set; } + + /// Upgrade profile. + public UpgradeProfile UpgradeProfile { get; set; } + + /// Observability profile. + internal ObservabilityProfile ObservabilityProfile { get; set; } + + /// Connectivity profile. + public ConnectivityProfile ConnectivityProfile { get; set; } + + /// Provisioning state. + public ProvisioningState? ProvisioningState { get; } + + /// Resource ID. + public ResourceIdentifier MetadataResourceId + { + get + { + return Metadata is null ? default : Metadata.ResourceId; + } + set + { + Metadata = new Metadata(value); + } + } + + /// Metrics endpoint URL. + public string ObservabilityMetricsEndpoint + { + get + { + return ObservabilityProfile is null ? default : ObservabilityProfile.MetricsEndpoint; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberUpdateProperties.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberUpdateProperties.Serialization.cs new file mode 100644 index 000000000000..ae54d2da2c38 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberUpdateProperties.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The updatable properties of the AppLinkMember. + public partial class AppLinkMemberUpdateProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AppLinkMemberUpdateProperties 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 DeserializeAppLinkMemberUpdateProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkMemberUpdateProperties)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkMemberUpdateProperties)} 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. + AppLinkMemberUpdateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(AppLinkMemberUpdateProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(UpgradeProfile)) + { + writer.WritePropertyName("upgradeProfile"u8); + writer.WriteObjectValue(UpgradeProfile, options); + } + if (Optional.IsDefined(ObservabilityProfile)) + { + writer.WritePropertyName("observabilityProfile"u8); + writer.WriteObjectValue(ObservabilityProfile, options); + } + if (Optional.IsDefined(ConnectivityProfile)) + { + writer.WritePropertyName("connectivityProfile"u8); + writer.WriteObjectValue(ConnectivityProfile, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AppLinkMemberUpdateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AppLinkMemberUpdateProperties 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(AppLinkMemberUpdateProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkMemberUpdateProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkMemberUpdateProperties DeserializeAppLinkMemberUpdateProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpgradeProfile upgradeProfile = default; + ObservabilityProfile observabilityProfile = default; + ConnectivityProfile connectivityProfile = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("upgradeProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + upgradeProfile = UpgradeProfile.DeserializeUpgradeProfile(prop.Value, options); + continue; + } + if (prop.NameEquals("observabilityProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + observabilityProfile = ObservabilityProfile.DeserializeObservabilityProfile(prop.Value, options); + continue; + } + if (prop.NameEquals("connectivityProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + connectivityProfile = ConnectivityProfile.DeserializeConnectivityProfile(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkMemberUpdateProperties(upgradeProfile, observabilityProfile, connectivityProfile, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberUpdateProperties.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberUpdateProperties.cs new file mode 100644 index 000000000000..d40c3c718f6d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkMemberUpdateProperties.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The updatable properties of the AppLinkMember. + public partial class AppLinkMemberUpdateProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AppLinkMemberUpdateProperties() + { + } + + /// Initializes a new instance of . + /// Upgrade profile. + /// Observability profile. + /// Connectivity profile. + /// Keeps track of any properties unknown to the library. + internal AppLinkMemberUpdateProperties(UpgradeProfile upgradeProfile, ObservabilityProfile observabilityProfile, ConnectivityProfile connectivityProfile, IDictionary additionalBinaryDataProperties) + { + UpgradeProfile = upgradeProfile; + ObservabilityProfile = observabilityProfile; + ConnectivityProfile = connectivityProfile; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Upgrade profile. + public UpgradeProfile UpgradeProfile { get; set; } + + /// Observability profile. + internal ObservabilityProfile ObservabilityProfile { get; set; } + + /// Connectivity profile. + public ConnectivityProfile ConnectivityProfile { get; set; } + + /// Metrics endpoint URL. + public string ObservabilityMetricsEndpoint + { + get + { + return ObservabilityProfile is null ? default : ObservabilityProfile.MetricsEndpoint; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkPatch.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkPatch.Serialization.cs new file mode 100644 index 000000000000..8d463fea01cb --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkPatch.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The type used for update operations of the AppLink. + public partial class AppLinkPatch : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AppLinkPatch 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 DeserializeAppLinkPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkPatch)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkPatch)} 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. + AppLinkPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => 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(AppLinkPatch appLinkPatch) + { + if (appLinkPatch == null) + { + return null; + } + return RequestContent.Create(appLinkPatch, 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 virtual 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(AppLinkPatch)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AppLinkPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AppLinkPatch 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(AppLinkPatch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkPatch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkPatch DeserializeAppLinkPatch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + 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 (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkPatch(tags ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkPatch.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkPatch.cs new file mode 100644 index 000000000000..3ea4cfff187e --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkPatch.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The type used for update operations of the AppLink. + public partial class AppLinkPatch + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AppLinkPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Resource tags. + /// Keeps track of any properties unknown to the library. + internal AppLinkPatch(IDictionary tags, IDictionary additionalBinaryDataProperties) + { + Tags = tags; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.Serialization.cs new file mode 100644 index 000000000000..ab7e6afe958a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink properties. + internal partial class AppLinkProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AppLinkProperties 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 DeserializeAppLinkProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppLinkProperties)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AppLinkProperties)} 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. + AppLinkProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(AppLinkProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AppLinkProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AppLinkProperties 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(AppLinkProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppLinkProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AppLinkProperties DeserializeAppLinkProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AppLinkProperties(provisioningState, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.cs new file mode 100644 index 000000000000..17640122e25a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AppLinkProperties.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink properties. + internal partial class AppLinkProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AppLinkProperties() + { + } + + /// Initializes a new instance of . + /// Provisioning state. + /// Keeps track of any properties unknown to the library. + internal AppLinkProperties(ProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Provisioning state. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.Serialization.cs new file mode 100644 index 000000000000..419df320fc68 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.Serialization.cs @@ -0,0 +1,176 @@ +// 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.Core; +using Azure.ResourceManager.AppLink; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink available version resource. + public partial class AvailableVersion : ResourceData, IJsonModel + { + /// 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 DeserializeAvailableVersion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AvailableVersion)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AvailableVersion)} 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. + AvailableVersion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AvailableVersion)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(AvailableVersion)} 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. + AvailableVersion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AvailableVersion)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(AvailableVersion)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAvailableVersion(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AvailableVersion DeserializeAvailableVersion(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(); + AvailableVersionProperties 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, AzureResourceManagerAppLinkContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = AvailableVersionProperties.DeserializeAvailableVersionProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AvailableVersion( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.cs new file mode 100644 index 000000000000..3245f3fecf4f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersion.cs @@ -0,0 +1,42 @@ +// 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.Models; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink available version resource. + public partial class AvailableVersion : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal AvailableVersion() + { + } + + /// 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. + /// The resource-specific properties for this resource. + internal AvailableVersion(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, AvailableVersionProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public AvailableVersionProperties Properties { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.Serialization.cs new file mode 100644 index 000000000000..a608a3970d2e --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AvailableVersion list operation. + internal partial class AvailableVersionListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AvailableVersionListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AvailableVersionListResult 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 DeserializeAvailableVersionListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AvailableVersionListResult)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AvailableVersionListResult)} 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. + AvailableVersionListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AvailableVersionListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAvailableVersionListResult(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 virtual 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(AvailableVersionListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (AvailableVersion item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AvailableVersionListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AvailableVersionListResult 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(AvailableVersionListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAvailableVersionListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AvailableVersionListResult DeserializeAvailableVersionListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(AvailableVersion.DeserializeAvailableVersion(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AvailableVersionListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.cs new file mode 100644 index 000000000000..8bcb876a7a5d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionListResult.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a AvailableVersion list operation. + internal partial class AvailableVersionListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The AvailableVersion items on this page. + internal AvailableVersionListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The AvailableVersion items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal AvailableVersionListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The AvailableVersion items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.Serialization.cs new file mode 100644 index 000000000000..816c2d1016ac --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink available version properties. + public partial class AvailableVersionProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AvailableVersionProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AvailableVersionProperties 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 DeserializeAvailableVersionProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AvailableVersionProperties)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(AvailableVersionProperties)} 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. + AvailableVersionProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(AvailableVersionProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("kubernetesVersion"u8); + writer.WriteStringValue(KubernetesVersion); + writer.WritePropertyName("fullyManagedVersions"u8); + writer.WriteObjectValue(FullyManagedVersions, options); + writer.WritePropertyName("selfManagedVersions"u8); + writer.WriteObjectValue(SelfManagedVersions, options); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AvailableVersionProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AvailableVersionProperties 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(AvailableVersionProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAvailableVersionProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AvailableVersionProperties DeserializeAvailableVersionProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string kubernetesVersion = default; + FullyManagedVersions fullyManagedVersions = default; + SelfManagedVersions selfManagedVersions = default; + ProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kubernetesVersion"u8)) + { + kubernetesVersion = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("fullyManagedVersions"u8)) + { + fullyManagedVersions = FullyManagedVersions.DeserializeFullyManagedVersions(prop.Value, options); + continue; + } + if (prop.NameEquals("selfManagedVersions"u8)) + { + selfManagedVersions = Models.SelfManagedVersions.DeserializeSelfManagedVersions(prop.Value, options); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AvailableVersionProperties(kubernetesVersion, fullyManagedVersions, selfManagedVersions, provisioningState, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.cs new file mode 100644 index 000000000000..d845462ec7df --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AvailableVersionProperties.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLink available version properties. + public partial class AvailableVersionProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Kubernetes version. + /// Fully managed versions. + /// Self managed versions. + internal AvailableVersionProperties(string kubernetesVersion, FullyManagedVersions fullyManagedVersions, SelfManagedVersions selfManagedVersions) + { + KubernetesVersion = kubernetesVersion; + FullyManagedVersions = fullyManagedVersions; + SelfManagedVersions = selfManagedVersions; + } + + /// Initializes a new instance of . + /// Kubernetes version. + /// Fully managed versions. + /// Self managed versions. + /// Provisioning state. + /// Keeps track of any properties unknown to the library. + internal AvailableVersionProperties(string kubernetesVersion, FullyManagedVersions fullyManagedVersions, SelfManagedVersions selfManagedVersions, ProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + KubernetesVersion = kubernetesVersion; + FullyManagedVersions = fullyManagedVersions; + SelfManagedVersions = selfManagedVersions; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Kubernetes version. + public string KubernetesVersion { get; } + + /// Fully managed versions. + internal FullyManagedVersions FullyManagedVersions { get; } + + /// Self managed versions. + internal SelfManagedVersions SelfManagedVersions { get; } + + /// Provisioning state. + public ProvisioningState? ProvisioningState { get; } + + /// Release channels. + public IList FullyManagedVersionsReleaseChannels + { + get + { + return FullyManagedVersions is null ? default : FullyManagedVersions.ReleaseChannels; + } + } + + /// Istio versions. + public IList SelfManagedVersions + { + get + { + return this.SelfManagedVersions is null ? default : SelfManagedVersions.Versions; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AzureResourceManagerAppLinkContext.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AzureResourceManagerAppLinkContext.cs new file mode 100644 index 000000000000..47e313b80f5f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/AzureResourceManagerAppLinkContext.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure; +using Azure.ResourceManager.AppLink.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(AppLinkData))] + [ModelReaderWriterBuildable(typeof(AppLinkListResult))] + [ModelReaderWriterBuildable(typeof(AppLinkMemberData))] + [ModelReaderWriterBuildable(typeof(AppLinkMemberListResult))] + [ModelReaderWriterBuildable(typeof(AppLinkMemberPatch))] + [ModelReaderWriterBuildable(typeof(AppLinkMemberProperties))] + [ModelReaderWriterBuildable(typeof(AppLinkMemberResource))] + [ModelReaderWriterBuildable(typeof(AppLinkMemberUpdateProperties))] + [ModelReaderWriterBuildable(typeof(AppLinkPatch))] + [ModelReaderWriterBuildable(typeof(AppLinkProperties))] + [ModelReaderWriterBuildable(typeof(AppLinkResource))] + [ModelReaderWriterBuildable(typeof(AvailableVersion))] + [ModelReaderWriterBuildable(typeof(AvailableVersionListResult))] + [ModelReaderWriterBuildable(typeof(AvailableVersionProperties))] + [ModelReaderWriterBuildable(typeof(ConnectivityProfile))] + [ModelReaderWriterBuildable(typeof(EastWestGatewayProfile))] + [ModelReaderWriterBuildable(typeof(FullyManagedUpgradeProfile))] + [ModelReaderWriterBuildable(typeof(FullyManagedVersions))] + [ModelReaderWriterBuildable(typeof(ManagedServiceIdentity))] + [ModelReaderWriterBuildable(typeof(Metadata))] + [ModelReaderWriterBuildable(typeof(MetricsProfile))] + [ModelReaderWriterBuildable(typeof(ObservabilityProfile))] + [ModelReaderWriterBuildable(typeof(PrivateConnectProfile))] + [ModelReaderWriterBuildable(typeof(ReleaseChannelInfo))] + [ModelReaderWriterBuildable(typeof(ResponseError))] + [ModelReaderWriterBuildable(typeof(SelfManagedUpgradeProfile))] + [ModelReaderWriterBuildable(typeof(SelfManagedVersions))] + [ModelReaderWriterBuildable(typeof(SystemData))] + [ModelReaderWriterBuildable(typeof(UpgradeHistory))] + [ModelReaderWriterBuildable(typeof(UpgradeHistoryListResult))] + [ModelReaderWriterBuildable(typeof(UpgradeHistoryProperties))] + [ModelReaderWriterBuildable(typeof(UpgradeProfile))] + [ModelReaderWriterBuildable(typeof(UserAssignedIdentity))] + [ModelReaderWriterBuildable(typeof(VersionInfo))] + public partial class AzureResourceManagerAppLinkContext : ModelReaderWriterContext + { + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ClusterType.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ClusterType.cs new file mode 100644 index 000000000000..0cca96bd6ac1 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ClusterType.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember cluster type. + public readonly partial struct ClusterType : IEquatable + { + private readonly string _value; + /// Azure Kubernetes Service. + private const string AKSValue = "AKS"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ClusterType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Azure Kubernetes Service. + public static ClusterType AKS { get; } = new ClusterType(AKSValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ClusterType left, ClusterType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ClusterType left, ClusterType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ClusterType(string value) => new ClusterType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ClusterType?(string value) => value == null ? null : new ClusterType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ClusterType other && Equals(other); + + /// + public bool Equals(ClusterType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.Serialization.cs new file mode 100644 index 000000000000..ee63f2ecfed8 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember connectivity profile. + public partial class ConnectivityProfile : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ConnectivityProfile 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 DeserializeConnectivityProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ConnectivityProfile)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(ConnectivityProfile)} 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. + ConnectivityProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(ConnectivityProfile)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(EastWestGateway)) + { + writer.WritePropertyName("eastWestGateway"u8); + writer.WriteObjectValue(EastWestGateway, options); + } + if (Optional.IsDefined(PrivateConnect)) + { + writer.WritePropertyName("privateConnect"u8); + writer.WriteObjectValue(PrivateConnect, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ConnectivityProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ConnectivityProfile 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(ConnectivityProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConnectivityProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ConnectivityProfile DeserializeConnectivityProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EastWestGatewayProfile eastWestGateway = default; + PrivateConnectProfile privateConnect = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("eastWestGateway"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + eastWestGateway = EastWestGatewayProfile.DeserializeEastWestGatewayProfile(prop.Value, options); + continue; + } + if (prop.NameEquals("privateConnect"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateConnect = PrivateConnectProfile.DeserializePrivateConnectProfile(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ConnectivityProfile(eastWestGateway, privateConnect, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.cs new file mode 100644 index 000000000000..6e24b2386760 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ConnectivityProfile.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember connectivity profile. + public partial class ConnectivityProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ConnectivityProfile() + { + } + + /// Initializes a new instance of . + /// East-West gateway profile. + /// Private connect profile. + /// Keeps track of any properties unknown to the library. + internal ConnectivityProfile(EastWestGatewayProfile eastWestGateway, PrivateConnectProfile privateConnect, IDictionary additionalBinaryDataProperties) + { + EastWestGateway = eastWestGateway; + PrivateConnect = privateConnect; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// East-West gateway profile. + internal EastWestGatewayProfile EastWestGateway { get; set; } + + /// Private connect profile. + internal PrivateConnectProfile PrivateConnect { get; set; } + + /// East-West gateway visibility. + public EastWestGatewayVisibility? EastWestGatewayVisibility + { + get + { + return EastWestGateway is null ? default : EastWestGateway.Visibility; + } + set + { + EastWestGateway = value.HasValue ? new EastWestGatewayProfile(value.Value) : default; + } + } + + /// Delegated Subnet to AppLink. + public ResourceIdentifier PrivateConnectSubnetResourceId + { + get + { + return PrivateConnect is null ? default : PrivateConnect.SubnetResourceId; + } + set + { + PrivateConnect = new PrivateConnectProfile(value); + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.Serialization.cs new file mode 100644 index 000000000000..60198ec17162 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember east-west gateway profile. + internal partial class EastWestGatewayProfile : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EastWestGatewayProfile() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EastWestGatewayProfile 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 DeserializeEastWestGatewayProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EastWestGatewayProfile)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(EastWestGatewayProfile)} 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. + EastWestGatewayProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(EastWestGatewayProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("visibility"u8); + writer.WriteStringValue(Visibility.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EastWestGatewayProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EastWestGatewayProfile 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(EastWestGatewayProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEastWestGatewayProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EastWestGatewayProfile DeserializeEastWestGatewayProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EastWestGatewayVisibility visibility = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("visibility"u8)) + { + visibility = new EastWestGatewayVisibility(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EastWestGatewayProfile(visibility, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.cs new file mode 100644 index 000000000000..651a45c23597 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayProfile.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember east-west gateway profile. + internal partial class EastWestGatewayProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// East-West gateway visibility. + public EastWestGatewayProfile(EastWestGatewayVisibility visibility) + { + Visibility = visibility; + } + + /// Initializes a new instance of . + /// East-West gateway visibility. + /// Keeps track of any properties unknown to the library. + internal EastWestGatewayProfile(EastWestGatewayVisibility visibility, IDictionary additionalBinaryDataProperties) + { + Visibility = visibility; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// East-West gateway visibility. + public EastWestGatewayVisibility Visibility { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayVisibility.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayVisibility.cs new file mode 100644 index 000000000000..35f62414685a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/EastWestGatewayVisibility.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// East-West gateway visibility. + public readonly partial struct EastWestGatewayVisibility : IEquatable + { + private readonly string _value; + /// Use an internal load balancer for the east-west gateway. + private const string InternalValue = "Internal"; + /// Use an external load balancer for the east-west gateway. + private const string ExternalValue = "External"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public EastWestGatewayVisibility(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Use an internal load balancer for the east-west gateway. + public static EastWestGatewayVisibility Internal { get; } = new EastWestGatewayVisibility(InternalValue); + + /// Use an external load balancer for the east-west gateway. + public static EastWestGatewayVisibility External { get; } = new EastWestGatewayVisibility(ExternalValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(EastWestGatewayVisibility left, EastWestGatewayVisibility right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(EastWestGatewayVisibility left, EastWestGatewayVisibility right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator EastWestGatewayVisibility(string value) => new EastWestGatewayVisibility(value); + + /// Converts a string to a . + /// The value. + public static implicit operator EastWestGatewayVisibility?(string value) => value == null ? null : new EastWestGatewayVisibility(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EastWestGatewayVisibility other && Equals(other); + + /// + public bool Equals(EastWestGatewayVisibility other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.Serialization.cs new file mode 100644 index 000000000000..235096ec3c25 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember fully managed upgrade profile. + internal partial class FullyManagedUpgradeProfile : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal FullyManagedUpgradeProfile() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FullyManagedUpgradeProfile 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 DeserializeFullyManagedUpgradeProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FullyManagedUpgradeProfile)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(FullyManagedUpgradeProfile)} 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. + FullyManagedUpgradeProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(FullyManagedUpgradeProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("releaseChannel"u8); + writer.WriteStringValue(ReleaseChannel.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + FullyManagedUpgradeProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FullyManagedUpgradeProfile 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(FullyManagedUpgradeProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFullyManagedUpgradeProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FullyManagedUpgradeProfile DeserializeFullyManagedUpgradeProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpgradeReleaseChannel releaseChannel = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("releaseChannel"u8)) + { + releaseChannel = new UpgradeReleaseChannel(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FullyManagedUpgradeProfile(releaseChannel, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.cs new file mode 100644 index 000000000000..199e15c4de50 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedUpgradeProfile.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember fully managed upgrade profile. + internal partial class FullyManagedUpgradeProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Release channel. + public FullyManagedUpgradeProfile(UpgradeReleaseChannel releaseChannel) + { + ReleaseChannel = releaseChannel; + } + + /// Initializes a new instance of . + /// Release channel. + /// Keeps track of any properties unknown to the library. + internal FullyManagedUpgradeProfile(UpgradeReleaseChannel releaseChannel, IDictionary additionalBinaryDataProperties) + { + ReleaseChannel = releaseChannel; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Release channel. + public UpgradeReleaseChannel ReleaseChannel { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.Serialization.cs new file mode 100644 index 000000000000..2b0e48068d38 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Fully managed versions. + internal partial class FullyManagedVersions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal FullyManagedVersions() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FullyManagedVersions 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 DeserializeFullyManagedVersions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FullyManagedVersions)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(FullyManagedVersions)} 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. + FullyManagedVersions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(FullyManagedVersions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("releaseChannels"u8); + writer.WriteStartArray(); + foreach (ReleaseChannelInfo item in ReleaseChannels) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + FullyManagedVersions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FullyManagedVersions 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(FullyManagedVersions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFullyManagedVersions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FullyManagedVersions DeserializeFullyManagedVersions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList releaseChannels = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("releaseChannels"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ReleaseChannelInfo.DeserializeReleaseChannelInfo(item, options)); + } + releaseChannels = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FullyManagedVersions(releaseChannels, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.cs new file mode 100644 index 000000000000..c90441a9b9be --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/FullyManagedVersions.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Fully managed versions. + internal partial class FullyManagedVersions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Release channels. + internal FullyManagedVersions(IEnumerable releaseChannels) + { + ReleaseChannels = releaseChannels.ToList(); + } + + /// Initializes a new instance of . + /// Release channels. + /// Keeps track of any properties unknown to the library. + internal FullyManagedVersions(IList releaseChannels, IDictionary additionalBinaryDataProperties) + { + ReleaseChannels = releaseChannels; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Release channels. + public IList ReleaseChannels { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.Serialization.cs new file mode 100644 index 000000000000..cd41b1cff662 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember metadata. + internal partial class Metadata : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal Metadata() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Metadata 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 DeserializeMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Metadata)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(Metadata)} 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. + Metadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(Metadata)} does not support writing '{format}' format."); + } + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + Metadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Metadata 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(Metadata)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetadata(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Metadata DeserializeMetadata(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier resourceId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("resourceId"u8)) + { + resourceId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Metadata(resourceId, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.cs new file mode 100644 index 000000000000..03415796f3dd --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/Metadata.cs @@ -0,0 +1,43 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember metadata. + internal partial class Metadata + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Resource ID. + /// is null. + public Metadata(ResourceIdentifier resourceId) + { + Argument.AssertNotNull(resourceId, nameof(resourceId)); + + ResourceId = resourceId; + } + + /// Initializes a new instance of . + /// Resource ID. + /// Keeps track of any properties unknown to the library. + internal Metadata(ResourceIdentifier resourceId, IDictionary additionalBinaryDataProperties) + { + ResourceId = resourceId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Resource ID. + public ResourceIdentifier ResourceId { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.Serialization.cs new file mode 100644 index 000000000000..050c7702817f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember metrics profile. + internal partial class MetricsProfile : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricsProfile 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 DeserializeMetricsProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricsProfile)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(MetricsProfile)} 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. + MetricsProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(MetricsProfile)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(MetricsEndpoint)) + { + writer.WritePropertyName("metricsEndpoint"u8); + writer.WriteStringValue(MetricsEndpoint); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MetricsProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricsProfile 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(MetricsProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricsProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricsProfile DeserializeMetricsProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string metricsEndpoint = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metricsEndpoint"u8)) + { + metricsEndpoint = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MetricsProfile(metricsEndpoint, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.cs new file mode 100644 index 000000000000..5361e9b10d2d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/MetricsProfile.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember metrics profile. + internal partial class MetricsProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public MetricsProfile() + { + } + + /// Initializes a new instance of . + /// Metrics endpoint URL. + /// Keeps track of any properties unknown to the library. + internal MetricsProfile(string metricsEndpoint, IDictionary additionalBinaryDataProperties) + { + MetricsEndpoint = metricsEndpoint; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Metrics endpoint URL. + public string MetricsEndpoint { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.Serialization.cs new file mode 100644 index 000000000000..e54b8ed92f1a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember observability profile. + internal partial class ObservabilityProfile : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ObservabilityProfile 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 DeserializeObservabilityProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ObservabilityProfile)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(ObservabilityProfile)} 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. + ObservabilityProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(ObservabilityProfile)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Metrics)) + { + writer.WritePropertyName("metrics"u8); + writer.WriteObjectValue(Metrics, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ObservabilityProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ObservabilityProfile 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(ObservabilityProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeObservabilityProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ObservabilityProfile DeserializeObservabilityProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MetricsProfile metrics = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metrics"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + metrics = MetricsProfile.DeserializeMetricsProfile(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ObservabilityProfile(metrics, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.cs new file mode 100644 index 000000000000..52fa0d12f4d8 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ObservabilityProfile.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember observability profile. + internal partial class ObservabilityProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ObservabilityProfile() + { + } + + /// Initializes a new instance of . + /// Metrics configuration. + /// Keeps track of any properties unknown to the library. + internal ObservabilityProfile(MetricsProfile metrics, IDictionary additionalBinaryDataProperties) + { + Metrics = metrics; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Metrics configuration. + internal MetricsProfile Metrics { get; set; } + + /// Metrics endpoint URL. + public string MetricsEndpoint + { + get + { + return Metrics is null ? default : Metrics.MetricsEndpoint; + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.Serialization.cs new file mode 100644 index 000000000000..9804bd575c29 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember private connect profile. + internal partial class PrivateConnectProfile : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PrivateConnectProfile() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PrivateConnectProfile 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 DeserializePrivateConnectProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PrivateConnectProfile)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(PrivateConnectProfile)} 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. + PrivateConnectProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(PrivateConnectProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("subnetResourceId"u8); + writer.WriteStringValue(SubnetResourceId); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PrivateConnectProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PrivateConnectProfile 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(PrivateConnectProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrivateConnectProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PrivateConnectProfile DeserializePrivateConnectProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier subnetResourceId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("subnetResourceId"u8)) + { + subnetResourceId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PrivateConnectProfile(subnetResourceId, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.cs new file mode 100644 index 000000000000..885d35b9e89e --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/PrivateConnectProfile.cs @@ -0,0 +1,43 @@ +// 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.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember private connect profile. + internal partial class PrivateConnectProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Delegated Subnet to AppLink. + /// is null. + public PrivateConnectProfile(ResourceIdentifier subnetResourceId) + { + Argument.AssertNotNull(subnetResourceId, nameof(subnetResourceId)); + + SubnetResourceId = subnetResourceId; + } + + /// Initializes a new instance of . + /// Delegated Subnet to AppLink. + /// Keeps track of any properties unknown to the library. + internal PrivateConnectProfile(ResourceIdentifier subnetResourceId, IDictionary additionalBinaryDataProperties) + { + SubnetResourceId = subnetResourceId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Delegated Subnet to AppLink. + public ResourceIdentifier SubnetResourceId { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ProvisioningState.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..1a3722d94d26 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Provisioning state of the resource. + public readonly partial struct ProvisioningState : IEquatable + { + private readonly string _value; + /// Resource has been created. + private const string SucceededValue = "Succeeded"; + /// Resource creation failed. + private const string FailedValue = "Failed"; + /// Resource creation was canceled. + private const string CanceledValue = "Canceled"; + /// Resource is getting provisioned. + private const string ProvisioningValue = "Provisioning"; + /// Resource is Updating. + private const string UpdatingValue = "Updating"; + /// Resource is Deleting. + private const string DeletingValue = "Deleting"; + /// Resource has been Accepted. + private const string AcceptedValue = "Accepted"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ProvisioningState(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Resource has been created. + public static ProvisioningState Succeeded { get; } = new ProvisioningState(SucceededValue); + + /// Resource creation failed. + public static ProvisioningState Failed { get; } = new ProvisioningState(FailedValue); + + /// Resource creation was canceled. + public static ProvisioningState Canceled { get; } = new ProvisioningState(CanceledValue); + + /// Resource is getting provisioned. + public static ProvisioningState Provisioning { get; } = new ProvisioningState(ProvisioningValue); + + /// Resource is Updating. + public static ProvisioningState Updating { get; } = new ProvisioningState(UpdatingValue); + + /// Resource is Deleting. + public static ProvisioningState Deleting { get; } = new ProvisioningState(DeletingValue); + + /// Resource has been Accepted. + public static ProvisioningState Accepted { get; } = new ProvisioningState(AcceptedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ProvisioningState left, ProvisioningState right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ProvisioningState left, ProvisioningState right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ProvisioningState(string value) => new ProvisioningState(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ProvisioningState?(string value) => value == null ? null : new ProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ProvisioningState other && Equals(other); + + /// + public bool Equals(ProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.Serialization.cs new file mode 100644 index 000000000000..18f6a7fbdba7 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Release channel information. + public partial class ReleaseChannelInfo : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ReleaseChannelInfo() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ReleaseChannelInfo 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 DeserializeReleaseChannelInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ReleaseChannelInfo)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(ReleaseChannelInfo)} 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. + ReleaseChannelInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(ReleaseChannelInfo)} does not support writing '{format}' format."); + } + writer.WritePropertyName("releaseChannel"u8); + writer.WriteStringValue(ReleaseChannel); + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ReleaseChannelInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ReleaseChannelInfo 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(ReleaseChannelInfo)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeReleaseChannelInfo(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ReleaseChannelInfo DeserializeReleaseChannelInfo(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string releaseChannel = default; + string version = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("releaseChannel"u8)) + { + releaseChannel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ReleaseChannelInfo(releaseChannel, version, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.cs new file mode 100644 index 000000000000..54d0e97dc5f9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/ReleaseChannelInfo.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Release channel information. + public partial class ReleaseChannelInfo + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Release channel. + /// Istio version behind release channel. + internal ReleaseChannelInfo(string releaseChannel, string version) + { + ReleaseChannel = releaseChannel; + Version = version; + } + + /// Initializes a new instance of . + /// Release channel. + /// Istio version behind release channel. + /// Keeps track of any properties unknown to the library. + internal ReleaseChannelInfo(string releaseChannel, string version, IDictionary additionalBinaryDataProperties) + { + ReleaseChannel = releaseChannel; + Version = version; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Release channel. + public string ReleaseChannel { get; } + + /// Istio version behind release channel. + public string Version { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.Serialization.cs new file mode 100644 index 000000000000..b0bb3e1e2366 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember self managed upgrade profile. + internal partial class SelfManagedUpgradeProfile : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SelfManagedUpgradeProfile() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfManagedUpgradeProfile 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 DeserializeSelfManagedUpgradeProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SelfManagedUpgradeProfile)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(SelfManagedUpgradeProfile)} 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. + SelfManagedUpgradeProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(SelfManagedUpgradeProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SelfManagedUpgradeProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfManagedUpgradeProfile 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(SelfManagedUpgradeProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSelfManagedUpgradeProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfManagedUpgradeProfile DeserializeSelfManagedUpgradeProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string version = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SelfManagedUpgradeProfile(version, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.cs new file mode 100644 index 000000000000..cd20ebc414b9 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedUpgradeProfile.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember self managed upgrade profile. + internal partial class SelfManagedUpgradeProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Istio version. + /// is null. + public SelfManagedUpgradeProfile(string version) + { + Argument.AssertNotNull(version, nameof(version)); + + Version = version; + } + + /// Initializes a new instance of . + /// Istio version. + /// Keeps track of any properties unknown to the library. + internal SelfManagedUpgradeProfile(string version, IDictionary additionalBinaryDataProperties) + { + Version = version; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Istio version. + public string Version { get; set; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.Serialization.cs new file mode 100644 index 000000000000..d05eef32081f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Self managed versions. + internal partial class SelfManagedVersions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SelfManagedVersions() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfManagedVersions 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 DeserializeSelfManagedVersions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SelfManagedVersions)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(SelfManagedVersions)} 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. + SelfManagedVersions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(SelfManagedVersions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("versions"u8); + writer.WriteStartArray(); + foreach (VersionInfo item in Versions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SelfManagedVersions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfManagedVersions 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(SelfManagedVersions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSelfManagedVersions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfManagedVersions DeserializeSelfManagedVersions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList versions = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("versions"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(VersionInfo.DeserializeVersionInfo(item, options)); + } + versions = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SelfManagedVersions(versions, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.cs new file mode 100644 index 000000000000..fbd6a9fd0c68 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/SelfManagedVersions.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Self managed versions. + internal partial class SelfManagedVersions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Istio versions. + internal SelfManagedVersions(IEnumerable versions) + { + Versions = versions.ToList(); + } + + /// Initializes a new instance of . + /// Istio versions. + /// Keeps track of any properties unknown to the library. + internal SelfManagedVersions(IList versions, IDictionary additionalBinaryDataProperties) + { + Versions = versions; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Istio versions. + public IList Versions { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.Serialization.cs new file mode 100644 index 000000000000..2e49aed3b37d --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.Serialization.cs @@ -0,0 +1,176 @@ +// 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.Core; +using Azure.ResourceManager.AppLink; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade history. + public partial class UpgradeHistory : ResourceData, IJsonModel + { + /// 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 DeserializeUpgradeHistory(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpgradeHistory)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(UpgradeHistory)} 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. + UpgradeHistory IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (UpgradeHistory)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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(UpgradeHistory)} 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. + UpgradeHistory IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (UpgradeHistory)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(UpgradeHistory)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpgradeHistory(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UpgradeHistory DeserializeUpgradeHistory(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(); + UpgradeHistoryProperties 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, AzureResourceManagerAppLinkContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = UpgradeHistoryProperties.DeserializeUpgradeHistoryProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UpgradeHistory( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.cs new file mode 100644 index 000000000000..ff9a544bb6fd --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistory.cs @@ -0,0 +1,42 @@ +// 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.Models; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade history. + public partial class UpgradeHistory : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal UpgradeHistory() + { + } + + /// 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. + /// The resource-specific properties for this resource. + internal UpgradeHistory(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, UpgradeHistoryProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// The resource-specific properties for this resource. + public UpgradeHistoryProperties Properties { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.Serialization.cs new file mode 100644 index 000000000000..33ff9e207ec6 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a UpgradeHistory list operation. + internal partial class UpgradeHistoryListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UpgradeHistoryListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UpgradeHistoryListResult 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 DeserializeUpgradeHistoryListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpgradeHistoryListResult)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(UpgradeHistoryListResult)} 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. + UpgradeHistoryListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static UpgradeHistoryListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUpgradeHistoryListResult(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 virtual 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(UpgradeHistoryListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (UpgradeHistory item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + UpgradeHistoryListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UpgradeHistoryListResult 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(UpgradeHistoryListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpgradeHistoryListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UpgradeHistoryListResult DeserializeUpgradeHistoryListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(UpgradeHistory.DeserializeUpgradeHistory(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UpgradeHistoryListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.cs new file mode 100644 index 000000000000..7dd3cece2f73 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryListResult.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// The response of a UpgradeHistory list operation. + internal partial class UpgradeHistoryListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The UpgradeHistory items on this page. + internal UpgradeHistoryListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The UpgradeHistory items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal UpgradeHistoryListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The UpgradeHistory items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.Serialization.cs new file mode 100644 index 000000000000..97647e5bbe0a --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.Serialization.cs @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade history properties. + public partial class UpgradeHistoryProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UpgradeHistoryProperties() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UpgradeHistoryProperties 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 DeserializeUpgradeHistoryProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpgradeHistoryProperties)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(UpgradeHistoryProperties)} 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. + UpgradeHistoryProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(UpgradeHistoryProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("startTimestamp"u8); + writer.WriteStringValue(StartTimestamp, "O"); + if (Optional.IsDefined(EndTimestamp)) + { + writer.WritePropertyName("endTimestamp"u8); + writer.WriteStringValue(EndTimestamp.Value, "O"); + } + writer.WritePropertyName("initiatedBy"u8); + writer.WriteStringValue(InitiatedBy); + writer.WritePropertyName("fromVersion"u8); + writer.WriteStringValue(FromVersion); + writer.WritePropertyName("toVersion"u8); + writer.WriteStringValue(ToVersion); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + UpgradeHistoryProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UpgradeHistoryProperties 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(UpgradeHistoryProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpgradeHistoryProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UpgradeHistoryProperties DeserializeUpgradeHistoryProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset startTimestamp = default; + DateTimeOffset? endTimestamp = default; + string initiatedBy = default; + string fromVersion = default; + string toVersion = default; + ProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("startTimestamp"u8)) + { + startTimestamp = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("endTimestamp"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endTimestamp = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("initiatedBy"u8)) + { + initiatedBy = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("fromVersion"u8)) + { + fromVersion = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("toVersion"u8)) + { + toVersion = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UpgradeHistoryProperties( + startTimestamp, + endTimestamp, + initiatedBy, + fromVersion, + toVersion, + provisioningState, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.cs new file mode 100644 index 000000000000..ba5450655253 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeHistoryProperties.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade history properties. + public partial class UpgradeHistoryProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Start timestamp. + /// Upgrade initiator. + /// Version upgraded from. + /// Version upgraded to. + internal UpgradeHistoryProperties(DateTimeOffset startTimestamp, string initiatedBy, string fromVersion, string toVersion) + { + StartTimestamp = startTimestamp; + InitiatedBy = initiatedBy; + FromVersion = fromVersion; + ToVersion = toVersion; + } + + /// Initializes a new instance of . + /// Start timestamp. + /// End timestamp. + /// Upgrade initiator. + /// Version upgraded from. + /// Version upgraded to. + /// Provisioning state. + /// Keeps track of any properties unknown to the library. + internal UpgradeHistoryProperties(DateTimeOffset startTimestamp, DateTimeOffset? endTimestamp, string initiatedBy, string fromVersion, string toVersion, ProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + StartTimestamp = startTimestamp; + EndTimestamp = endTimestamp; + InitiatedBy = initiatedBy; + FromVersion = fromVersion; + ToVersion = toVersion; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Start timestamp. + public DateTimeOffset StartTimestamp { get; } + + /// End timestamp. + public DateTimeOffset? EndTimestamp { get; } + + /// Upgrade initiator. + public string InitiatedBy { get; } + + /// Version upgraded from. + public string FromVersion { get; } + + /// Version upgraded to. + public string ToVersion { get; } + + /// Provisioning state. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeMode.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeMode.cs new file mode 100644 index 000000000000..024e7f906d3f --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeMode.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade mode. + public readonly partial struct UpgradeMode : IEquatable + { + private readonly string _value; + /// Fully managed upgrade mode. + private const string FullyManagedValue = "FullyManaged"; + /// Self managed upgrade mode. + private const string SelfManagedValue = "SelfManaged"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public UpgradeMode(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Fully managed upgrade mode. + public static UpgradeMode FullyManaged { get; } = new UpgradeMode(FullyManagedValue); + + /// Self managed upgrade mode. + public static UpgradeMode SelfManaged { get; } = new UpgradeMode(SelfManagedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(UpgradeMode left, UpgradeMode right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(UpgradeMode left, UpgradeMode right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator UpgradeMode(string value) => new UpgradeMode(value); + + /// Converts a string to a . + /// The value. + public static implicit operator UpgradeMode?(string value) => value == null ? null : new UpgradeMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is UpgradeMode other && Equals(other); + + /// + public bool Equals(UpgradeMode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.Serialization.cs new file mode 100644 index 000000000000..33405da807c0 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.Serialization.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade profile. + public partial class UpgradeProfile : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UpgradeProfile() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UpgradeProfile 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 DeserializeUpgradeProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpgradeProfile)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(UpgradeProfile)} 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. + UpgradeProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(UpgradeProfile)} does not support writing '{format}' format."); + } + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.ToString()); + if (Optional.IsDefined(FullyManagedUpgradeProfile)) + { + writer.WritePropertyName("fullyManagedUpgradeProfile"u8); + writer.WriteObjectValue(FullyManagedUpgradeProfile, options); + } + if (Optional.IsDefined(SelfManagedUpgradeProfile)) + { + writer.WritePropertyName("selfManagedUpgradeProfile"u8); + writer.WriteObjectValue(SelfManagedUpgradeProfile, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + UpgradeProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UpgradeProfile 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(UpgradeProfile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpgradeProfile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UpgradeProfile DeserializeUpgradeProfile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpgradeMode mode = default; + FullyManagedUpgradeProfile fullyManagedUpgradeProfile = default; + SelfManagedUpgradeProfile selfManagedUpgradeProfile = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("mode"u8)) + { + mode = new UpgradeMode(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("fullyManagedUpgradeProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fullyManagedUpgradeProfile = FullyManagedUpgradeProfile.DeserializeFullyManagedUpgradeProfile(prop.Value, options); + continue; + } + if (prop.NameEquals("selfManagedUpgradeProfile"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + selfManagedUpgradeProfile = SelfManagedUpgradeProfile.DeserializeSelfManagedUpgradeProfile(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UpgradeProfile(mode, fullyManagedUpgradeProfile, selfManagedUpgradeProfile, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.cs new file mode 100644 index 000000000000..9aa9d4196da4 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeProfile.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade profile. + public partial class UpgradeProfile + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Upgrade mode. + public UpgradeProfile(UpgradeMode mode) + { + Mode = mode; + } + + /// Initializes a new instance of . + /// Upgrade mode. + /// Fully managed upgrade profile. + /// Self managed upgrade profile. + /// Keeps track of any properties unknown to the library. + internal UpgradeProfile(UpgradeMode mode, FullyManagedUpgradeProfile fullyManagedUpgradeProfile, SelfManagedUpgradeProfile selfManagedUpgradeProfile, IDictionary additionalBinaryDataProperties) + { + Mode = mode; + FullyManagedUpgradeProfile = fullyManagedUpgradeProfile; + SelfManagedUpgradeProfile = selfManagedUpgradeProfile; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Upgrade mode. + public UpgradeMode Mode { get; set; } + + /// Fully managed upgrade profile. + internal FullyManagedUpgradeProfile FullyManagedUpgradeProfile { get; set; } + + /// Self managed upgrade profile. + internal SelfManagedUpgradeProfile SelfManagedUpgradeProfile { get; set; } + + /// Release channel. + public UpgradeReleaseChannel? FullyManagedUpgradeReleaseChannel + { + get + { + return FullyManagedUpgradeProfile is null ? default : FullyManagedUpgradeProfile.ReleaseChannel; + } + set + { + FullyManagedUpgradeProfile = value.HasValue ? new FullyManagedUpgradeProfile(value.Value) : default; + } + } + + /// Istio version. + public string SelfManagedUpgradeVersion + { + get + { + return SelfManagedUpgradeProfile is null ? default : SelfManagedUpgradeProfile.Version; + } + set + { + SelfManagedUpgradeProfile = new SelfManagedUpgradeProfile(value); + } + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeReleaseChannel.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeReleaseChannel.cs new file mode 100644 index 000000000000..bd9ffbc012f7 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/UpgradeReleaseChannel.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// AppLinkMember upgrade release channel. + public readonly partial struct UpgradeReleaseChannel : IEquatable + { + private readonly string _value; + /// Rapid release channel. + private const string RapidValue = "Rapid"; + /// Stable release channel. + private const string StableValue = "Stable"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public UpgradeReleaseChannel(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Rapid release channel. + public static UpgradeReleaseChannel Rapid { get; } = new UpgradeReleaseChannel(RapidValue); + + /// Stable release channel. + public static UpgradeReleaseChannel Stable { get; } = new UpgradeReleaseChannel(StableValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(UpgradeReleaseChannel left, UpgradeReleaseChannel right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(UpgradeReleaseChannel left, UpgradeReleaseChannel right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator UpgradeReleaseChannel(string value) => new UpgradeReleaseChannel(value); + + /// Converts a string to a . + /// The value. + public static implicit operator UpgradeReleaseChannel?(string value) => value == null ? null : new UpgradeReleaseChannel(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is UpgradeReleaseChannel other && Equals(other); + + /// + public bool Equals(UpgradeReleaseChannel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.Serialization.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.Serialization.cs new file mode 100644 index 000000000000..d731472dec29 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.Serialization.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.AppLink; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Version information. + public partial class VersionInfo : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal VersionInfo() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual VersionInfo 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 DeserializeVersionInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VersionInfo)} 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, AzureResourceManagerAppLinkContext.Default); + default: + throw new FormatException($"The model {nameof(VersionInfo)} 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. + VersionInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// 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 virtual 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(VersionInfo)} does not support writing '{format}' format."); + } + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + writer.WritePropertyName("upgrades"u8); + writer.WriteStartArray(); + foreach (string item in Upgrades) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + VersionInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual VersionInfo 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(VersionInfo)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVersionInfo(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static VersionInfo DeserializeVersionInfo(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string version = default; + IList upgrades = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("upgrades"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + upgrades = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new VersionInfo(version, upgrades, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.cs new file mode 100644 index 000000000000..c7c968d74b98 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/Models/VersionInfo.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 System.Linq; + +namespace Azure.ResourceManager.AppLink.Models +{ + /// Version information. + public partial class VersionInfo + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Istio version. + /// Available upgrades. + internal VersionInfo(string version, IEnumerable upgrades) + { + Version = version; + Upgrades = upgrades.ToList(); + } + + /// Initializes a new instance of . + /// Istio version. + /// Available upgrades. + /// Keeps track of any properties unknown to the library. + internal VersionInfo(string version, IList upgrades, IDictionary additionalBinaryDataProperties) + { + Version = version; + Upgrades = upgrades; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Istio version. + public string Version { get; } + + /// Available upgrades. + public IList Upgrades { get; } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/ProviderConstants.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..7d05f1f90356 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/ProviderConstants.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.AppLink +{ + internal static partial class ProviderConstants + { + /// Gets the DefaultProviderNamespace. + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinkMembersRestOperations.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinkMembersRestOperations.cs new file mode 100644 index 000000000000..09844489dc48 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinkMembersRestOperations.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinkMembers + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of AppLinkMembers for mocking. + protected AppLinkMembers() + { + } + + /// Initializes a new instance of AppLinkMembers. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal AppLinkMembers(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers/", false); + uri.AppendPath(appLinkMemberName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers/", false); + uri.AppendPath(appLinkMemberName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers/", false); + uri.AppendPath(appLinkMemberName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers/", false); + uri.AppendPath(appLinkMemberName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetByAppLinkRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetByAppLinkRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string appLinkName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinksRestOperations.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinksRestOperations.cs new file mode 100644 index 000000000000..21047fbb2167 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AppLinksRestOperations.cs @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AppLinks + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of AppLinks for mocking. + protected AppLinks() + { + } + + /// Initializes a new instance of AppLinks. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal AppLinks(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, RequestContent content, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; + } + + internal HttpMessage CreateGetByResourceGroupRequest(Guid subscriptionId, string resourceGroupName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetBySubscriptionRequest(Guid subscriptionId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetBySubscriptionRequest(Uri nextPage, Guid subscriptionId, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AvailableVersionsRestOperations.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AvailableVersionsRestOperations.cs new file mode 100644 index 000000000000..d720a1d04cae --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/AvailableVersionsRestOperations.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class AvailableVersions + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of AvailableVersions for mocking. + protected AvailableVersions() + { + } + + /// Initializes a new instance of AvailableVersions. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal AvailableVersions(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetByLocationRequest(Guid subscriptionId, AzureLocation location, string kubernetesVersion, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/providers/Microsoft.AppLink/locations/", false); + uri.AppendPath(location.ToString(), true); + uri.AppendPath("/availableVersions", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + if (kubernetesVersion != null) + { + uri.AppendQuery("kubernetesVersion", kubernetesVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetByLocationRequest(Uri nextPage, Guid subscriptionId, AzureLocation location, string kubernetesVersion, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/UpgradeHistoriesRestOperations.cs b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/UpgradeHistoriesRestOperations.cs new file mode 100644 index 000000000000..9ab1b4ce95cf --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/src/Generated/RestOperations/UpgradeHistoriesRestOperations.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.AppLink +{ + internal partial class UpgradeHistories + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of UpgradeHistories for mocking. + protected UpgradeHistories() + { + } + + /// Initializes a new instance of UpgradeHistories. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal UpgradeHistories(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetByAppLinkMemberRequest(Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId.ToString(), true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AppLink/appLinks/", false); + uri.AppendPath(appLinkName, true); + uri.AppendPath("/appLinkMembers/", false); + uri.AppendPath(appLinkMemberName, true); + uri.AppendPath("/upgradeHistories", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateNextGetByAppLinkMemberRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string appLinkName, string appLinkMemberName, RequestContext context) + { + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) + { + uri.Reset(nextPage); + } + else + { + uri.Reset(new Uri(_endpoint, nextPage)); + } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; + } + } +} diff --git a/sdk/applink/Azure.ResourceManager.AppLink/tsp-location.yaml b/sdk/applink/Azure.ResourceManager.AppLink/tsp-location.yaml new file mode 100644 index 000000000000..575d88b73623 --- /dev/null +++ b/sdk/applink/Azure.ResourceManager.AppLink/tsp-location.yaml @@ -0,0 +1,6 @@ +directory: specification/applink/AppLink.Management +commit: 5bdcbdbbffe1d6417e9783f9cdf79432600e5a31 +repo: Azure/azure-rest-api-specs +additionalDirectories: + +emitterPackageJsonPath: eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json \ No newline at end of file