diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/ArmSelfHelpModelFactory.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/ArmSelfHelpModelFactory.cs index 5e655cf300fd..b0dfa5a6bf66 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/ArmSelfHelpModelFactory.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/ArmSelfHelpModelFactory.cs @@ -24,7 +24,8 @@ public static partial class ArmSelfHelpModelFactory [EditorBrowsable(EditorBrowsableState.Never)] public static SelfHelpSolutionMetadata SelfHelpSolutionMetadata(ResourceIdentifier id, string name, ResourceType resourceType, ResourceManager.Models.SystemData systemData, string solutionId, string solutionType, string description, IEnumerable> requiredParameterSets) { - return new SelfHelpSolutionMetadata(id, name, resourceType, systemData, default, serializedAdditionalRawData: null); + throw new NotImplementedException(); + //return new SelfHelpSolutionMetadata(id, name, resourceType, systemData, default, serializedAdditionalRawData: null); } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/Extensions/MockableSelfHelpArmClient.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/Extensions/MockableSelfHelpArmClient.cs index 955fa62674ee..7ef2acd6d1a7 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/Extensions/MockableSelfHelpArmClient.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/Extensions/MockableSelfHelpArmClient.cs @@ -13,11 +13,10 @@ namespace Azure.ResourceManager.SelfHelp.Mocking { public partial class MockableSelfHelpArmClient : ArmResource { - private ClientDiagnostics _discoverySolutionClientDiagnostics; - private DiscoverySolutionRestOperations _discoverySolutionRestClient; + //private ClientDiagnostics _discoverySolutionClientDiagnostics; + //private DiscoverySolution _discoverySolutionRestClient; - private ClientDiagnostics DiscoverySolutionClientDiagnostics => _discoverySolutionClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private DiscoverySolutionRestOperations DiscoverySolutionRestClient => _discoverySolutionRestClient ??= new DiscoverySolutionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + //private ClientDiagnostics DiscoverySolutionClientDiagnostics => _discoverySolutionClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ProviderConstants.DefaultProviderNamespace, Diagnostics); /// /// Lists the relevant Azure diagnostics and solutions using [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) AND resourceUri or resourceType.<br/> Discovery Solutions is the initial entry point within Help API, which identifies relevant Azure diagnostics and solutions. We will do our best to return the most effective solutions based on the type of inputs, in the request URL <br/><br/> Mandatory input : problemClassificationId (Use the [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) <br/>Optional input: resourceUri OR resource Type <br/><br/> <b>Note: </b> ‘requiredInputs’ from Discovery solutions response must be passed via ‘additionalParameters’ as an input to Diagnostics and Solutions API. @@ -43,11 +42,7 @@ public partial class MockableSelfHelpArmClient : ArmResource [EditorBrowsable(EditorBrowsableState.Never)] public virtual Pageable GetSelfHelpDiscoverySolutions(ResourceIdentifier scope, string filter = null, string skiptoken = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(scope, nameof(scope)); - - HttpMessage FirstPageRequest(int? pageSizeHint) => DiscoverySolutionRestClient.CreateDiscoverSolutionsRequest(filter, skiptoken); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DiscoverySolutionRestClient.CreateDiscoverSolutionsNextPageRequest(nextLink, filter, skiptoken); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => SelfHelpSolutionMetadata.DeserializeSelfHelpSolutionMetadata(e), DiscoverySolutionClientDiagnostics, Pipeline, "MockableSelfHelpArmClient.GetSelfHelpDiscoverySolutions", "value", "nextLink", cancellationToken); + throw new NotImplementedException(); } /// @@ -74,11 +69,7 @@ public virtual Pageable GetSelfHelpDiscoverySolutions( [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncPageable GetSelfHelpDiscoverySolutionsAsync(ResourceIdentifier scope, string filter = null, string skiptoken = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(scope, nameof(scope)); - - HttpMessage FirstPageRequest(int? pageSizeHint) => DiscoverySolutionRestClient.CreateDiscoverSolutionsRequest(filter, skiptoken); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DiscoverySolutionRestClient.CreateDiscoverSolutionsNextPageRequest(nextLink, filter, skiptoken); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => SelfHelpSolutionMetadata.DeserializeSelfHelpSolutionMetadata(e), DiscoverySolutionClientDiagnostics, Pipeline, "MockableSelfHelpArmClient.GetSelfHelpDiscoverySolutions", "value", "nextLink", cancellationToken); + throw new NotImplementedException(); } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/Models/SelfHelpSolutionMetadata.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/Models/SelfHelpSolutionMetadata.Serialization.cs index 3a7c87d7ddee..5487237eb3c8 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/Models/SelfHelpSolutionMetadata.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Custom/Models/SelfHelpSolutionMetadata.Serialization.cs @@ -164,7 +164,7 @@ internal static SelfHelpSolutionMetadata DeserializeSelfHelpSolutionMetadata(Jso List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(SolutionMetadataProperties.DeserializeSolutionMetadataProperties(item)); + array.Add(SolutionMetadataProperties.DeserializeSolutionMetadataProperties(item, default)); } solutions = array; continue; diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/ArmSelfHelpModelFactory.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/ArmSelfHelpModelFactory.cs index fd9f3a5b6905..07c95365e06b 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/ArmSelfHelpModelFactory.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/ArmSelfHelpModelFactory.cs @@ -8,86 +8,96 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure; using Azure.Core; using Azure.ResourceManager.Models; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - /// Model factory for models. + /// A factory class for creating instances of the models for mocking. public static partial class ArmSelfHelpModelFactory { - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + + /// 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. /// Global parameters is an optional map which can be used to add key and value to request body to improve the diagnostics results. /// SolutionIds that are needed to be invoked. /// Diagnostic Request Accepted time. /// Status of diagnostic provisioning. /// Array of Diagnostics. /// A new instance for mocking. - public static SelfHelpDiagnosticData SelfHelpDiagnosticData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary globalParameters = null, IEnumerable insights = null, DateTimeOffset? acceptedOn = null, SelfHelpProvisioningState? provisioningState = null, IEnumerable diagnostics = null) + public static SelfHelpDiagnosticData SelfHelpDiagnosticData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary globalParameters = default, IEnumerable insights = default, DateTimeOffset? acceptedOn = default, SelfHelpProvisioningState? provisioningState = default, IEnumerable diagnostics = default) { - globalParameters ??= new Dictionary(); - insights ??= new List(); - diagnostics ??= new List(); - return new SelfHelpDiagnosticData( id, name, resourceType, systemData, - globalParameters, - insights?.ToList(), - acceptedOn, - provisioningState, - diagnostics?.ToList(), - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + globalParameters is null && insights is null && acceptedOn is null && provisioningState is null && diagnostics is null ? default : new SelfHelpDiagnosticResourceProperties( + globalParameters, + (insights ?? new ChangeTrackingList()).ToList(), + acceptedOn, + provisioningState, + (diagnostics ?? new ChangeTrackingList()).ToList(), + null)); } - /// Initializes a new instance of . + /// Solution Invocation with additional params needed for invocation. + /// Solution Id to invoke. + /// Additional parameters required to invoke the solutionId. + /// A new instance for mocking. + public static SelfHelpDiagnosticInvocation SelfHelpDiagnosticInvocation(string solutionId = default, IDictionary additionalParameters = default) + { + additionalParameters ??= new ChangeTrackingDictionary(); + + return new SelfHelpDiagnosticInvocation(solutionId, additionalParameters, additionalBinaryDataProperties: null); + } + + /// Properties returned with in an insight. /// Solution Id. /// Denotes the status of the diagnostic resource. /// The problems (if any) detected by this insight. /// Error definition. /// A new instance for mocking. - public static SelfHelpDiagnosticInfo SelfHelpDiagnosticInfo(string solutionId = null, SelfHelpDiagnosticStatus? status = null, IEnumerable insights = null, SelfHelpError error = null) + public static SelfHelpDiagnosticInfo SelfHelpDiagnosticInfo(string solutionId = default, SelfHelpDiagnosticStatus? status = default, IEnumerable insights = default, SelfHelpError error = default) { - insights ??= new List(); + insights ??= new ChangeTrackingList(); - return new SelfHelpDiagnosticInfo(solutionId, status, insights?.ToList(), error, serializedAdditionalRawData: null); + return new SelfHelpDiagnosticInfo(solutionId, status, insights.ToList(), error, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Detailed insights(s) obtained via the invocation of an insight diagnostic. /// Article id. /// This insight's title. /// Detailed result content. /// Importance level of the insight. /// A new instance for mocking. - public static SelfHelpDiagnosticInsight SelfHelpDiagnosticInsight(string id = null, string title = null, string results = null, SelfHelpImportanceLevel? insightImportanceLevel = null) + public static SelfHelpDiagnosticInsight SelfHelpDiagnosticInsight(string id = default, string title = default, string results = default, SelfHelpImportanceLevel? insightImportanceLevel = default) { - return new SelfHelpDiagnosticInsight(id, title, results, insightImportanceLevel, serializedAdditionalRawData: null); + return new SelfHelpDiagnosticInsight(id, title, results, insightImportanceLevel, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Error definition. /// Service specific error code which serves as the substatus for the HTTP error code. /// Service specific error type which serves as additional context for the error herein. /// Description of the error. /// An array of additional nested error response info objects, as described by this contract. /// A new instance for mocking. - public static SelfHelpError SelfHelpError(string code = null, string errorType = null, string message = null, IEnumerable details = null) + public static SelfHelpError SelfHelpError(string code = default, string errorType = default, string message = default, IEnumerable details = default) { - details ??= new List(); + details ??= new ChangeTrackingList(); - return new SelfHelpError(code, errorType, message, details?.ToList(), serializedAdditionalRawData: null); + return new SelfHelpError(code, errorType, message, details.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// 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. /// Solution request trigger criteria. /// Client input parameters to run Solution. /// Solution Id to identify single solution. @@ -97,29 +107,27 @@ public static SelfHelpError SelfHelpError(string code = null, string errorType = /// Solution replacement maps. /// List of section object. /// A new instance for mocking. - public static SelfHelpSolutionData SelfHelpSolutionData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IEnumerable triggerCriteria = null, IDictionary parameters = null, string solutionId = null, SolutionProvisioningState? provisioningState = null, string title = null, string content = null, SolutionReplacementMaps replacementMaps = null, IEnumerable sections = null) + public static SelfHelpSolutionData SelfHelpSolutionData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IEnumerable triggerCriteria = default, IDictionary parameters = default, string solutionId = default, SolutionProvisioningState? provisioningState = default, string title = default, string content = default, SolutionReplacementMaps replacementMaps = default, IEnumerable sections = default) { - triggerCriteria ??= new List(); - parameters ??= new Dictionary(); - sections ??= new List(); - return new SelfHelpSolutionData( id, name, resourceType, systemData, - triggerCriteria?.ToList(), - parameters, - solutionId, - provisioningState, - title, - content, - replacementMaps, - sections?.ToList(), - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . + additionalBinaryDataProperties: null, + triggerCriteria is null && parameters is null && solutionId is null && provisioningState is null && title is null && content is null && replacementMaps is null && sections is null ? default : new SolutionResourceProperties( + (triggerCriteria ?? new ChangeTrackingList()).ToList(), + parameters, + solutionId, + provisioningState, + title, + content, + replacementMaps, + (sections ?? new ChangeTrackingList()).ToList(), + null)); + } + + /// Solution replacement maps. /// Solution AzureKB results. /// Solution diagnostics results. /// Solutions Troubleshooters. @@ -127,37 +135,37 @@ public static SelfHelpSolutionData SelfHelpSolutionData(ResourceIdentifier id = /// Video solutions, which have the power to engage the customer by stimulating their senses. /// Group of Videos. /// A new instance for mocking. - public static SolutionReplacementMaps SolutionReplacementMaps(IEnumerable webResults = null, IEnumerable diagnostics = null, IEnumerable troubleshooters = null, IEnumerable metricsBasedCharts = null, IEnumerable videos = null, IEnumerable videoGroups = null) + public static SolutionReplacementMaps SolutionReplacementMaps(IEnumerable webResults = default, IEnumerable diagnostics = default, IEnumerable troubleshooters = default, IEnumerable metricsBasedCharts = default, IEnumerable videos = default, IEnumerable videoGroups = default) { - webResults ??= new List(); - diagnostics ??= new List(); - troubleshooters ??= new List(); - metricsBasedCharts ??= new List(); - videos ??= new List(); - videoGroups ??= new List(); + webResults ??= new ChangeTrackingList(); + diagnostics ??= new ChangeTrackingList(); + troubleshooters ??= new ChangeTrackingList(); + metricsBasedCharts ??= new ChangeTrackingList(); + videos ??= new ChangeTrackingList(); + videoGroups ??= new ChangeTrackingList(); return new SolutionReplacementMaps( - webResults?.ToList(), - diagnostics?.ToList(), - troubleshooters?.ToList(), - metricsBasedCharts?.ToList(), - videos?.ToList(), - videoGroups?.ToList(), - serializedAdditionalRawData: null); + webResults.ToList(), + diagnostics.ToList(), + troubleshooters.ToList(), + metricsBasedCharts.ToList(), + videos.ToList(), + videoGroups.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// AzureKB web result. /// Place holder used in HTML Content replace control with the content. /// AzureKB search results. /// A new instance for mocking. - public static KBWebResult KBWebResult(string replacementKey = null, IEnumerable searchResults = null) + public static KBWebResult KBWebResult(string replacementKey = default, IEnumerable searchResults = default) { - searchResults ??= new List(); + searchResults ??= new ChangeTrackingList(); - return new KBWebResult(replacementKey, searchResults?.ToList(), serializedAdditionalRawData: null); + return new KBWebResult(replacementKey, searchResults.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Details of an AzureKB search result. /// Unique id of the result. /// Content of the search result. /// Title of the search result. @@ -167,7 +175,7 @@ public static KBWebResult KBWebResult(string replacementKey = null, IEnumerable< /// rank of the search result. /// Link to the document. /// A new instance for mocking. - public static KBSearchResult KBSearchResult(string solutionId = null, string content = null, string title = null, SelfHelpConfidence? confidence = null, string source = null, KBSearchResultType? resultType = null, int? rank = null, string link = null) + public static KBSearchResult KBSearchResult(string solutionId = default, string content = default, string title = default, SelfHelpConfidence? confidence = default, string source = default, KBSearchResultType? resultType = default, int? rank = default, string link = default) { return new KBSearchResult( solutionId, @@ -178,10 +186,10 @@ public static KBSearchResult KBSearchResult(string solutionId = null, string con resultType, rank, link, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Solutions Diagnostic. /// Solution Id to identify single Solutions Diagnostic. /// Denotes the status of the diagnostic resource. /// Details of the status. @@ -190,10 +198,10 @@ public static KBSearchResult KBSearchResult(string solutionId = null, string con /// Required parameters of this item. /// Diagnostic insights. /// A new instance for mocking. - public static SolutionsDiagnostic SolutionsDiagnostic(string solutionId = null, SelfHelpDiagnosticStatus? status = null, string statusDetails = null, string replacementKey = null, string estimatedCompletionTime = null, IEnumerable requiredParameters = null, IEnumerable insights = null) + public static SolutionsDiagnostic SolutionsDiagnostic(string solutionId = default, SelfHelpDiagnosticStatus? status = default, string statusDetails = default, string replacementKey = default, string estimatedCompletionTime = default, IEnumerable requiredParameters = default, IEnumerable insights = default) { - requiredParameters ??= new List(); - insights ??= new List(); + requiredParameters ??= new ChangeTrackingList(); + insights ??= new ChangeTrackingList(); return new SolutionsDiagnostic( solutionId, @@ -201,180 +209,150 @@ public static SolutionsDiagnostic SolutionsDiagnostic(string solutionId = null, statusDetails, replacementKey, estimatedCompletionTime, - requiredParameters?.ToList(), - insights?.ToList(), - serializedAdditionalRawData: null); + requiredParameters.ToList(), + insights.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Troubleshooters in Solutions. /// Solution Id to identify single Solutions Troubleshooter. /// Troubleshooter title. /// Troubleshooter summary. /// A new instance for mocking. - public static SolutionsTroubleshooters SolutionsTroubleshooters(string solutionId = null, string title = null, string summary = null) + public static SolutionsTroubleshooters SolutionsTroubleshooters(string solutionId = default, string title = default, string summary = default) { - return new SolutionsTroubleshooters(solutionId, title, summary, serializedAdditionalRawData: null); + return new SolutionsTroubleshooters(solutionId, title, summary, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . /// Chart name. /// Allowed values are Sum, Avg, Count, Min, Max. Default is Sum. /// Time span duration. /// Chart title. - /// Filter group. + /// List of filters. /// Place holder used in HTML Content replace control with the content. /// A new instance for mocking. - public static MetricsBasedChart MetricsBasedChart(string name = null, ChartAggregationType? aggregationType = null, TimeSpan? timeSpanDuration = null, string title = null, IEnumerable filter = null, string replacementKey = null) + public static MetricsBasedChart MetricsBasedChart(string name = default, ChartAggregationType? aggregationType = default, TimeSpan? timeSpanDuration = default, string title = default, IEnumerable filter = default, string replacementKey = default) { - filter ??= new List(); - return new MetricsBasedChart( name, aggregationType, timeSpanDuration, title, - filter != null ? new ChartFilterGroup(filter?.ToList(), serializedAdditionalRawData: null) : null, + filter is null ? default : new ChartFilterGroup((filter ?? new ChangeTrackingList()).ToList(), null), replacementKey, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Filter criterion. /// Filter name. /// Filter values. /// Filter operator. /// A new instance for mocking. - public static SelfHelpFilter SelfHelpFilter(string name = null, string values = null, string @operator = null) + public static SelfHelpFilter SelfHelpFilter(string name = default, string values = default, string @operator = default) { - return new SelfHelpFilter(name, values, @operator, serializedAdditionalRawData: null); + return new SelfHelpFilter(name, values, @operator, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Video detail. /// Link to the video. /// Title of the video. /// Place holder used in HTML Content replace control with the insight content. /// A new instance for mocking. - public static SelfHelpVideo SelfHelpVideo(string src = null, string title = null, string replacementKey = null) + public static SelfHelpVideo SelfHelpVideo(string src = default, string title = default, string replacementKey = default) { - return new SelfHelpVideo(src, title, serializedAdditionalRawData: null, replacementKey); + return new SelfHelpVideo(src, title, additionalBinaryDataProperties: null, replacementKey); } - /// Initializes a new instance of . + /// VideoGroup video detail. /// Link to the video. /// Title of the video. /// A new instance for mocking. - public static VideoGroupVideo VideoGroupVideo(string src = null, string title = null) + public static VideoGroupVideo VideoGroupVideo(string src = default, string title = default) { - return new VideoGroupVideo(src, title, serializedAdditionalRawData: null); + return new VideoGroupVideo(src, title, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Video group detail. /// List of videos will be shown to customers. /// Place holder used in HTML Content replace control with the insight content. /// A new instance for mocking. - public static VideoGroupDetail VideoGroupDetail(IEnumerable videos = null, string replacementKey = null) + public static VideoGroupDetail VideoGroupDetail(IEnumerable videos = default, string replacementKey = default) { - videos ??= new List(); + videos ??= new ChangeTrackingList(); - return new VideoGroupDetail(videos?.ToList(), replacementKey, serializedAdditionalRawData: null); + return new VideoGroupDetail(videos.ToList(), replacementKey, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Part of the solution and are dividers in the solution rendering. /// Solution sections title. /// Solution sections content. /// Solution replacement maps. /// A new instance for mocking. - public static SelfHelpSection SelfHelpSection(string title = null, string content = null, SolutionReplacementMaps replacementMaps = null) + public static SelfHelpSection SelfHelpSection(string title = default, string content = default, SolutionReplacementMaps replacementMaps = default) { - return new SelfHelpSection(title, content, replacementMaps, serializedAdditionalRawData: null); + return new SelfHelpSection(title, content, replacementMaps, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// Solution request trigger criteria. - /// Client input parameters to run Solution. - /// Solution Id to identify single solution. - /// Status of solution provisioning. - /// The title. - /// The HTML content that needs to be rendered and shown to customer. - /// Solution replacement maps. - /// List of section object. - /// A new instance for mocking. - public static SelfHelpSolutionPatch SelfHelpSolutionPatch(IEnumerable triggerCriteria = null, IDictionary parameters = null, string solutionId = null, SolutionProvisioningState? provisioningState = null, string title = null, string content = null, SolutionReplacementMaps replacementMaps = null, IEnumerable sections = null) + /// Solution WarmUpRequest body. + /// Dictionary of <string>. + /// A new instance for mocking. + public static SolutionWarmUpContent SolutionWarmUpContent(IDictionary parameters = default) { - triggerCriteria ??= new List(); - parameters ??= new Dictionary(); - sections ??= new List(); + parameters ??= new ChangeTrackingDictionary(); - return new SelfHelpSolutionPatch( - triggerCriteria?.ToList(), - parameters, - solutionId, - provisioningState, - title, - content, - replacementMaps, - sections?.ToList(), - serializedAdditionalRawData: null); + return new SolutionWarmUpContent(parameters, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// 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. /// Solution Id to identify single Simplified Solution. /// Client input parameters to run Simplified Solutions. /// The title. /// Additional parameter response for Simplified Solutions. /// The HTML content that needs to be rendered and shown to customer. /// Status of Simplified Solution provisioning. - /// A new instance for mocking. - public static SelfHelpSimplifiedSolutionData SelfHelpSimplifiedSolutionData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string solutionId = null, IDictionary parameters = null, string title = null, IReadOnlyDictionary appendix = null, string content = null, SolutionProvisioningState? provisioningState = null) + /// A new instance for mocking. + public static SelfHelpSimplifiedSolutionsData SelfHelpSimplifiedSolutionsData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, string solutionId = default, IDictionary parameters = default, string title = default, IReadOnlyDictionary appendix = default, string content = default, SolutionProvisioningState? provisioningState = default) { - parameters ??= new Dictionary(); - appendix ??= new Dictionary(); - - return new SelfHelpSimplifiedSolutionData( + return new SelfHelpSimplifiedSolutionsData( id, name, resourceType, systemData, - solutionId, - parameters, - title, - appendix, - content, - provisioningState, - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + additionalBinaryDataProperties: null, + solutionId is null && parameters is null && title is null && appendix is null && content is null && provisioningState is null ? default : new SimplifiedSolutionsResourceProperties( + solutionId, + parameters, + title, + appendix, + content, + provisioningState, + null)); + } + + /// 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. /// Solution Id to identify single troubleshooter. /// Client input parameters to run Troubleshooter Resource. /// Status of troubleshooter provisioning. /// List of step object. /// A new instance for mocking. - public static SelfHelpTroubleshooterData SelfHelpTroubleshooterData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string solutionId = null, IDictionary parameters = null, TroubleshooterProvisioningState? provisioningState = null, IEnumerable steps = null) + public static SelfHelpTroubleshooterData SelfHelpTroubleshooterData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, string solutionId = default, IDictionary parameters = default, TroubleshooterProvisioningState? provisioningState = default, IEnumerable steps = default) { - parameters ??= new Dictionary(); - steps ??= new List(); - return new SelfHelpTroubleshooterData( id, name, resourceType, systemData, - solutionId, - parameters, - provisioningState, - steps?.ToList(), - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + solutionId is null && parameters is null && provisioningState is null && steps is null ? default : new TroubleshooterInstanceProperties(solutionId, parameters, provisioningState, (steps ?? new ChangeTrackingList()).ToList(), null)); } - /// Initializes a new instance of . + /// Troubleshooter step. /// Unique step id. /// Step title. /// Step description. @@ -388,10 +366,10 @@ public static SelfHelpTroubleshooterData SelfHelpTroubleshooterData(ResourceIden /// /// The error detail. /// A new instance for mocking. - public static SelfHelpStep SelfHelpStep(string id = null, string title = null, string description = null, string guidance = null, TroubleshooterExecutionStatus? executionStatus = null, string executionStatusDescription = null, SelfHelpType? stepType = null, bool? isLastStep = null, IEnumerable inputs = null, AutomatedCheckResult automatedCheckResults = null, IEnumerable insights = null, ResponseError error = null) + public static SelfHelpStep SelfHelpStep(string id = default, string title = default, string description = default, string guidance = default, TroubleshooterExecutionStatus? executionStatus = default, string executionStatusDescription = default, SelfHelpType? stepType = default, bool? isLastStep = default, IEnumerable inputs = default, AutomatedCheckResult automatedCheckResults = default, IEnumerable insights = default, ResponseError error = default) { - inputs ??= new List(); - insights ??= new List(); + inputs ??= new ChangeTrackingList(); + insights ??= new ChangeTrackingList(); return new SelfHelpStep( id, @@ -402,14 +380,14 @@ public static SelfHelpStep SelfHelpStep(string id = null, string title = null, s executionStatusDescription, stepType, isLastStep, - inputs?.ToList(), + inputs.ToList(), automatedCheckResults, - insights?.ToList(), + insights.ToList(), error, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Details of step input. /// Use Index as QuestionId. /// Type of Question. /// Question title. @@ -421,9 +399,9 @@ public static SelfHelpStep SelfHelpStep(string id = null, string title = null, s /// Troubleshooter step input response validation properties. /// /// A new instance for mocking. - public static TroubleshooterStepInput TroubleshooterStepInput(string questionId = null, TroubleshooterQuestionType? questionType = null, string questionTitle = null, string questionContent = null, TroubleshooterQuestionContentType? questionContentType = null, string responseHint = null, string recommendedOption = null, string selectedOptionValue = null, ResponseValidationProperties responseValidationProperties = null, IEnumerable responseOptions = null) + public static TroubleshooterStepInput TroubleshooterStepInput(string questionId = default, TroubleshooterQuestionType? questionType = default, string questionTitle = default, string questionContent = default, TroubleshooterQuestionContentType? questionContentType = default, string responseHint = default, string recommendedOption = default, string selectedOptionValue = default, ResponseValidationProperties responseValidationProperties = default, IEnumerable responseOptions = default) { - responseOptions ??= new List(); + responseOptions ??= new ChangeTrackingList(); return new TroubleshooterStepInput( questionId, @@ -435,18 +413,18 @@ public static TroubleshooterStepInput TroubleshooterStepInput(string questionId recommendedOption, selectedOptionValue, responseValidationProperties, - responseOptions?.ToList(), - serializedAdditionalRawData: null); + responseOptions.ToList(), + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Troubleshooter step input response validation properties. /// Regex used for the input validation. /// Validation scope. /// Default True. /// Validation Error Message. /// Max text input (open Ended Text). /// A new instance for mocking. - public static ResponseValidationProperties ResponseValidationProperties(string regex = null, TroubleshooterValidationScope? validationScope = null, bool? isRequired = null, string validationErrorMessage = null, long? maxLength = null) + public static ResponseValidationProperties ResponseValidationProperties(string regex = default, TroubleshooterValidationScope? validationScope = default, bool? isRequired = default, string validationErrorMessage = default, long? maxLength = default) { return new ResponseValidationProperties( regex, @@ -454,53 +432,73 @@ public static ResponseValidationProperties ResponseValidationProperties(string r isRequired, validationErrorMessage, maxLength, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The status of the resource. /// Unique string. /// Option description. /// A new instance for mocking. - public static ResponseConfig ResponseConfig(string key = null, string value = null) + public static ResponseConfig ResponseConfig(string key = default, string value = default) { - return new ResponseConfig(key, value, serializedAdditionalRawData: null); + return new ResponseConfig(key, value, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Only for AutomatedStep type. /// Version for automated check result. /// Status for automated check result. /// Insight Article Content. /// Type of Result. /// A new instance for mocking. - public static AutomatedCheckResult AutomatedCheckResult(string version = null, string status = null, string result = null, AutomatedCheckResultType? resultType = null) + public static AutomatedCheckResult AutomatedCheckResult(string version = default, string status = default, string result = default, AutomatedCheckResultType? resultType = default) { - return new AutomatedCheckResult(version, status, result, resultType, serializedAdditionalRawData: null); + return new AutomatedCheckResult(version, status, result, resultType, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Troubleshooter ContinueRequest body. + /// Unique id of the result. + /// + /// A new instance for mocking. + public static TroubleshooterContinueContent TroubleshooterContinueContent(string stepId = default, IEnumerable responses = default) + { + responses ??= new ChangeTrackingList(); + + return new TroubleshooterContinueContent(stepId, responses.ToList(), additionalBinaryDataProperties: null); + } + + /// Troubleshooter restart response. /// Updated TroubleshooterResource Name . /// A new instance for mocking. - public static RestartTroubleshooterResult RestartTroubleshooterResult(string troubleshooterResourceName = null) + public static RestartTroubleshooterResult RestartTroubleshooterResult(string troubleshooterResourceName = default) { - return new RestartTroubleshooterResult(troubleshooterResourceName, serializedAdditionalRawData: null); + return new RestartTroubleshooterResult(troubleshooterResourceName, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Discover NLP request. /// Natural language description of the issue. /// ARM resource Id of the resource that is having the issue. Only applicable for Discovery Solution NLP Subscription Scope. /// ARM service Id of the service that is having the issue. For more information on service Id see https://learn.microsoft.com/rest/api/support/services/list?tabs=HTTP. /// Additional information in the form of a string. /// A new instance for mocking. - public static DiscoveryNlpContent DiscoveryNlpContent(string issueSummary = null, string resourceId = null, string serviceId = null, string additionalContext = null) + public static DiscoveryNlpContent DiscoveryNlpContent(string issueSummary = default, string resourceId = default, string serviceId = default, string additionalContext = default) { - return new DiscoveryNlpContent(issueSummary, resourceId, serviceId, additionalContext, serializedAdditionalRawData: null); + return new DiscoveryNlpContent(issueSummary, resourceId, serviceId, additionalContext, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// Successfully fetched list of solution metadata. + /// The list of solution metadata. + /// A new instance for mocking. + public static DiscoveryNlpResult DiscoveryNlpResult(IEnumerable value = default) + { + value ??= new ChangeTrackingList(); + + return new DiscoveryNlpResult(value.ToList(), additionalBinaryDataProperties: null); + } + + /// 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. /// Title of the problem classification. /// Description of the problem classification. /// Id of the service (https://learn.microsoft.com/en-us/rest/api/support/services?view=rest-support-2020-04-01) that may be used to create a support ticket. @@ -508,130 +506,115 @@ public static DiscoveryNlpContent DiscoveryNlpContent(string issueSummary = null /// The list of solution metadata. /// The set of services that are most likely related to the request. If relatedServices is included in the response then solutions may not be discovered until the client calls a second time specifying one of the service Ids in the relatedServices object. /// A new instance for mocking. - public static SolutionNlpMetadata SolutionNlpMetadata(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string problemTitle = null, string problemDescription = null, string serviceId = null, string problemClassificationId = null, IEnumerable solutions = null, IEnumerable relatedServices = null) + public static SolutionNlpMetadata SolutionNlpMetadata(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, string problemTitle = default, string problemDescription = default, string serviceId = default, string problemClassificationId = default, IEnumerable solutions = default, IEnumerable relatedServices = default) { - solutions ??= new List(); - relatedServices ??= new List(); - return new SolutionNlpMetadata( id, name, resourceType, systemData, - problemTitle, - problemDescription, - serviceId, - problemClassificationId, - solutions?.ToList(), - relatedServices?.ToList(), - serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . + additionalBinaryDataProperties: null, + problemTitle is null && problemDescription is null && serviceId is null && problemClassificationId is null && solutions is null && relatedServices is null ? default : new SelfHelpNlpSolutions( + problemTitle, + problemDescription, + serviceId, + problemClassificationId, + (solutions ?? new ChangeTrackingList()).ToList(), + (relatedServices ?? new ChangeTrackingList()).ToList(), + null)); + } + + /// Metadata Properties. /// Solution Id. /// Solution Type. /// A detailed description of solution. /// Required parameters for invoking this particular solution. /// A new instance for mocking. - public static SolutionMetadataProperties SolutionMetadataProperties(string solutionId = null, SelfHelpSolutionType? solutionType = null, string description = null, IEnumerable requiredInputs = null) + public static SolutionMetadataProperties SolutionMetadataProperties(string solutionId = default, SelfHelpSolutionType? solutionType = default, string description = default, IEnumerable requiredInputs = default) { - requiredInputs ??= new List(); + requiredInputs ??= new ChangeTrackingList(); - return new SolutionMetadataProperties(solutionId, solutionType, description, requiredInputs?.ToList(), serializedAdditionalRawData: null); + return new SolutionMetadataProperties(solutionId, solutionType, description, requiredInputs.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Service Classification result object. /// Azure resource Id of the service. /// Localized name of the azure service. /// List of applicable ARM resource types for this service. /// A new instance for mocking. - public static ClassificationService ClassificationService(ResourceIdentifier serviceId = null, string displayName = null, IEnumerable resourceTypes = null) + public static ClassificationService ClassificationService(ResourceIdentifier serviceId = default, string displayName = default, IEnumerable resourceTypes = default) { - resourceTypes ??= new List(); + resourceTypes ??= new ChangeTrackingList(); - return new ClassificationService(serviceId, displayName, resourceTypes?.ToList(), serializedAdditionalRawData: null); + return new ClassificationService(serviceId, displayName, resourceTypes.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// 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. /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. /// The title. /// The HTML content that needs to be rendered and shown to customer. /// Solution replacement maps. /// List of section object. - /// A new instance for mocking. - public static SelfHelpSolutionResult SelfHelpSolutionResult(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string solutionId = null, string title = null, string content = null, ReplacementMapsResult replacementMaps = null, IEnumerable sections = null) + /// A new instance for mocking. + public static SelfHelpSolutionResultData SelfHelpSolutionResultData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, string solutionId = default, string title = default, string content = default, ReplacementMapsResult replacementMaps = default, IEnumerable sections = default) { - sections ??= new List(); - - return new SelfHelpSolutionResult( + return new SelfHelpSolutionResultData( id, name, resourceType, systemData, - solutionId, - title, - content, - replacementMaps, - sections?.ToList(), - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + solutionId is null && title is null && content is null && replacementMaps is null && sections is null ? default : new SolutionsResourcePropertiesSelfHelp( + solutionId, + title, + content, + replacementMaps, + (sections ?? new ChangeTrackingList()).ToList(), + null)); } - /// Initializes a new instance of . + /// Solution replacement maps. /// Solution AzureKB results. /// Video solutions, which have the power to engage the customer by stimulating their senses. /// Group of Videos. /// A new instance for mocking. - public static ReplacementMapsResult ReplacementMapsResult(IEnumerable webResults = null, IEnumerable videos = null, IEnumerable videoGroups = null) + public static ReplacementMapsResult ReplacementMapsResult(IEnumerable webResults = default, IEnumerable videos = default, IEnumerable videoGroups = default) { - webResults ??= new List(); - videos ??= new List(); - videoGroups ??= new List(); + webResults ??= new ChangeTrackingList(); + videos ??= new ChangeTrackingList(); + videoGroups ??= new ChangeTrackingList(); - return new ReplacementMapsResult(webResults?.ToList(), videos?.ToList(), videoGroups?.ToList(), serializedAdditionalRawData: null); + return new ReplacementMapsResult(webResults.ToList(), videos.ToList(), videoGroups.ToList(), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// Part of the solution and are dividers in the solution rendering. /// Solution sections title. /// Solution sections content. /// Solution replacement maps. /// A new instance for mocking. - public static SolutionSection SolutionSection(string title = null, string content = null, ReplacementMapsResult replacementMaps = null) - { - return new SolutionSection(title, content, replacementMaps, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Returns true or false depending on the availability of the name. - /// Reason for why value is not available. This field is returned if nameAvailable is false. - /// Gets an error message explaining the 'reason' value with more details. This field is returned iif nameAvailable is false. - /// A new instance for mocking. - public static SelfHelpNameAvailabilityResult SelfHelpNameAvailabilityResult(bool? isNameAvailable = null, string reason = null, string message = null) + public static SolutionSection SolutionSection(string title = default, string content = default, ReplacementMapsResult replacementMaps = default) { - return new SelfHelpNameAvailabilityResult(isNameAvailable, reason, message, serializedAdditionalRawData: null); + return new SolutionSection(title, content, replacementMaps, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// 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. /// List of metadata. /// A new instance for mocking. - public static SelfHelpSolutionMetadata SelfHelpSolutionMetadata(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IEnumerable solutions = null) + public static SelfHelpSolutionMetadata SelfHelpSolutionMetadata(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IEnumerable solutions = default) { - solutions ??= new List(); - return new SelfHelpSolutionMetadata( id, name, resourceType, systemData, - solutions?.ToList(), - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + solutions is null ? default : new SelfHelpSolutions((solutions ?? new ChangeTrackingList()).ToList(), null)); } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/CollectionResults/DiscoverySolutionDiscoverSolutionsAsyncCollectionResultOfT.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/CollectionResults/DiscoverySolutionDiscoverSolutionsAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..7fa88b3dc98e --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/CollectionResults/DiscoverySolutionDiscoverSolutionsAsyncCollectionResultOfT.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.SelfHelp.Models; + +namespace Azure.ResourceManager.SelfHelp +{ + internal partial class DiscoverySolutionDiscoverSolutionsAsyncCollectionResultOfT : AsyncPageable + { + private readonly DiscoverySolution _client; + private readonly string _filter; + private readonly string _skiptoken; + private readonly RequestContext _context; + + /// Initializes a new instance of DiscoverySolutionDiscoverSolutionsAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The DiscoverySolution client used to send requests. + /// 'ProblemClassificationId' is a mandatory filter to get solutions ids. It also supports optional 'ResourceType' and 'SolutionType' filters. The [$filter](https://learn.microsoft.com/en-us/odata/webapi/first-odata-api#filter) supports only 'and', 'or' and 'eq' operators. Example: $filter=ProblemClassificationId eq '1ddda5b4-cf6c-4d4f-91ad-bc38ab0e811e'. + /// Skiptoken is only used if a previous operation returned a partial result. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public DiscoverySolutionDiscoverSolutionsAsyncCollectionResultOfT(DiscoverySolution client, string filter, string skiptoken, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _filter = filter; + _skiptoken = skiptoken; + _context = context; + } + + /// Gets the pages of DiscoverySolutionDiscoverSolutionsAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of DiscoverySolutionDiscoverSolutionsAsyncCollectionResultOfT 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; + } + SelfHelpDiscoverySolutionResult result = SelfHelpDiscoverySolutionResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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.CreateNextDiscoverSolutionsRequest(nextLink, _filter, _skiptoken, _context) : _client.CreateDiscoverSolutionsRequest(_filter, _skiptoken, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableSelfHelpTenantResource.DiscoverSolutions"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/CollectionResults/DiscoverySolutionDiscoverSolutionsCollectionResultOfT.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/CollectionResults/DiscoverySolutionDiscoverSolutionsCollectionResultOfT.cs new file mode 100644 index 000000000000..1134c0b2cdf6 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/CollectionResults/DiscoverySolutionDiscoverSolutionsCollectionResultOfT.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.SelfHelp.Models; + +namespace Azure.ResourceManager.SelfHelp +{ + internal partial class DiscoverySolutionDiscoverSolutionsCollectionResultOfT : Pageable + { + private readonly DiscoverySolution _client; + private readonly string _filter; + private readonly string _skiptoken; + private readonly RequestContext _context; + + /// Initializes a new instance of DiscoverySolutionDiscoverSolutionsCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The DiscoverySolution client used to send requests. + /// 'ProblemClassificationId' is a mandatory filter to get solutions ids. It also supports optional 'ResourceType' and 'SolutionType' filters. The [$filter](https://learn.microsoft.com/en-us/odata/webapi/first-odata-api#filter) supports only 'and', 'or' and 'eq' operators. Example: $filter=ProblemClassificationId eq '1ddda5b4-cf6c-4d4f-91ad-bc38ab0e811e'. + /// Skiptoken is only used if a previous operation returned a partial result. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public DiscoverySolutionDiscoverSolutionsCollectionResultOfT(DiscoverySolution client, string filter, string skiptoken, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _filter = filter; + _skiptoken = skiptoken; + _context = context; + } + + /// Gets the pages of DiscoverySolutionDiscoverSolutionsCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of DiscoverySolutionDiscoverSolutionsCollectionResultOfT 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; + } + SelfHelpDiscoverySolutionResult result = SelfHelpDiscoverySolutionResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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.CreateNextDiscoverSolutionsRequest(nextLink, _filter, _skiptoken, _context) : _client.CreateDiscoverSolutionsRequest(_filter, _skiptoken, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableSelfHelpTenantResource.DiscoverSolutions"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpArmClient.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpArmClient.cs index b8db8e300bd0..3907431fa420 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpArmClient.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpArmClient.cs @@ -8,454 +8,215 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.SelfHelp.Models; +using Azure.ResourceManager; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Mocking { - /// A class to add extension methods to ArmClient. + /// A class to add extension methods to . public partial class MockableSelfHelpArmClient : ArmResource { - private ClientDiagnostics _checkNameAvailabilityClientDiagnostics; - private CheckNameAvailabilityRestOperations _checkNameAvailabilityRestClient; - - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableSelfHelpArmClient for mocking. protected MockableSelfHelpArmClient() { } - /// Initializes a new instance of the class. + /// 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 MockableSelfHelpArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) { } - internal MockableSelfHelpArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) - { - } - - private ClientDiagnostics CheckNameAvailabilityClientDiagnostics => _checkNameAvailabilityClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private CheckNameAvailabilityRestOperations CheckNameAvailabilityRestClient => _checkNameAvailabilityRestClient ??= new CheckNameAvailabilityRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); - - private string GetApiVersionOrNull(ResourceType resourceType) + /// 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 SelfHelpDiagnosticResource GetSelfHelpDiagnosticResource(ResourceIdentifier id) { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; + SelfHelpDiagnosticResource.ValidateResourceId(id); + return new SelfHelpDiagnosticResource(Client, id); } - /// Gets a collection of SelfHelpDiagnosticResources in the ArmClient. - /// The scope that the resource will apply against. - /// An object representing collection of SelfHelpDiagnosticResources and their operations over a SelfHelpDiagnosticResource. + /// Gets a collection of objects within the specified scope. + /// The scope of the resource collection to get. + /// Returns a collection of objects. public virtual SelfHelpDiagnosticCollection GetSelfHelpDiagnostics(ResourceIdentifier scope) { return new SelfHelpDiagnosticCollection(Client, scope); } - /// - /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} - /// - /// - /// Operation Id - /// DiagnosticResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The scope that the resource will apply against. + /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. + /// The scope of the resource collection to get. /// Unique resource name for insight resources. /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual async Task> GetSelfHelpDiagnosticAsync(ResourceIdentifier scope, string diagnosticsResourceName, CancellationToken cancellationToken = default) + public virtual Response GetSelfHelpDiagnostic(ResourceIdentifier scope, string diagnosticsResourceName, CancellationToken cancellationToken = default) { - return await GetSelfHelpDiagnostics(scope).GetAsync(diagnosticsResourceName, cancellationToken).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); + + return GetSelfHelpDiagnostics(scope).Get(diagnosticsResourceName, cancellationToken); } - /// - /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} - /// - /// - /// Operation Id - /// DiagnosticResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The scope that the resource will apply against. + /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. + /// The scope of the resource collection to get. /// Unique resource name for insight resources. /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual Response GetSelfHelpDiagnostic(ResourceIdentifier scope, string diagnosticsResourceName, CancellationToken cancellationToken = default) + public virtual async Task> GetSelfHelpDiagnosticAsync(ResourceIdentifier scope, string diagnosticsResourceName, CancellationToken cancellationToken = default) { - return GetSelfHelpDiagnostics(scope).Get(diagnosticsResourceName, cancellationToken); + Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); + + return await GetSelfHelpDiagnostics(scope).GetAsync(diagnosticsResourceName, cancellationToken).ConfigureAwait(false); } - /// Gets a collection of SelfHelpSolutionResources in the ArmClient. - /// The scope that the resource will apply against. - /// An object representing collection of SelfHelpSolutionResources and their operations over a SelfHelpSolutionResource. + /// 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 SelfHelpSolutionResource GetSelfHelpSolutionResource(ResourceIdentifier id) + { + SelfHelpSolutionResource.ValidateResourceId(id); + return new SelfHelpSolutionResource(Client, id); + } + + /// Gets a collection of objects within the specified scope. + /// The scope of the resource collection to get. + /// Returns a collection of objects. public virtual SelfHelpSolutionCollection GetSelfHelpSolutions(ResourceIdentifier scope) { return new SelfHelpSolutionCollection(Client, scope); } - /// - /// Get the solution using the applicable solutionResourceName while creating the solution. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} - /// - /// - /// Operation Id - /// SolutionResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The scope that the resource will apply against. + /// Get the solution using the applicable solutionResourceName while creating the solution. + /// The scope of the resource collection to get. /// Solution resource Name. /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual async Task> GetSelfHelpSolutionAsync(ResourceIdentifier scope, string solutionResourceName, CancellationToken cancellationToken = default) + public virtual Response GetSelfHelpSolution(ResourceIdentifier scope, string solutionResourceName, CancellationToken cancellationToken = default) { - return await GetSelfHelpSolutions(scope).GetAsync(solutionResourceName, cancellationToken).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); + + return GetSelfHelpSolutions(scope).Get(solutionResourceName, cancellationToken); } - /// - /// Get the solution using the applicable solutionResourceName while creating the solution. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} - /// - /// - /// Operation Id - /// SolutionResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The scope that the resource will apply against. + /// Get the solution using the applicable solutionResourceName while creating the solution. + /// The scope of the resource collection to get. /// Solution resource Name. /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual Response GetSelfHelpSolution(ResourceIdentifier scope, string solutionResourceName, CancellationToken cancellationToken = default) + public virtual async Task> GetSelfHelpSolutionAsync(ResourceIdentifier scope, string solutionResourceName, CancellationToken cancellationToken = default) { - return GetSelfHelpSolutions(scope).Get(solutionResourceName, cancellationToken); + Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); + + return await GetSelfHelpSolutions(scope).GetAsync(solutionResourceName, cancellationToken).ConfigureAwait(false); + } + + /// 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 SelfHelpSimplifiedSolutionsResource GetSelfHelpSimplifiedSolutionsResource(ResourceIdentifier id) + { + SelfHelpSimplifiedSolutionsResource.ValidateResourceId(id); + return new SelfHelpSimplifiedSolutionsResource(Client, id); } - /// Gets a collection of SelfHelpSimplifiedSolutionResources in the ArmClient. - /// The scope that the resource will apply against. - /// An object representing collection of SelfHelpSimplifiedSolutionResources and their operations over a SelfHelpSimplifiedSolutionResource. - public virtual SelfHelpSimplifiedSolutionCollection GetSelfHelpSimplifiedSolutions(ResourceIdentifier scope) + /// Gets a collection of objects within the specified scope. + /// The scope of the resource collection to get. + /// Returns a collection of objects. + public virtual SelfHelpSimplifiedSolutionsCollection GetSelfHelpSimplifiedSolutions(ResourceIdentifier scope) { - return new SelfHelpSimplifiedSolutionCollection(Client, scope); + return new SelfHelpSimplifiedSolutionsCollection(Client, scope); } - /// - /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The scope that the resource will apply against. + /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. + /// The scope of the resource collection to get. /// Simplified Solutions Resource Name. /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual async Task> GetSelfHelpSimplifiedSolutionAsync(ResourceIdentifier scope, string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) + public virtual Response GetSelfHelpSimplifiedSolutions(ResourceIdentifier scope, string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) { - return await GetSelfHelpSimplifiedSolutions(scope).GetAsync(simplifiedSolutionsResourceName, cancellationToken).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); + + return GetSelfHelpSimplifiedSolutions(scope).Get(simplifiedSolutionsResourceName, cancellationToken); } - /// - /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The scope that the resource will apply against. + /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. + /// The scope of the resource collection to get. /// Simplified Solutions Resource Name. /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual Response GetSelfHelpSimplifiedSolution(ResourceIdentifier scope, string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) + public virtual async Task> GetSelfHelpSimplifiedSolutionsAsync(ResourceIdentifier scope, string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) { - return GetSelfHelpSimplifiedSolutions(scope).Get(simplifiedSolutionsResourceName, cancellationToken); + Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); + + return await GetSelfHelpSimplifiedSolutions(scope).GetAsync(simplifiedSolutionsResourceName, cancellationToken).ConfigureAwait(false); } - /// Gets a collection of SelfHelpTroubleshooterResources in the ArmClient. - /// The scope that the resource will apply against. - /// An object representing collection of SelfHelpTroubleshooterResources and their operations over a SelfHelpTroubleshooterResource. + /// 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 SelfHelpTroubleshooterResource GetSelfHelpTroubleshooterResource(ResourceIdentifier id) + { + SelfHelpTroubleshooterResource.ValidateResourceId(id); + return new SelfHelpTroubleshooterResource(Client, id); + } + + /// Gets a collection of objects within the specified scope. + /// The scope of the resource collection to get. + /// Returns a collection of objects. public virtual SelfHelpTroubleshooterCollection GetSelfHelpTroubleshooters(ResourceIdentifier scope) { return new SelfHelpTroubleshooterCollection(Client, scope); } - /// - /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} - /// - /// - /// Operation Id - /// TroubleshooterResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The scope that the resource will apply against. + /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. + /// The scope of the resource collection to get. /// Troubleshooter resource Name. /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual async Task> GetSelfHelpTroubleshooterAsync(ResourceIdentifier scope, string troubleshooterName, CancellationToken cancellationToken = default) + public virtual Response GetSelfHelpTroubleshooter(ResourceIdentifier scope, string troubleshooterName, CancellationToken cancellationToken = default) { - return await GetSelfHelpTroubleshooters(scope).GetAsync(troubleshooterName, cancellationToken).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); + + return GetSelfHelpTroubleshooters(scope).Get(troubleshooterName, cancellationToken); } - /// - /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} - /// - /// - /// Operation Id - /// TroubleshooterResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The scope that the resource will apply against. + /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. + /// The scope of the resource collection to get. /// Troubleshooter resource Name. /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual Response GetSelfHelpTroubleshooter(ResourceIdentifier scope, string troubleshooterName, CancellationToken cancellationToken = default) - { - return GetSelfHelpTroubleshooters(scope).Get(troubleshooterName, cancellationToken); - } - - /// - /// This API is used to check the uniqueness of a resource name used for a diagnostic, troubleshooter or solutions - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/checkNameAvailability - /// - /// - /// Operation Id - /// CheckNameAvailabilityOperationGroup_CheckSelfHelpNameAvailability - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// - /// The scope that the resource will apply against. - /// The required parameters for availability check. - /// The cancellation token to use. - /// is null. - public virtual async Task> CheckSelfHelpNameAvailabilityAsync(ResourceIdentifier scope, SelfHelpNameAvailabilityContent content = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - - using var scope0 = CheckNameAvailabilityClientDiagnostics.CreateScope("MockableSelfHelpArmClient.CheckSelfHelpNameAvailability"); - scope0.Start(); - try - { - var response = await CheckNameAvailabilityRestClient.CheckSelfHelpNameAvailabilityAsync(scope, content, cancellationToken).ConfigureAwait(false); - return response; - } - catch (Exception e) - { - scope0.Failed(e); - throw; - } - } - - /// - /// This API is used to check the uniqueness of a resource name used for a diagnostic, troubleshooter or solutions - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/checkNameAvailability - /// - /// - /// Operation Id - /// CheckNameAvailabilityOperationGroup_CheckSelfHelpNameAvailability - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// - /// The scope that the resource will apply against. - /// The required parameters for availability check. - /// The cancellation token to use. - /// is null. - public virtual Response CheckSelfHelpNameAvailability(ResourceIdentifier scope, SelfHelpNameAvailabilityContent content = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - - using var scope0 = CheckNameAvailabilityClientDiagnostics.CreateScope("MockableSelfHelpArmClient.CheckSelfHelpNameAvailability"); - scope0.Start(); - try - { - var response = CheckNameAvailabilityRestClient.CheckSelfHelpNameAvailability(scope, content, cancellationToken); - return response; - } - catch (Exception e) - { - scope0.Failed(e); - throw; - } - } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// The resource ID of the resource to get. - /// Returns a object. - public virtual SelfHelpDiagnosticResource GetSelfHelpDiagnosticResource(ResourceIdentifier id) - { - SelfHelpDiagnosticResource.ValidateResourceId(id); - return new SelfHelpDiagnosticResource(Client, id); - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// The resource ID of the resource to get. - /// Returns a object. - public virtual SelfHelpSolutionResource GetSelfHelpSolutionResource(ResourceIdentifier id) + public virtual async Task> GetSelfHelpTroubleshooterAsync(ResourceIdentifier scope, string troubleshooterName, CancellationToken cancellationToken = default) { - SelfHelpSolutionResource.ValidateResourceId(id); - return new SelfHelpSolutionResource(Client, id); - } + Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// The resource ID of the resource to get. - /// Returns a object. - public virtual SelfHelpSimplifiedSolutionResource GetSelfHelpSimplifiedSolutionResource(ResourceIdentifier id) - { - SelfHelpSimplifiedSolutionResource.ValidateResourceId(id); - return new SelfHelpSimplifiedSolutionResource(Client, id); + return await GetSelfHelpTroubleshooters(scope).GetAsync(troubleshooterName, cancellationToken).ConfigureAwait(false); } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// + /// 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 SelfHelpTroubleshooterResource GetSelfHelpTroubleshooterResource(ResourceIdentifier id) + /// Returns a object. + public virtual SelfHelpSolutionResultResource GetSelfHelpSolutionResultResource(ResourceIdentifier id) { - SelfHelpTroubleshooterResource.ValidateResourceId(id); - return new SelfHelpTroubleshooterResource(Client, id); + SelfHelpSolutionResultResource.ValidateResourceId(id); + return new SelfHelpSolutionResultResource(Client, id); } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpSubscriptionResource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpSubscriptionResource.cs index 93585d37fbee..0e9fbeb51f4e 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpSubscriptionResource.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpSubscriptionResource.cs @@ -5,91 +5,129 @@ #nullable disable +using System; using System.Threading; -using Autorest.CSharp.Core; +using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.SelfHelp; using Azure.ResourceManager.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp.Mocking { - /// A class to add extension methods to SubscriptionResource. + /// A class to add extension methods to . public partial class MockableSelfHelpSubscriptionResource : ArmResource { private ClientDiagnostics _discoverySolutionNLPClientDiagnostics; - private DiscoverySolutionNLPRestOperations _discoverySolutionNLPRestClient; + private DiscoverySolutionNLP _discoverySolutionNLPRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableSelfHelpSubscriptionResource for mocking. protected MockableSelfHelpSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 MockableSelfHelpSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private ClientDiagnostics DiscoverySolutionNLPClientDiagnostics => _discoverySolutionNLPClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private DiscoverySolutionNLPRestOperations DiscoverySolutionNLPRestClient => _discoverySolutionNLPRestClient ??= new DiscoverySolutionNLPRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics DiscoverySolutionNLPClientDiagnostics => _discoverySolutionNLPClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SelfHelp.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private DiscoverySolutionNLP DiscoverySolutionNLPRestClient => _discoverySolutionNLPRestClient ??= new DiscoverySolutionNLP(DiscoverySolutionNLPClientDiagnostics, Pipeline, Endpoint, "2024-03-01-preview"); /// /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary and subscription. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Help/discoverSolutions + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Help/discoverSolutions. /// /// - /// Operation Id - /// DiscoverySolutionNLPOperationGroup_DiscoverSolutionsNlp + /// Operation Id. + /// DiscoverySolutionNLPOperationGroup_DiscoverSolutionsBySubscription. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// - /// The request body. + /// The request body. /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable DiscoverSolutionsNlpAsync(DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) + public virtual async Task> DiscoverSolutionsNlpAsync(DiscoveryNlpContent discoverSolutionRequest = default, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => DiscoverySolutionNLPRestClient.CreateDiscoverSolutionsNlpRequest(Id.SubscriptionId, content); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => SolutionNlpMetadata.DeserializeSolutionNlpMetadata(e), DiscoverySolutionNLPClientDiagnostics, Pipeline, "MockableSelfHelpSubscriptionResource.DiscoverSolutionsNlp", "value", null, cancellationToken); + using DiagnosticScope scope = DiscoverySolutionNLPClientDiagnostics.CreateScope("MockableSelfHelpSubscriptionResource.DiscoverSolutionsNlp"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = DiscoverySolutionNLPRestClient.CreateDiscoverSolutionsNlpRequest(Guid.Parse(Id.SubscriptionId), DiscoveryNlpContent.ToRequestContent(discoverSolutionRequest), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DiscoveryNlpResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } /// /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary and subscription. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Help/discoverSolutions + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Help/discoverSolutions. /// /// - /// Operation Id - /// DiscoverySolutionNLPOperationGroup_DiscoverSolutionsNlp + /// Operation Id. + /// DiscoverySolutionNLPOperationGroup_DiscoverSolutionsBySubscription. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// - /// The request body. + /// The request body. /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable DiscoverSolutionsNlp(DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) + public virtual Response DiscoverSolutionsNlp(DiscoveryNlpContent discoverSolutionRequest = default, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => DiscoverySolutionNLPRestClient.CreateDiscoverSolutionsNlpRequest(Id.SubscriptionId, content); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => SolutionNlpMetadata.DeserializeSolutionNlpMetadata(e), DiscoverySolutionNLPClientDiagnostics, Pipeline, "MockableSelfHelpSubscriptionResource.DiscoverSolutionsNlp", "value", null, cancellationToken); + using DiagnosticScope scope = DiscoverySolutionNLPClientDiagnostics.CreateScope("MockableSelfHelpSubscriptionResource.DiscoverSolutionsNlp"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = DiscoverySolutionNLPRestClient.CreateDiscoverSolutionsNlpRequest(Guid.Parse(Id.SubscriptionId), DiscoveryNlpContent.ToRequestContent(discoverSolutionRequest), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DiscoveryNlpResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpTenantResource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpTenantResource.cs index 01d79921d536..539acd98d3fc 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpTenantResource.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/MockableSelfHelpTenantResource.cs @@ -8,130 +8,87 @@ using System; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.SelfHelp; using Azure.ResourceManager.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp.Mocking { - /// A class to add extension methods to TenantResource. + /// A class to add extension methods to . public partial class MockableSelfHelpTenantResource : ArmResource { private ClientDiagnostics _discoverySolutionNLPOperationGroupClientDiagnostics; - private DiscoverySolutionNLPOperationGroupRestOperations _discoverySolutionNLPOperationGroupRestClient; - private ClientDiagnostics _solutionSelfHelpClientDiagnostics; - private SolutionSelfHelpRestOperations _solutionSelfHelpRestClient; + private DiscoverySolutionNLPOperationGroup _discoverySolutionNLPOperationGroupRestClient; private ClientDiagnostics _discoverySolutionClientDiagnostics; - private DiscoverySolutionRestOperations _discoverySolutionRestClient; + private DiscoverySolution _discoverySolutionRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableSelfHelpTenantResource for mocking. protected MockableSelfHelpTenantResource() { } - /// Initializes a new instance of the class. + /// 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 MockableSelfHelpTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private ClientDiagnostics DiscoverySolutionNLPOperationGroupClientDiagnostics => _discoverySolutionNLPOperationGroupClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private DiscoverySolutionNLPOperationGroupRestOperations DiscoverySolutionNLPOperationGroupRestClient => _discoverySolutionNLPOperationGroupRestClient ??= new DiscoverySolutionNLPOperationGroupRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); - private ClientDiagnostics SolutionSelfHelpClientDiagnostics => _solutionSelfHelpClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private SolutionSelfHelpRestOperations SolutionSelfHelpRestClient => _solutionSelfHelpRestClient ??= new SolutionSelfHelpRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); - private ClientDiagnostics DiscoverySolutionClientDiagnostics => _discoverySolutionClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private DiscoverySolutionRestOperations DiscoverySolutionRestClient => _discoverySolutionRestClient ??= new DiscoverySolutionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics DiscoverySolutionNLPOperationGroupClientDiagnostics => _discoverySolutionNLPOperationGroupClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SelfHelp.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private DiscoverySolutionNLPOperationGroup DiscoverySolutionNLPOperationGroupRestClient => _discoverySolutionNLPOperationGroupRestClient ??= new DiscoverySolutionNLPOperationGroup(DiscoverySolutionNLPOperationGroupClientDiagnostics, Pipeline, Endpoint, "2024-03-01-preview"); - /// - /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary. - /// - /// - /// Request Path - /// /providers/Microsoft.Help/discoverSolutions - /// - /// - /// Operation Id - /// DiscoverySolutionNLPOperationGroup_DiscoverSolutionsNlp - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// - /// The request body. - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable DiscoverSolutionsNlpAsync(DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => DiscoverySolutionNLPOperationGroupRestClient.CreateDiscoverSolutionsNlpRequest(content); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => SolutionNlpMetadata.DeserializeSolutionNlpMetadata(e), DiscoverySolutionNLPOperationGroupClientDiagnostics, Pipeline, "MockableSelfHelpTenantResource.DiscoverSolutionsNlp", "value", null, cancellationToken); - } + private ClientDiagnostics DiscoverySolutionClientDiagnostics => _discoverySolutionClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SelfHelp.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - /// - /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary. - /// - /// - /// Request Path - /// /providers/Microsoft.Help/discoverSolutions - /// - /// - /// Operation Id - /// DiscoverySolutionNLPOperationGroup_DiscoverSolutionsNlp - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// - /// The request body. - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable DiscoverSolutionsNlp(DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) + private DiscoverySolution DiscoverySolutionRestClient => _discoverySolutionRestClient ??= new DiscoverySolution(DiscoverySolutionClientDiagnostics, Pipeline, Endpoint, "2024-03-01-preview"); + + /// Gets a collection of SelfHelpSolutionResults in the . + /// An object representing collection of SelfHelpSolutionResults and their operations over a SelfHelpSolutionResultResource. + public virtual SelfHelpSolutionResultCollection GetSelfHelpSolutionResults() { - HttpMessage FirstPageRequest(int? pageSizeHint) => DiscoverySolutionNLPOperationGroupRestClient.CreateDiscoverSolutionsNlpRequest(content); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => SolutionNlpMetadata.DeserializeSolutionNlpMetadata(e), DiscoverySolutionNLPOperationGroupClientDiagnostics, Pipeline, "MockableSelfHelpTenantResource.DiscoverSolutionsNlp", "value", null, cancellationToken); + return GetCachedClient(client => new SelfHelpSolutionResultCollection(client, Id)); } /// - /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. + /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary. /// /// - /// Request Path - /// /providers/Microsoft.Help/selfHelp/{solutionId} + /// Request Path. + /// /providers/Microsoft.Help/discoverSolutions. /// /// - /// Operation Id - /// SolutionResourceSelfHelp_GetSelfHelpSolutionById + /// Operation Id. + /// DiscoverySolutionNLPOperationGroup_DiscoverSolutions. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// - /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + /// The request body. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetSelfHelpSolutionByIdAsync(string solutionId, CancellationToken cancellationToken = default) + public virtual async Task> DiscoverSolutionsNlpAsync(DiscoveryNlpContent discoverSolutionRequest = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(solutionId, nameof(solutionId)); - - using var scope = SolutionSelfHelpClientDiagnostics.CreateScope("MockableSelfHelpTenantResource.GetSelfHelpSolutionById"); + using DiagnosticScope scope = DiscoverySolutionNLPOperationGroupClientDiagnostics.CreateScope("MockableSelfHelpTenantResource.DiscoverSolutionsNlp"); scope.Start(); try { - var response = await SolutionSelfHelpRestClient.GetSelfHelpSolutionByIdAsync(solutionId, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = DiscoverySolutionNLPOperationGroupRestClient.CreateDiscoverSolutionsNlpRequest(DiscoveryNlpContent.ToRequestContent(discoverSolutionRequest), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DiscoveryNlpResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -142,35 +99,41 @@ public virtual async Task> GetSelfHelpSolutionB } /// - /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. + /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary. /// /// - /// Request Path - /// /providers/Microsoft.Help/selfHelp/{solutionId} + /// Request Path. + /// /providers/Microsoft.Help/discoverSolutions. /// /// - /// Operation Id - /// SolutionResourceSelfHelp_GetSelfHelpSolutionById + /// Operation Id. + /// DiscoverySolutionNLPOperationGroup_DiscoverSolutions. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// - /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + /// The request body. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response GetSelfHelpSolutionById(string solutionId, CancellationToken cancellationToken = default) + public virtual Response DiscoverSolutionsNlp(DiscoveryNlpContent discoverSolutionRequest = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(solutionId, nameof(solutionId)); - - using var scope = SolutionSelfHelpClientDiagnostics.CreateScope("MockableSelfHelpTenantResource.GetSelfHelpSolutionById"); + using DiagnosticScope scope = DiscoverySolutionNLPOperationGroupClientDiagnostics.CreateScope("MockableSelfHelpTenantResource.DiscoverSolutionsNlp"); scope.Start(); try { - var response = SolutionSelfHelpRestClient.GetSelfHelpSolutionById(solutionId, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = DiscoverySolutionNLPOperationGroupRestClient.CreateDiscoverSolutionsNlpRequest(DiscoveryNlpContent.ToRequestContent(discoverSolutionRequest), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DiscoveryNlpResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -184,44 +147,46 @@ public virtual Response GetSelfHelpSolutionById(string s /// Lists the relevant Azure Diagnostics, Solutions and Troubleshooters using [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) AND resourceUri or resourceType.<br/> Discovery Solutions is the initial entry point within Help API, which identifies relevant Azure diagnostics and solutions. <br/><br/> Required Input : problemClassificationId (Use the [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) <br/>Optional input: resourceUri OR resource Type <br/><br/> <b>Note: </b> ‘requiredInputs’ from Discovery solutions response must be passed via ‘additionalParameters’ as an input to Diagnostics and Solutions API. /// /// - /// Request Path - /// /providers/Microsoft.Help/discoverySolutions + /// Request Path. + /// /providers/Microsoft.Help/discoverySolutions. /// /// - /// Operation Id - /// DiscoverySolutionOperationGroup_DiscoverSolutions + /// Operation Id. + /// DiscoverySolutionOperationGroup_List. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// 'ProblemClassificationId' is a mandatory filter to get solutions ids. It also supports optional 'ResourceType' and 'SolutionType' filters. The [$filter](https://learn.microsoft.com/en-us/odata/webapi/first-odata-api#filter) supports only 'and', 'or' and 'eq' operators. Example: $filter=ProblemClassificationId eq '1ddda5b4-cf6c-4d4f-91ad-bc38ab0e811e'. /// Skiptoken is only used if a previous operation returned a partial result. /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable DiscoverSolutionsAsync(string filter = null, string skiptoken = null, CancellationToken cancellationToken = default) + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable DiscoverSolutionsAsync(string filter = default, string skiptoken = default, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => DiscoverySolutionRestClient.CreateDiscoverSolutionsRequest(filter, skiptoken); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DiscoverySolutionRestClient.CreateDiscoverSolutionsNextPageRequest(nextLink, filter, skiptoken); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => SelfHelpSolutionMetadata.DeserializeSelfHelpSolutionMetadata(e), DiscoverySolutionClientDiagnostics, Pipeline, "MockableSelfHelpTenantResource.DiscoverSolutions", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new DiscoverySolutionDiscoverSolutionsAsyncCollectionResultOfT(DiscoverySolutionRestClient, filter, skiptoken, context); } /// /// Lists the relevant Azure Diagnostics, Solutions and Troubleshooters using [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) AND resourceUri or resourceType.<br/> Discovery Solutions is the initial entry point within Help API, which identifies relevant Azure diagnostics and solutions. <br/><br/> Required Input : problemClassificationId (Use the [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) <br/>Optional input: resourceUri OR resource Type <br/><br/> <b>Note: </b> ‘requiredInputs’ from Discovery solutions response must be passed via ‘additionalParameters’ as an input to Diagnostics and Solutions API. /// /// - /// Request Path - /// /providers/Microsoft.Help/discoverySolutions + /// Request Path. + /// /providers/Microsoft.Help/discoverySolutions. /// /// - /// Operation Id - /// DiscoverySolutionOperationGroup_DiscoverSolutions + /// Operation Id. + /// DiscoverySolutionOperationGroup_List. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// @@ -229,11 +194,13 @@ public virtual AsyncPageable DiscoverSolutionsAsync(st /// Skiptoken is only used if a previous operation returned a partial result. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable DiscoverSolutions(string filter = null, string skiptoken = null, CancellationToken cancellationToken = default) + public virtual Pageable DiscoverSolutions(string filter = default, string skiptoken = default, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => DiscoverySolutionRestClient.CreateDiscoverSolutionsRequest(filter, skiptoken); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DiscoverySolutionRestClient.CreateDiscoverSolutionsNextPageRequest(nextLink, filter, skiptoken); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => SelfHelpSolutionMetadata.DeserializeSelfHelpSolutionMetadata(e), DiscoverySolutionClientDiagnostics, Pipeline, "MockableSelfHelpTenantResource.DiscoverSolutions", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new DiscoverySolutionDiscoverSolutionsCollectionResultOfT(DiscoverySolutionRestClient, filter, skiptoken, context); } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/SelfHelpExtensions.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/SelfHelpExtensions.cs index 915909a8aec7..f95b254ba98a 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/SelfHelpExtensions.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Extensions/SelfHelpExtensions.cs @@ -8,7 +8,9 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Resources; using Azure.ResourceManager.SelfHelp.Mocking; using Azure.ResourceManager.SelfHelp.Models; @@ -18,109 +20,72 @@ namespace Azure.ResourceManager.SelfHelp /// A class to add extension methods to Azure.ResourceManager.SelfHelp. public static partial class SelfHelpExtensions { + /// private static MockableSelfHelpArmClient GetMockableSelfHelpArmClient(ArmClient client) { - return client.GetCachedClient(client0 => new MockableSelfHelpArmClient(client0)); + return client.GetCachedClient(client0 => new MockableSelfHelpArmClient(client0, ResourceIdentifier.Root)); } - private static MockableSelfHelpSubscriptionResource GetMockableSelfHelpSubscriptionResource(ArmResource resource) + /// + private static MockableSelfHelpSubscriptionResource GetMockableSelfHelpSubscriptionResource(SubscriptionResource subscriptionResource) { - return resource.GetCachedClient(client => new MockableSelfHelpSubscriptionResource(client, resource.Id)); + return subscriptionResource.GetCachedClient(client => new MockableSelfHelpSubscriptionResource(client, subscriptionResource.Id)); } - private static MockableSelfHelpTenantResource GetMockableSelfHelpTenantResource(ArmResource resource) + /// + private static MockableSelfHelpTenantResource GetMockableSelfHelpTenantResource(TenantResource tenantResource) { - return resource.GetCachedClient(client => new MockableSelfHelpTenantResource(client, resource.Id)); + return tenantResource.GetCachedClient(client => new MockableSelfHelpTenantResource(client, tenantResource.Id)); } /// - /// Gets a collection of SelfHelpDiagnosticResources in the ArmClient. + /// 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. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. + /// The the method will execute against. + /// The resource ID of the resource to get. /// is null. - /// An object representing collection of SelfHelpDiagnosticResources and their operations over a SelfHelpDiagnosticResource. - public static SelfHelpDiagnosticCollection GetSelfHelpDiagnostics(this ArmClient client, ResourceIdentifier scope) + /// Returns a object. + public static SelfHelpDiagnosticResource GetSelfHelpDiagnosticResource(this ArmClient client, ResourceIdentifier id) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSelfHelpArmClient(client).GetSelfHelpDiagnostics(scope); + return GetMockableSelfHelpArmClient(client).GetSelfHelpDiagnosticResource(id); } /// - /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} - /// - /// - /// Operation Id - /// DiagnosticResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// + /// Gets a collection of objects within the specified scope. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// Unique resource name for insight resources. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public static async Task> GetSelfHelpDiagnosticAsync(this ArmClient client, ResourceIdentifier scope, string diagnosticsResourceName, CancellationToken cancellationToken = default) + /// The the method will execute against. + /// The scope of the resource collection to get. + /// is null. + /// Returns a collection of objects. + public static SelfHelpDiagnosticCollection GetSelfHelpDiagnostics(this ArmClient client, ResourceIdentifier scope) { Argument.AssertNotNull(client, nameof(client)); - return await GetMockableSelfHelpArmClient(client).GetSelfHelpDiagnosticAsync(scope, diagnosticsResourceName, cancellationToken).ConfigureAwait(false); + return GetMockableSelfHelpArmClient(client).GetSelfHelpDiagnostics(scope); } /// /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} - /// - /// - /// Operation Id - /// DiagnosticResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. + /// The the method will execute against. + /// The scope of the resource collection to get. /// Unique resource name for insight resources. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] public static Response GetSelfHelpDiagnostic(this ArmClient client, ResourceIdentifier scope, string diagnosticsResourceName, CancellationToken cancellationToken = default) { @@ -130,661 +95,374 @@ public static Response GetSelfHelpDiagnostic(this Ar } /// - /// Gets a collection of SelfHelpSolutionResources in the ArmClient. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// is null. - /// An object representing collection of SelfHelpSolutionResources and their operations over a SelfHelpSolutionResource. - public static SelfHelpSolutionCollection GetSelfHelpSolutions(this ArmClient client, ResourceIdentifier scope) - { - Argument.AssertNotNull(client, nameof(client)); - - return GetMockableSelfHelpArmClient(client).GetSelfHelpSolutions(scope); - } - - /// - /// Get the solution using the applicable solutionResourceName while creating the solution. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} - /// - /// - /// Operation Id - /// SolutionResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// + /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// Solution resource Name. + /// The the method will execute against. + /// The scope of the resource collection to get. + /// Unique resource name for insight resources. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] - public static async Task> GetSelfHelpSolutionAsync(this ArmClient client, ResourceIdentifier scope, string solutionResourceName, CancellationToken cancellationToken = default) + public static async Task> GetSelfHelpDiagnosticAsync(this ArmClient client, ResourceIdentifier scope, string diagnosticsResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(client, nameof(client)); - return await GetMockableSelfHelpArmClient(client).GetSelfHelpSolutionAsync(scope, solutionResourceName, cancellationToken).ConfigureAwait(false); + return await GetMockableSelfHelpArmClient(client).GetSelfHelpDiagnosticAsync(scope, diagnosticsResourceName, cancellationToken).ConfigureAwait(false); } /// - /// Get the solution using the applicable solutionResourceName while creating the solution. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Operation Id - /// SolutionResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// Solution resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public static Response GetSelfHelpSolution(this ArmClient client, ResourceIdentifier scope, string solutionResourceName, CancellationToken cancellationToken = default) + /// The the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static SelfHelpSolutionResource GetSelfHelpSolutionResource(this ArmClient client, ResourceIdentifier id) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSelfHelpArmClient(client).GetSelfHelpSolution(scope, solutionResourceName, cancellationToken); + return GetMockableSelfHelpArmClient(client).GetSelfHelpSolutionResource(id); } /// - /// Gets a collection of SelfHelpSimplifiedSolutionResources in the ArmClient. + /// Gets a collection of objects within the specified scope. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. + /// The the method will execute against. + /// The scope of the resource collection to get. /// is null. - /// An object representing collection of SelfHelpSimplifiedSolutionResources and their operations over a SelfHelpSimplifiedSolutionResource. - public static SelfHelpSimplifiedSolutionCollection GetSelfHelpSimplifiedSolutions(this ArmClient client, ResourceIdentifier scope) + /// Returns a collection of objects. + public static SelfHelpSolutionCollection GetSelfHelpSolutions(this ArmClient client, ResourceIdentifier scope) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSelfHelpArmClient(client).GetSelfHelpSimplifiedSolutions(scope); + return GetMockableSelfHelpArmClient(client).GetSelfHelpSolutions(scope); } /// - /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// + /// Get the solution using the applicable solutionResourceName while creating the solution. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// Simplified Solutions Resource Name. + /// The the method will execute against. + /// The scope of the resource collection to get. + /// Solution resource Name. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] - public static async Task> GetSelfHelpSimplifiedSolutionAsync(this ArmClient client, ResourceIdentifier scope, string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) + public static Response GetSelfHelpSolution(this ArmClient client, ResourceIdentifier scope, string solutionResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(client, nameof(client)); - return await GetMockableSelfHelpArmClient(client).GetSelfHelpSimplifiedSolutionAsync(scope, simplifiedSolutionsResourceName, cancellationToken).ConfigureAwait(false); + return GetMockableSelfHelpArmClient(client).GetSelfHelpSolution(scope, solutionResourceName, cancellationToken); } /// - /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// + /// Get the solution using the applicable solutionResourceName while creating the solution. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// Simplified Solutions Resource Name. + /// The the method will execute against. + /// The scope of the resource collection to get. + /// Solution resource Name. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] - public static Response GetSelfHelpSimplifiedSolution(this ArmClient client, ResourceIdentifier scope, string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) + public static async Task> GetSelfHelpSolutionAsync(this ArmClient client, ResourceIdentifier scope, string solutionResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSelfHelpArmClient(client).GetSelfHelpSimplifiedSolution(scope, simplifiedSolutionsResourceName, cancellationToken); + return await GetMockableSelfHelpArmClient(client).GetSelfHelpSolutionAsync(scope, solutionResourceName, cancellationToken).ConfigureAwait(false); } /// - /// Gets a collection of SelfHelpTroubleshooterResources in the ArmClient. + /// 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. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. + /// The the method will execute against. + /// The resource ID of the resource to get. /// is null. - /// An object representing collection of SelfHelpTroubleshooterResources and their operations over a SelfHelpTroubleshooterResource. - public static SelfHelpTroubleshooterCollection GetSelfHelpTroubleshooters(this ArmClient client, ResourceIdentifier scope) + /// Returns a object. + public static SelfHelpSimplifiedSolutionsResource GetSelfHelpSimplifiedSolutionsResource(this ArmClient client, ResourceIdentifier id) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSelfHelpArmClient(client).GetSelfHelpTroubleshooters(scope); + return GetMockableSelfHelpArmClient(client).GetSelfHelpSimplifiedSolutionsResource(id); } /// - /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} - /// - /// - /// Operation Id - /// TroubleshooterResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// + /// Gets a collection of objects within the specified scope. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// Troubleshooter resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public static async Task> GetSelfHelpTroubleshooterAsync(this ArmClient client, ResourceIdentifier scope, string troubleshooterName, CancellationToken cancellationToken = default) + /// The the method will execute against. + /// The scope of the resource collection to get. + /// is null. + /// Returns a collection of objects. + public static SelfHelpSimplifiedSolutionsCollection GetSelfHelpSimplifiedSolutions(this ArmClient client, ResourceIdentifier scope) { Argument.AssertNotNull(client, nameof(client)); - return await GetMockableSelfHelpArmClient(client).GetSelfHelpTroubleshooterAsync(scope, troubleshooterName, cancellationToken).ConfigureAwait(false); + return GetMockableSelfHelpArmClient(client).GetSelfHelpSimplifiedSolutions(scope); } /// - /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} - /// - /// - /// Operation Id - /// TroubleshooterResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// + /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// Troubleshooter resource Name. + /// The the method will execute against. + /// The scope of the resource collection to get. + /// Simplified Solutions Resource Name. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] - public static Response GetSelfHelpTroubleshooter(this ArmClient client, ResourceIdentifier scope, string troubleshooterName, CancellationToken cancellationToken = default) + public static Response GetSelfHelpSimplifiedSolutions(this ArmClient client, ResourceIdentifier scope, string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSelfHelpArmClient(client).GetSelfHelpTroubleshooter(scope, troubleshooterName, cancellationToken); + return GetMockableSelfHelpArmClient(client).GetSelfHelpSimplifiedSolutions(scope, simplifiedSolutionsResourceName, cancellationToken); } /// - /// This API is used to check the uniqueness of a resource name used for a diagnostic, troubleshooter or solutions - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/checkNameAvailability - /// - /// - /// Operation Id - /// CheckNameAvailabilityOperationGroup_CheckSelfHelpNameAvailability - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// + /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// The required parameters for availability check. + /// The the method will execute against. + /// The scope of the resource collection to get. + /// Simplified Solutions Resource Name. /// The cancellation token to use. /// is null. - public static async Task> CheckSelfHelpNameAvailabilityAsync(this ArmClient client, ResourceIdentifier scope, SelfHelpNameAvailabilityContent content = null, CancellationToken cancellationToken = default) + [ForwardsClientCalls] + public static async Task> GetSelfHelpSimplifiedSolutionsAsync(this ArmClient client, ResourceIdentifier scope, string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(client, nameof(client)); - return await GetMockableSelfHelpArmClient(client).CheckSelfHelpNameAvailabilityAsync(scope, content, cancellationToken).ConfigureAwait(false); + return await GetMockableSelfHelpArmClient(client).GetSelfHelpSimplifiedSolutionsAsync(scope, simplifiedSolutionsResourceName, cancellationToken).ConfigureAwait(false); } /// - /// This API is used to check the uniqueness of a resource name used for a diagnostic, troubleshooter or solutions - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/checkNameAvailability - /// - /// - /// Operation Id - /// CheckNameAvailabilityOperationGroup_CheckSelfHelpNameAvailability - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// The required parameters for availability check. - /// The cancellation token to use. + /// The the method will execute against. + /// The resource ID of the resource to get. /// is null. - public static Response CheckSelfHelpNameAvailability(this ArmClient client, ResourceIdentifier scope, SelfHelpNameAvailabilityContent content = null, CancellationToken cancellationToken = default) + /// Returns a object. + public static SelfHelpTroubleshooterResource GetSelfHelpTroubleshooterResource(this ArmClient client, ResourceIdentifier id) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSelfHelpArmClient(client).CheckSelfHelpNameAvailability(scope, content, cancellationToken); + return GetMockableSelfHelpArmClient(client).GetSelfHelpTroubleshooterResource(id); } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// Gets a collection of objects within the specified scope. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The resource ID of the resource to get. + /// The the method will execute against. + /// The scope of the resource collection to get. /// is null. - /// Returns a object. - public static SelfHelpDiagnosticResource GetSelfHelpDiagnosticResource(this ArmClient client, ResourceIdentifier id) + /// Returns a collection of objects. + public static SelfHelpTroubleshooterCollection GetSelfHelpTroubleshooters(this ArmClient client, ResourceIdentifier scope) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSelfHelpArmClient(client).GetSelfHelpDiagnosticResource(id); + return GetMockableSelfHelpArmClient(client).GetSelfHelpTroubleshooters(scope); } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The resource ID of the resource to get. + /// The the method will execute against. + /// The scope of the resource collection to get. + /// Troubleshooter resource Name. + /// The cancellation token to use. /// is null. - /// Returns a object. - public static SelfHelpSolutionResource GetSelfHelpSolutionResource(this ArmClient client, ResourceIdentifier id) + [ForwardsClientCalls] + public static Response GetSelfHelpTroubleshooter(this ArmClient client, ResourceIdentifier scope, string troubleshooterName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSelfHelpArmClient(client).GetSelfHelpSolutionResource(id); + return GetMockableSelfHelpArmClient(client).GetSelfHelpTroubleshooter(scope, troubleshooterName, cancellationToken); } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The resource ID of the resource to get. + /// The the method will execute against. + /// The scope of the resource collection to get. + /// Troubleshooter resource Name. + /// The cancellation token to use. /// is null. - /// Returns a object. - public static SelfHelpSimplifiedSolutionResource GetSelfHelpSimplifiedSolutionResource(this ArmClient client, ResourceIdentifier id) + [ForwardsClientCalls] + public static async Task> GetSelfHelpTroubleshooterAsync(this ArmClient client, ResourceIdentifier scope, string troubleshooterName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSelfHelpArmClient(client).GetSelfHelpSimplifiedSolutionResource(id); + return await GetMockableSelfHelpArmClient(client).GetSelfHelpTroubleshooterAsync(scope, troubleshooterName, cancellationToken).ConfigureAwait(false); } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// 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. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. - /// Returns a object. - public static SelfHelpTroubleshooterResource GetSelfHelpTroubleshooterResource(this ArmClient client, ResourceIdentifier id) + /// Returns a object. + public static SelfHelpSolutionResultResource GetSelfHelpSolutionResultResource(this ArmClient client, ResourceIdentifier id) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSelfHelpArmClient(client).GetSelfHelpTroubleshooterResource(id); + return GetMockableSelfHelpArmClient(client).GetSelfHelpSolutionResultResource(id); } /// /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary and subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Help/discoverSolutions - /// - /// - /// Operation Id - /// DiscoverySolutionNLPOperationGroup_DiscoverSolutionsNlp - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The request body. + /// The the method will execute against. + /// The request body. /// The cancellation token to use. /// is null. - /// An async collection of that may take multiple service requests to iterate over. - public static AsyncPageable DiscoverSolutionsNlpAsync(this SubscriptionResource subscriptionResource, DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) + public static async Task> DiscoverSolutionsNlpAsync(this SubscriptionResource subscriptionResource, DiscoveryNlpContent discoverSolutionRequest = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); - return GetMockableSelfHelpSubscriptionResource(subscriptionResource).DiscoverSolutionsNlpAsync(content, cancellationToken); + return await GetMockableSelfHelpSubscriptionResource(subscriptionResource).DiscoverSolutionsNlpAsync(discoverSolutionRequest, cancellationToken).ConfigureAwait(false); } /// /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary and subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Help/discoverSolutions - /// - /// - /// Operation Id - /// DiscoverySolutionNLPOperationGroup_DiscoverSolutionsNlp - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The request body. + /// The the method will execute against. + /// The request body. /// The cancellation token to use. /// is null. - /// A collection of that may take multiple service requests to iterate over. - public static Pageable DiscoverSolutionsNlp(this SubscriptionResource subscriptionResource, DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) + public static Response DiscoverSolutionsNlp(this SubscriptionResource subscriptionResource, DiscoveryNlpContent discoverSolutionRequest = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); - return GetMockableSelfHelpSubscriptionResource(subscriptionResource).DiscoverSolutionsNlp(content, cancellationToken); + return GetMockableSelfHelpSubscriptionResource(subscriptionResource).DiscoverSolutionsNlp(discoverSolutionRequest, cancellationToken); } /// - /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary. - /// - /// - /// Request Path - /// /providers/Microsoft.Help/discoverSolutions - /// + /// Gets a collection of SelfHelpSolutionResults in the /// - /// Operation Id - /// DiscoverySolutionNLPOperationGroup_DiscoverSolutionsNlp - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The request body. - /// The cancellation token to use. + /// The the method will execute against. /// is null. - /// An async collection of that may take multiple service requests to iterate over. - public static AsyncPageable DiscoverSolutionsNlpAsync(this TenantResource tenantResource, DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) + /// An object representing collection of SelfHelpSolutionResults and their operations over a SelfHelpSolutionResultResource. + public static SelfHelpSolutionResultCollection GetSelfHelpSolutionResults(this TenantResource tenantResource) { Argument.AssertNotNull(tenantResource, nameof(tenantResource)); - return GetMockableSelfHelpTenantResource(tenantResource).DiscoverSolutionsNlpAsync(content, cancellationToken); + return GetMockableSelfHelpTenantResource(tenantResource).GetSelfHelpSolutionResults(); } /// /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary. - /// - /// - /// Request Path - /// /providers/Microsoft.Help/discoverSolutions - /// - /// - /// Operation Id - /// DiscoverySolutionNLPOperationGroup_DiscoverSolutionsNlp - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The request body. + /// The the method will execute against. + /// The request body. /// The cancellation token to use. /// is null. - /// A collection of that may take multiple service requests to iterate over. - public static Pageable DiscoverSolutionsNlp(this TenantResource tenantResource, DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(tenantResource, nameof(tenantResource)); - - return GetMockableSelfHelpTenantResource(tenantResource).DiscoverSolutionsNlp(content, cancellationToken); - } - - /// - /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. - /// - /// - /// Request Path - /// /providers/Microsoft.Help/selfHelp/{solutionId} - /// - /// - /// Operation Id - /// SolutionResourceSelfHelp_GetSelfHelpSolutionById - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. - /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public static async Task> GetSelfHelpSolutionByIdAsync(this TenantResource tenantResource, string solutionId, CancellationToken cancellationToken = default) + public static async Task> DiscoverSolutionsNlpAsync(this TenantResource tenantResource, DiscoveryNlpContent discoverSolutionRequest = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tenantResource, nameof(tenantResource)); - return await GetMockableSelfHelpTenantResource(tenantResource).GetSelfHelpSolutionByIdAsync(solutionId, cancellationToken).ConfigureAwait(false); + return await GetMockableSelfHelpTenantResource(tenantResource).DiscoverSolutionsNlpAsync(discoverSolutionRequest, cancellationToken).ConfigureAwait(false); } /// - /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. - /// - /// - /// Request Path - /// /providers/Microsoft.Help/selfHelp/{solutionId} - /// - /// - /// Operation Id - /// SolutionResourceSelfHelp_GetSelfHelpSolutionById - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// + /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + /// The the method will execute against. + /// The request body. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public static Response GetSelfHelpSolutionById(this TenantResource tenantResource, string solutionId, CancellationToken cancellationToken = default) + /// is null. + public static Response DiscoverSolutionsNlp(this TenantResource tenantResource, DiscoveryNlpContent discoverSolutionRequest = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tenantResource, nameof(tenantResource)); - return GetMockableSelfHelpTenantResource(tenantResource).GetSelfHelpSolutionById(solutionId, cancellationToken); + return GetMockableSelfHelpTenantResource(tenantResource).DiscoverSolutionsNlp(discoverSolutionRequest, cancellationToken); } /// /// Lists the relevant Azure Diagnostics, Solutions and Troubleshooters using [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) AND resourceUri or resourceType.<br/> Discovery Solutions is the initial entry point within Help API, which identifies relevant Azure diagnostics and solutions. <br/><br/> Required Input : problemClassificationId (Use the [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) <br/>Optional input: resourceUri OR resource Type <br/><br/> <b>Note: </b> ‘requiredInputs’ from Discovery solutions response must be passed via ‘additionalParameters’ as an input to Diagnostics and Solutions API. - /// - /// - /// Request Path - /// /providers/Microsoft.Help/discoverySolutions - /// - /// - /// Operation Id - /// DiscoverySolutionOperationGroup_DiscoverSolutions - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// 'ProblemClassificationId' is a mandatory filter to get solutions ids. It also supports optional 'ResourceType' and 'SolutionType' filters. The [$filter](https://learn.microsoft.com/en-us/odata/webapi/first-odata-api#filter) supports only 'and', 'or' and 'eq' operators. Example: $filter=ProblemClassificationId eq '1ddda5b4-cf6c-4d4f-91ad-bc38ab0e811e'. /// Skiptoken is only used if a previous operation returned a partial result. /// The cancellation token to use. /// is null. - /// An async collection of that may take multiple service requests to iterate over. - public static AsyncPageable DiscoverSolutionsAsync(this TenantResource tenantResource, string filter = null, string skiptoken = null, CancellationToken cancellationToken = default) + /// A collection of that may take multiple service requests to iterate over. + public static AsyncPageable DiscoverSolutionsAsync(this TenantResource tenantResource, string filter = default, string skiptoken = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tenantResource, nameof(tenantResource)); @@ -793,32 +471,18 @@ public static AsyncPageable DiscoverSolutionsAsync(thi /// /// Lists the relevant Azure Diagnostics, Solutions and Troubleshooters using [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) AND resourceUri or resourceType.<br/> Discovery Solutions is the initial entry point within Help API, which identifies relevant Azure diagnostics and solutions. <br/><br/> Required Input : problemClassificationId (Use the [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) <br/>Optional input: resourceUri OR resource Type <br/><br/> <b>Note: </b> ‘requiredInputs’ from Discovery solutions response must be passed via ‘additionalParameters’ as an input to Diagnostics and Solutions API. - /// - /// - /// Request Path - /// /providers/Microsoft.Help/discoverySolutions - /// - /// - /// Operation Id - /// DiscoverySolutionOperationGroup_DiscoverSolutions - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// 'ProblemClassificationId' is a mandatory filter to get solutions ids. It also supports optional 'ResourceType' and 'SolutionType' filters. The [$filter](https://learn.microsoft.com/en-us/odata/webapi/first-odata-api#filter) supports only 'and', 'or' and 'eq' operators. Example: $filter=ProblemClassificationId eq '1ddda5b4-cf6c-4d4f-91ad-bc38ab0e811e'. /// Skiptoken is only used if a previous operation returned a partial result. /// The cancellation token to use. /// is null. /// A collection of that may take multiple service requests to iterate over. - public static Pageable DiscoverSolutions(this TenantResource tenantResource, string filter = null, string skiptoken = null, CancellationToken cancellationToken = default) + public static Pageable DiscoverSolutions(this TenantResource tenantResource, string filter = default, string skiptoken = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tenantResource, nameof(tenantResource)); diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Argument.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Argument.cs index b26ad8233e4d..9027f39a257c 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Argument.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Argument.cs @@ -11,8 +11,10 @@ namespace Azure.ResourceManager.SelfHelp { - internal static class Argument + internal static partial class Argument { + /// The value. + /// The name. public static void AssertNotNull(T value, string name) { if (value is null) @@ -21,8 +23,10 @@ public static void AssertNotNull(T value, string name) } } + /// The value. + /// The name. public static void AssertNotNull(T? value, string name) - where T : struct + where T : struct { if (!value.HasValue) { @@ -30,6 +34,8 @@ public static void AssertNotNull(T? value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(IEnumerable value, string name) { if (value is null) @@ -51,6 +57,8 @@ public static void AssertNotNullOrEmpty(IEnumerable value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(string value, string name) { if (value is null) @@ -62,68 +70,5 @@ public static void AssertNotNullOrEmpty(string value, string name) throw new ArgumentException("Value cannot be an empty string.", 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); - } - } - - public static void AssertNotDefault(ref T value, string name) - where T : struct, IEquatable - { - if (value.Equals(default)) - { - throw new ArgumentException("Value cannot be empty.", 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."); - } - } - - public static void AssertEnumDefined(Type enumType, object value, string name) - { - if (!Enum.IsDefined(enumType, value)) - { - throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); - } - } - - public static T CheckNotNull(T value, string name) - where T : class - { - AssertNotNull(value, name); - return value; - } - - public static string CheckNotNullOrEmpty(string value, string name) - { - AssertNotNullOrEmpty(value, name); - return value; - } - - public static void AssertNull(T value, string name, string message = null) - { - if (value != null) - { - throw new ArgumentException(message ?? "Value must be null.", name); - } - } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ChangeTrackingDictionary.cs index 68f055f983b0..e3c864f5551b 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -11,7 +11,8 @@ namespace Azure.ResourceManager.SelfHelp { - internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull { private IDictionary _innerDictionary; @@ -19,6 +20,7 @@ public ChangeTrackingDictionary() { } + /// The inner dictionary. public ChangeTrackingDictionary(IDictionary dictionary) { if (dictionary == null) @@ -28,6 +30,7 @@ public ChangeTrackingDictionary(IDictionary dictionary) _innerDictionary = new Dictionary(dictionary); } + /// The inner dictionary. public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) { if (dictionary == null) @@ -41,16 +44,22 @@ public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) } } + /// 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 @@ -67,8 +76,10 @@ public TValue this[TKey key] } } + /// Gets the Keys. IEnumerable IReadOnlyDictionary.Keys => Keys; + /// Gets the Values. IEnumerable IReadOnlyDictionary.Values => Values; public IEnumerator> GetEnumerator() @@ -89,6 +100,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(KeyValuePair item) { EnsureDictionary().Add(item); @@ -99,6 +111,7 @@ public void Clear() EnsureDictionary().Clear(); } + /// The item to search for. public bool Contains(KeyValuePair item) { if (IsUndefined) @@ -108,6 +121,8 @@ public bool Contains(KeyValuePair item) return EnsureDictionary().Contains(item); } + /// The array to copy. + /// The index. public void CopyTo(KeyValuePair[] array, int index) { if (IsUndefined) @@ -117,6 +132,7 @@ public void CopyTo(KeyValuePair[] array, int index) EnsureDictionary().CopyTo(array, index); } + /// The item to remove. public bool Remove(KeyValuePair item) { if (IsUndefined) @@ -126,11 +142,14 @@ public bool Remove(KeyValuePair item) 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) @@ -140,6 +159,7 @@ public bool ContainsKey(TKey key) return EnsureDictionary().ContainsKey(key); } + /// The key. public bool Remove(TKey key) { if (IsUndefined) @@ -149,6 +169,8 @@ public bool Remove(TKey key) return EnsureDictionary().Remove(key); } + /// The key to search for. + /// The value. public bool TryGetValue(TKey key, out TValue value) { if (IsUndefined) diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ChangeTrackingList.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ChangeTrackingList.cs index fdb58a3138cf..17cfc3518a15 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ChangeTrackingList.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ChangeTrackingList.cs @@ -12,7 +12,7 @@ namespace Azure.ResourceManager.SelfHelp { - internal class ChangeTrackingList : IList, IReadOnlyList + internal partial class ChangeTrackingList : IList, IReadOnlyList { private IList _innerList; @@ -20,6 +20,7 @@ public ChangeTrackingList() { } + /// The inner list. public ChangeTrackingList(IList innerList) { if (innerList != null) @@ -28,6 +29,7 @@ public ChangeTrackingList(IList innerList) } } + /// The inner list. public ChangeTrackingList(IReadOnlyList innerList) { if (innerList != null) @@ -36,12 +38,16 @@ public ChangeTrackingList(IReadOnlyList innerList) } } + /// 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 @@ -85,6 +91,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(T item) { EnsureList().Add(item); @@ -95,6 +102,7 @@ public void Clear() EnsureList().Clear(); } + /// The item. public bool Contains(T item) { if (IsUndefined) @@ -104,6 +112,8 @@ public bool Contains(T item) return EnsureList().Contains(item); } + /// The array to copy to. + /// The array index. public void CopyTo(T[] array, int arrayIndex) { if (IsUndefined) @@ -113,6 +123,7 @@ public void CopyTo(T[] array, int arrayIndex) EnsureList().CopyTo(array, arrayIndex); } + /// The item. public bool Remove(T item) { if (IsUndefined) @@ -122,6 +133,7 @@ public bool Remove(T item) return EnsureList().Remove(item); } + /// The item. public int IndexOf(T item) { if (IsUndefined) @@ -131,11 +143,14 @@ public int IndexOf(T item) 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) diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..cc7c947f4aff --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/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.SelfHelp +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (context?.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 statusOption) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (context?.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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..20b46bee3acd --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/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 Azure.ResourceManager.SelfHelp +{ + [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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..cf197147e17f --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/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 Azure.ResourceManager.SelfHelp +{ + [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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..bbced4baeca7 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/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 Azure.ResourceManager.SelfHelp +{ + [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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..b420ed9fe1cd --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/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 Azure.ResourceManager.SelfHelp +{ + [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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ErrorResult.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..f4e75d04e5cc --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/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.SelfHelp +{ + 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ModelSerializationExtensions.cs index f532c527a330..d1503e6d27a3 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/ModelSerializationExtensions.cs @@ -11,18 +11,16 @@ using System.Diagnostics; using System.Globalization; using System.Text.Json; -using System.Xml; -using Azure.Core; namespace Azure.ResourceManager.SelfHelp { - internal static class ModelSerializationExtensions + internal static partial class ModelSerializationExtensions { - internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); - internal static readonly ModelReaderWriterOptions WireV3Options = new ModelReaderWriterOptions("W|v3"); - internal static readonly ModelReaderWriterOptions JsonV3Options = new ModelReaderWriterOptions("J|v3"); - internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; public static object GetObject(this JsonElement element) { @@ -48,14 +46,14 @@ public static object GetObject(this JsonElement element) case JsonValueKind.Null: return null; case JsonValueKind.Object: - var dictionary = new Dictionary(); + Dictionary dictionary = new Dictionary(); foreach (var jsonProperty in element.EnumerateObject()) { dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); } return dictionary; case JsonValueKind.Array: - var list = new List(); + List list = new List(); foreach (var item in element.EnumerateArray()) { list.Add(item.GetObject()); @@ -93,7 +91,7 @@ public static char GetChar(this JsonElement element) { if (element.ValueKind == JsonValueKind.String) { - var text = element.GetString(); + string text = element.GetString(); if (text == null || text.Length != 1) { throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); @@ -107,14 +105,14 @@ public static char GetChar(this JsonElement element) } [Conditional("DEBUG")] - public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + 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"); + 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) { - var value = element.GetString(); + 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}'."); @@ -181,9 +179,6 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value, Mode case IJsonModel jsonModel: jsonModel.Write(writer, options ?? WireOptions); break; - case IUtf8JsonSerializable serializable: - serializable.Write(writer); - break; case byte[] bytes: writer.WriteBase64StringValue(bytes); break; @@ -259,151 +254,5 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, object value, Mo { writer.WriteObjectValue(value, options); } - - internal static bool IsSentinelValue(BinaryData value) - { - ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; - ReadOnlySpan valueSpan = value.ToMemory().Span; - return sentinelSpan.SequenceEqual(valueSpan); - } - - internal static 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}. Azure SDK requires 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 ConvertToString(object value, string format = null) => 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 format != null => ToString(b0, format), - IEnumerable s0 => string.Join(",", s0), - DateTimeOffset dateTime when format != null => ToString(dateTime, format), - TimeSpan timeSpan when format != null => ToString(timeSpan, format), - TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), - Guid guid => guid.ToString(), - BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), - _ => value.ToString() - }; - } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Optional.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Optional.cs index 569dae7715cc..65ab87aa8899 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Optional.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Optional.cs @@ -10,7 +10,7 @@ namespace Azure.ResourceManager.SelfHelp { - internal static class Optional + internal static partial class Optional { public static bool IsCollectionDefined(IEnumerable collection) { @@ -28,7 +28,7 @@ public static bool IsCollectionDefined(IReadOnlyDictionary(T? value) - where T : struct + where T : struct { return value.HasValue; } @@ -38,14 +38,14 @@ public static bool IsDefined(object value) return value != null; } - public static bool IsDefined(JsonElement value) + public static bool IsDefined(string value) { - return value.ValueKind != JsonValueKind.Undefined; + return value != null; } - public static bool IsDefined(string value) + public static bool IsDefined(JsonElement value) { - return value != null; + return value.ValueKind != JsonValueKind.Undefined; } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..b95e1d2a4e74 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,23 @@ +// 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.SelfHelp +{ + 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); + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/RequestContextExtensions.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..f24ea4921dd6 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/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.SelfHelp +{ + 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/SerializationFormat.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..b1952e655c9a --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/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.SelfHelp +{ + 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/TypeFormatters.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..b13c9de718b9 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/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.SelfHelp +{ + 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Utf8JsonRequestContent.cs index ff90ecbf5846..c383711572a6 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Utf8JsonRequestContent.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -13,7 +13,7 @@ namespace Azure.ResourceManager.SelfHelp { - internal class Utf8JsonRequestContent : RequestContent + internal partial class Utf8JsonRequestContent : RequestContent { private readonly MemoryStream _stream; private readonly RequestContent _content; @@ -25,20 +25,26 @@ public Utf8JsonRequestContent() JsonWriter = new Utf8JsonWriter(_stream); } + /// Gets the JsonWriter. public Utf8JsonWriter JsonWriter { get; } + /// The stream containing the data to be written. + /// The cancellation token to use. public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) { await JsonWriter.FlushAsync().ConfigureAwait(false); await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); } + /// The stream containing the data to be written. + /// The cancellation token to use. public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) { JsonWriter.Flush(); _content.WriteTo(stream, cancellationToken); } + /// public override bool TryComputeLength(out long length) { length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpArmOperationOfT.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpArmOperationOfT.cs index d2de4b77df06..b7e3ec875f45 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpArmOperationOfT.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpArmOperationOfT.cs @@ -6,18 +6,16 @@ #nullable disable using System; -using System.ClientModel.Primitives; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.SelfHelp { -#pragma warning disable SA1649 // File name should match first type name - internal class SelfHelpArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class SelfHelpArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected SelfHelpArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal SelfHelpArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); @@ -36,12 +37,21 @@ internal SelfHelpArmOperation(Response response, RehydrationToken? rehydratio _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 SelfHelpArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) { - var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); - if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) { - _nextLinkOperation = nextLinkOperationValue; + _nextLinkOperation = nextLinkOperationImplementation; _operationId = _nextLinkOperation.OperationId; } else @@ -49,54 +59,55 @@ internal SelfHelpArmOperation(IOperationSource source, ClientDiagnostics clie _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "SelfHelpArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "SelfHelpArmOperation", + null, + new SequentialDelayStrategy()); } - private string GetOperationId(RehydrationToken? rehydrationToken) - { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerSelfHelpContext.Default); - using var document = JsonDocument.Parse(data); - var lroDetails = document.RootElement; - return lroDetails.GetProperty("id").GetString(); - } - /// + /// Gets the Id. public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; - /// - public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; - - /// + /// 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpDiagnosticOperationSource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpDiagnosticOperationSource.cs index c68e643fefbe..1cdf88dd4da1 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpDiagnosticOperationSource.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpDiagnosticOperationSource.cs @@ -5,32 +5,45 @@ #nullable disable -using System.ClientModel.Primitives; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.SelfHelp { - internal class SelfHelpDiagnosticOperationSource : IOperationSource + /// + internal partial class SelfHelpDiagnosticOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal SelfHelpDiagnosticOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// SelfHelpDiagnosticResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSelfHelpContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + SelfHelpDiagnosticData data = SelfHelpDiagnosticData.DeserializeSelfHelpDiagnosticData(document.RootElement, ModelSerializationExtensions.WireOptions); return new SelfHelpDiagnosticResource(_client, data); } + /// The response from the service. + /// The cancellation token to use. + /// async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSelfHelpContext.Default); - return await Task.FromResult(new SelfHelpDiagnosticResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + SelfHelpDiagnosticData data = SelfHelpDiagnosticData.DeserializeSelfHelpDiagnosticData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new SelfHelpDiagnosticResource(_client, data); } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpSimplifiedSolutionOperationSource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpSimplifiedSolutionOperationSource.cs deleted file mode 100644 index a63c9c914966..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpSimplifiedSolutionOperationSource.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.ClientModel.Primitives; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; - -namespace Azure.ResourceManager.SelfHelp -{ - internal class SelfHelpSimplifiedSolutionOperationSource : IOperationSource - { - private readonly ArmClient _client; - - internal SelfHelpSimplifiedSolutionOperationSource(ArmClient client) - { - _client = client; - } - - SelfHelpSimplifiedSolutionResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) - { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSelfHelpContext.Default); - return new SelfHelpSimplifiedSolutionResource(_client, data); - } - - async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) - { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSelfHelpContext.Default); - return await Task.FromResult(new SelfHelpSimplifiedSolutionResource(_client, data)).ConfigureAwait(false); - } - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpSimplifiedSolutionsOperationSource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpSimplifiedSolutionsOperationSource.cs new file mode 100644 index 000000000000..c29699623229 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpSimplifiedSolutionsOperationSource.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.SelfHelp +{ + /// + internal partial class SelfHelpSimplifiedSolutionsOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal SelfHelpSimplifiedSolutionsOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + SelfHelpSimplifiedSolutionsResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + SelfHelpSimplifiedSolutionsData data = SelfHelpSimplifiedSolutionsData.DeserializeSelfHelpSimplifiedSolutionsData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new SelfHelpSimplifiedSolutionsResource(_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); + SelfHelpSimplifiedSolutionsData data = SelfHelpSimplifiedSolutionsData.DeserializeSelfHelpSimplifiedSolutionsData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new SelfHelpSimplifiedSolutionsResource(_client, data); + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpSolutionOperationSource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpSolutionOperationSource.cs index b951da6dc100..d7c9fd0a3242 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpSolutionOperationSource.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/LongRunningOperation/SelfHelpSolutionOperationSource.cs @@ -5,32 +5,45 @@ #nullable disable -using System.ClientModel.Primitives; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.SelfHelp { - internal class SelfHelpSolutionOperationSource : IOperationSource + /// + internal partial class SelfHelpSolutionOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal SelfHelpSolutionOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// SelfHelpSolutionResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSelfHelpContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + SelfHelpSolutionData data = SelfHelpSolutionData.DeserializeSelfHelpSolutionData(document.RootElement, ModelSerializationExtensions.WireOptions); return new SelfHelpSolutionResource(_client, data); } + /// The response from the service. + /// The cancellation token to use. + /// async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSelfHelpContext.Default); - return await Task.FromResult(new SelfHelpSolutionResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + SelfHelpSolutionData data = SelfHelpSolutionData.DeserializeSelfHelpSolutionData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new SelfHelpSolutionResource(_client, data); } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResult.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResult.Serialization.cs index 26d647b33b4f..082f3fe9d776 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResult.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResult.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class AutomatedCheckResult : IUtf8JsonSerializable, IJsonModel + /// Only for AutomatedStep type. + public partial class AutomatedCheckResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(AutomatedCheckResult)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Version)) { writer.WritePropertyName("version"u8); @@ -54,15 +54,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("type"u8); writer.WriteStringValue(ResultType.Value.ToString()); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -71,22 +71,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AutomatedCheckResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + AutomatedCheckResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AutomatedCheckResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(AutomatedCheckResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAutomatedCheckResult(document.RootElement, options); } - internal static AutomatedCheckResult DeserializeAutomatedCheckResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AutomatedCheckResult DeserializeAutomatedCheckResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -94,48 +99,49 @@ internal static AutomatedCheckResult DeserializeAutomatedCheckResult(JsonElement string version = default; string status = default; string result = default; - AutomatedCheckResultType? type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + AutomatedCheckResultType? resultType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("version"u8)) + if (prop.NameEquals("version"u8)) { - version = property.Value.GetString(); + version = prop.Value.GetString(); continue; } - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - status = property.Value.GetString(); + status = prop.Value.GetString(); continue; } - if (property.NameEquals("result"u8)) + if (prop.NameEquals("result"u8)) { - result = property.Value.GetString(); + result = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new AutomatedCheckResultType(property.Value.GetString()); + resultType = new AutomatedCheckResultType(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new AutomatedCheckResult(version, status, result, type, serializedAdditionalRawData); + return new AutomatedCheckResult(version, status, result, resultType, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -145,15 +151,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - AutomatedCheckResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + AutomatedCheckResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AutomatedCheckResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeAutomatedCheckResult(document.RootElement, options); } default: @@ -161,6 +172,7 @@ AutomatedCheckResult IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResult.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResult.cs index 1f0bfa7adc48..dd4ab9b6644e 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResult.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResult.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Only for AutomatedStep type. public partial class AutomatedCheckResult { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal AutomatedCheckResult() @@ -55,22 +26,25 @@ internal AutomatedCheckResult() /// Status for automated check result. /// Insight Article Content. /// Type of Result. - /// Keeps track of any properties unknown to the library. - internal AutomatedCheckResult(string version, string status, string result, AutomatedCheckResultType? resultType, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal AutomatedCheckResult(string version, string status, string result, AutomatedCheckResultType? resultType, IDictionary additionalBinaryDataProperties) { Version = version; Status = status; Result = result; ResultType = resultType; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Version for automated check result. public string Version { get; } + /// Status for automated check result. public string Status { get; } + /// Insight Article Content. public string Result { get; } + /// Type of Result. public AutomatedCheckResultType? ResultType { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResultType.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResultType.cs index 47f4e894a8a5..c3937f48223d 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResultType.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AutomatedCheckResultType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,44 +15,63 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct AutomatedCheckResultType : IEquatable { private readonly string _value; + private const string SuccessValue = "Success"; + private const string WarningValue = "Warning"; + private const string ErrorValue = "Error"; + private const string InformationValue = "Information"; /// Initializes a new instance of . + /// The value. /// is null. public AutomatedCheckResultType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SuccessValue = "Success"; - private const string WarningValue = "Warning"; - private const string ErrorValue = "Error"; - private const string InformationValue = "Information"; + _value = value; + } - /// Success. + /// Gets the Success. public static AutomatedCheckResultType Success { get; } = new AutomatedCheckResultType(SuccessValue); - /// Warning. + + /// Gets the Warning. public static AutomatedCheckResultType Warning { get; } = new AutomatedCheckResultType(WarningValue); - /// Error. + + /// Gets the Error. public static AutomatedCheckResultType Error { get; } = new AutomatedCheckResultType(ErrorValue); - /// Information. + + /// Gets the Information. public static AutomatedCheckResultType Information { get; } = new AutomatedCheckResultType(InformationValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(AutomatedCheckResultType left, AutomatedCheckResultType 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 !=(AutomatedCheckResultType left, AutomatedCheckResultType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator AutomatedCheckResultType(string value) => new AutomatedCheckResultType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator AutomatedCheckResultType?(string value) => value == null ? null : new AutomatedCheckResultType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is AutomatedCheckResultType other && Equals(other); - /// + + /// public bool Equals(AutomatedCheckResultType 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AzureResourceManagerSelfHelpContext.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AzureResourceManagerSelfHelpContext.cs index e6f89c255d48..2a862b43b2fa 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AzureResourceManagerSelfHelpContext.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/AzureResourceManagerSelfHelpContext.cs @@ -6,6 +6,7 @@ #nullable disable using System.ClientModel.Primitives; +using Azure; using Azure.ResourceManager.Models; using Azure.ResourceManager.SelfHelp.Models; @@ -13,7 +14,7 @@ namespace Azure.ResourceManager.SelfHelp { /// /// Context class which will be filled in by the System.ClientModel.SourceGeneration. - /// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md' + /// For more information /// [ModelReaderWriterBuildable(typeof(AutomatedCheckResult))] [ModelReaderWriterBuildable(typeof(ChartFilterGroup))] @@ -33,33 +34,39 @@ namespace Azure.ResourceManager.SelfHelp [ModelReaderWriterBuildable(typeof(SelfHelpDiagnosticInsight))] [ModelReaderWriterBuildable(typeof(SelfHelpDiagnosticInvocation))] [ModelReaderWriterBuildable(typeof(SelfHelpDiagnosticResource))] + [ModelReaderWriterBuildable(typeof(SelfHelpDiagnosticResourceProperties))] [ModelReaderWriterBuildable(typeof(SelfHelpDiscoverySolutionResult))] [ModelReaderWriterBuildable(typeof(SelfHelpError))] [ModelReaderWriterBuildable(typeof(SelfHelpFilter))] - [ModelReaderWriterBuildable(typeof(SelfHelpNameAvailabilityContent))] - [ModelReaderWriterBuildable(typeof(SelfHelpNameAvailabilityResult))] + [ModelReaderWriterBuildable(typeof(SelfHelpNlpSolutions))] [ModelReaderWriterBuildable(typeof(SelfHelpSection))] - [ModelReaderWriterBuildable(typeof(SelfHelpSimplifiedSolutionData))] - [ModelReaderWriterBuildable(typeof(SelfHelpSimplifiedSolutionResource))] + [ModelReaderWriterBuildable(typeof(SelfHelpSimplifiedSolutionsData))] + [ModelReaderWriterBuildable(typeof(SelfHelpSimplifiedSolutionsResource))] [ModelReaderWriterBuildable(typeof(SelfHelpSolutionData))] [ModelReaderWriterBuildable(typeof(SelfHelpSolutionMetadata))] [ModelReaderWriterBuildable(typeof(SelfHelpSolutionPatch))] [ModelReaderWriterBuildable(typeof(SelfHelpSolutionResource))] - [ModelReaderWriterBuildable(typeof(SelfHelpSolutionResult))] + [ModelReaderWriterBuildable(typeof(SelfHelpSolutionResultData))] + [ModelReaderWriterBuildable(typeof(SelfHelpSolutionResultResource))] + [ModelReaderWriterBuildable(typeof(SelfHelpSolutions))] [ModelReaderWriterBuildable(typeof(SelfHelpStep))] [ModelReaderWriterBuildable(typeof(SelfHelpTroubleshooterData))] [ModelReaderWriterBuildable(typeof(SelfHelpTroubleshooterResource))] [ModelReaderWriterBuildable(typeof(SelfHelpVideo))] + [ModelReaderWriterBuildable(typeof(SimplifiedSolutionsResourceProperties))] [ModelReaderWriterBuildable(typeof(SolutionMetadataProperties))] [ModelReaderWriterBuildable(typeof(SolutionNlpMetadata))] [ModelReaderWriterBuildable(typeof(SolutionReplacementMaps))] + [ModelReaderWriterBuildable(typeof(SolutionResourceProperties))] [ModelReaderWriterBuildable(typeof(SolutionsDiagnostic))] [ModelReaderWriterBuildable(typeof(SolutionSection))] + [ModelReaderWriterBuildable(typeof(SolutionsResourcePropertiesSelfHelp))] [ModelReaderWriterBuildable(typeof(SolutionsTroubleshooters))] [ModelReaderWriterBuildable(typeof(SolutionTriggerCriterion))] [ModelReaderWriterBuildable(typeof(SolutionWarmUpContent))] [ModelReaderWriterBuildable(typeof(SystemData))] [ModelReaderWriterBuildable(typeof(TroubleshooterContinueContent))] + [ModelReaderWriterBuildable(typeof(TroubleshooterInstanceProperties))] [ModelReaderWriterBuildable(typeof(TroubleshooterResult))] [ModelReaderWriterBuildable(typeof(TroubleshooterStepInput))] [ModelReaderWriterBuildable(typeof(VideoGroupDetail))] diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartAggregationType.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartAggregationType.cs index c94132455af2..d28ae89af621 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartAggregationType.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartAggregationType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,47 +15,67 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct ChartAggregationType : IEquatable { private readonly string _value; + private const string SumValue = "Sum"; + private const string AvgValue = "Avg"; + private const string CountValue = "Count"; + private const string MinValue = "Min"; + private const string MaxValue = "Max"; /// Initializes a new instance of . + /// The value. /// is null. public ChartAggregationType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SumValue = "Sum"; - private const string AvgValue = "Avg"; - private const string CountValue = "Count"; - private const string MinValue = "Min"; - private const string MaxValue = "Max"; + _value = value; + } - /// Sum. + /// Gets the Sum. public static ChartAggregationType Sum { get; } = new ChartAggregationType(SumValue); - /// Avg. + + /// Gets the Avg. public static ChartAggregationType Avg { get; } = new ChartAggregationType(AvgValue); - /// Count. + + /// Gets the Count. public static ChartAggregationType Count { get; } = new ChartAggregationType(CountValue); - /// Min. + + /// Gets the Min. public static ChartAggregationType Min { get; } = new ChartAggregationType(MinValue); - /// Max. + + /// Gets the Max. public static ChartAggregationType Max { get; } = new ChartAggregationType(MaxValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(ChartAggregationType left, ChartAggregationType 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 !=(ChartAggregationType left, ChartAggregationType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator ChartAggregationType(string value) => new ChartAggregationType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator ChartAggregationType?(string value) => value == null ? null : new ChartAggregationType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is ChartAggregationType other && Equals(other); - /// + + /// public bool Equals(ChartAggregationType 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartFilterGroup.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartFilterGroup.Serialization.cs index cdf5fb02a4ce..5f169572fdb7 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartFilterGroup.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartFilterGroup.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - internal partial class ChartFilterGroup : IUtf8JsonSerializable, IJsonModel + /// Filter group. + internal partial class ChartFilterGroup : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,31 +29,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ChartFilterGroup)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Filter)) { writer.WritePropertyName("filter"u8); writer.WriteStartArray(); - foreach (var item in Filter) + foreach (SelfHelpFilter item in Filter) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,39 +61,43 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ChartFilterGroup IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ChartFilterGroup IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ChartFilterGroup JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ChartFilterGroup)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeChartFilterGroup(document.RootElement, options); } - internal static ChartFilterGroup DeserializeChartFilterGroup(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ChartFilterGroup DeserializeChartFilterGroup(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList filter = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList filter = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("filter"u8)) + if (prop.NameEquals("filter"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(SelfHelpFilter.DeserializeSelfHelpFilter(item, options)); } @@ -102,17 +106,19 @@ internal static ChartFilterGroup DeserializeChartFilterGroup(JsonElement element } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ChartFilterGroup(filter ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new ChartFilterGroup(filter ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -122,15 +128,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - ChartFilterGroup IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ChartFilterGroup IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ChartFilterGroup 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeChartFilterGroup(document.RootElement, options); } default: @@ -138,6 +149,7 @@ ChartFilterGroup IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartFilterGroup.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartFilterGroup.cs index f0d284df8282..89fa669ec75a 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartFilterGroup.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ChartFilterGroup.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Filter group. internal partial class ChartFilterGroup { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal ChartFilterGroup() @@ -53,14 +25,14 @@ internal ChartFilterGroup() /// Initializes a new instance of . /// List of filters. - /// Keeps track of any properties unknown to the library. - internal ChartFilterGroup(IReadOnlyList filter, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ChartFilterGroup(IList filter, IDictionary additionalBinaryDataProperties) { Filter = filter; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// List of filters. - public IReadOnlyList Filter { get; } + public IList Filter { get; } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ClassificationService.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ClassificationService.Serialization.cs index 00dfa50aa9fd..d358e8e1144c 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ClassificationService.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ClassificationService.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class ClassificationService : IUtf8JsonSerializable, IJsonModel + /// Service Classification result object. + public partial class ClassificationService : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +30,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ClassificationService)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(ServiceId)) { writer.WritePropertyName("serviceId"u8); @@ -48,21 +49,26 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("resourceTypes"u8); writer.WriteStartArray(); - foreach (var item in ResourceTypes) + foreach (string item in ResourceTypes) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -71,22 +77,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ClassificationService IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ClassificationService IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ClassificationService JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ClassificationService)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeClassificationService(document.RootElement, options); } - internal static ClassificationService DeserializeClassificationService(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ClassificationService DeserializeClassificationService(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -94,51 +105,59 @@ internal static ClassificationService DeserializeClassificationService(JsonEleme ResourceIdentifier serviceId = default; string displayName = default; IList resourceTypes = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("serviceId"u8)) + if (prop.NameEquals("serviceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - serviceId = new ResourceIdentifier(property.Value.GetString()); + serviceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("resourceTypes"u8)) + if (prop.NameEquals("resourceTypes"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } resourceTypes = array; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ClassificationService(serviceId, displayName, resourceTypes ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new ClassificationService(serviceId, displayName, resourceTypes ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -148,15 +167,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - ClassificationService IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ClassificationService IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ClassificationService 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeClassificationService(document.RootElement, options); } default: @@ -164,6 +188,7 @@ ClassificationService IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ClassificationService.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ClassificationService.cs index 3b0d2000624e..6a18a04e914e 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ClassificationService.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ClassificationService.cs @@ -8,43 +8,15 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Service Classification result object. public partial class ClassificationService { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public ClassificationService() @@ -56,19 +28,21 @@ public ClassificationService() /// Azure resource Id of the service. /// Localized name of the azure service. /// List of applicable ARM resource types for this service. - /// Keeps track of any properties unknown to the library. - internal ClassificationService(ResourceIdentifier serviceId, string displayName, IList resourceTypes, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ClassificationService(ResourceIdentifier serviceId, string displayName, IList resourceTypes, IDictionary additionalBinaryDataProperties) { ServiceId = serviceId; DisplayName = displayName; ResourceTypes = resourceTypes; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Azure resource Id of the service. public ResourceIdentifier ServiceId { get; } + /// Localized name of the azure service. public string DisplayName { get; } + /// List of applicable ARM resource types for this service. public IList ResourceTypes { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpContent.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpContent.Serialization.cs index e1dd97399dfc..960b8b2401f1 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpContent.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpContent.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class DiscoveryNlpContent : IUtf8JsonSerializable, IJsonModel + /// Discover NLP request. + public partial class DiscoveryNlpContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DiscoveryNlpContent() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +35,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DiscoveryNlpContent)} does not support writing '{format}' format."); } - writer.WritePropertyName("issueSummary"u8); writer.WriteStringValue(IssueSummary); if (Optional.IsDefined(ResourceId)) @@ -51,15 +57,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("additionalContext"u8); writer.WriteStringValue(AdditionalContext); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -68,22 +74,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DiscoveryNlpContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DiscoveryNlpContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DiscoveryNlpContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DiscoveryNlpContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDiscoveryNlpContent(document.RootElement, options); } - internal static DiscoveryNlpContent DeserializeDiscoveryNlpContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DiscoveryNlpContent DeserializeDiscoveryNlpContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -92,43 +103,44 @@ internal static DiscoveryNlpContent DeserializeDiscoveryNlpContent(JsonElement e string resourceId = default; string serviceId = default; string additionalContext = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("issueSummary"u8)) + if (prop.NameEquals("issueSummary"u8)) { - issueSummary = property.Value.GetString(); + issueSummary = prop.Value.GetString(); continue; } - if (property.NameEquals("resourceId"u8)) + if (prop.NameEquals("resourceId"u8)) { - resourceId = property.Value.GetString(); + resourceId = prop.Value.GetString(); continue; } - if (property.NameEquals("serviceId"u8)) + if (prop.NameEquals("serviceId"u8)) { - serviceId = property.Value.GetString(); + serviceId = prop.Value.GetString(); continue; } - if (property.NameEquals("additionalContext"u8)) + if (prop.NameEquals("additionalContext"u8)) { - additionalContext = property.Value.GetString(); + additionalContext = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DiscoveryNlpContent(issueSummary, resourceId, serviceId, additionalContext, serializedAdditionalRawData); + return new DiscoveryNlpContent(issueSummary, resourceId, serviceId, additionalContext, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -138,15 +150,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - DiscoveryNlpContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DiscoveryNlpContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DiscoveryNlpContent 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDiscoveryNlpContent(document.RootElement, options); } default: @@ -154,6 +171,19 @@ DiscoveryNlpContent IPersistableModel.Create(BinaryData dat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DiscoveryNlpContent discoveryNlpContent) + { + if (discoveryNlpContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(discoveryNlpContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpContent.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpContent.cs index 905e97a666ac..01cfbb37dd07 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpContent.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpContent.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Discover NLP request. public partial class DiscoveryNlpContent { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// Natural language description of the issue. @@ -60,27 +32,25 @@ public DiscoveryNlpContent(string issueSummary) /// ARM resource Id of the resource that is having the issue. Only applicable for Discovery Solution NLP Subscription Scope. /// ARM service Id of the service that is having the issue. For more information on service Id see https://learn.microsoft.com/rest/api/support/services/list?tabs=HTTP. /// Additional information in the form of a string. - /// Keeps track of any properties unknown to the library. - internal DiscoveryNlpContent(string issueSummary, string resourceId, string serviceId, string additionalContext, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DiscoveryNlpContent(string issueSummary, string resourceId, string serviceId, string additionalContext, IDictionary additionalBinaryDataProperties) { IssueSummary = issueSummary; ResourceId = resourceId; ServiceId = serviceId; AdditionalContext = additionalContext; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DiscoveryNlpContent() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Natural language description of the issue. public string IssueSummary { get; } + /// ARM resource Id of the resource that is having the issue. Only applicable for Discovery Solution NLP Subscription Scope. public string ResourceId { get; set; } + /// ARM service Id of the service that is having the issue. For more information on service Id see https://learn.microsoft.com/rest/api/support/services/list?tabs=HTTP. public string ServiceId { get; set; } + /// Additional information in the form of a string. public string AdditionalContext { get; set; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpResult.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpResult.Serialization.cs index 7b352be762bf..214874299c1b 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpResult.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpResult.Serialization.cs @@ -9,14 +9,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - internal partial class DiscoveryNlpResult : IUtf8JsonSerializable, IJsonModel + /// Successfully fetched list of solution metadata. + public partial class DiscoveryNlpResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,31 +30,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DiscoveryNlpResult)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Value)) { writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (SolutionNlpMetadata item in Value) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,39 +62,43 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DiscoveryNlpResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DiscoveryNlpResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DiscoveryNlpResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DiscoveryNlpResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDiscoveryNlpResult(document.RootElement, options); } - internal static DiscoveryNlpResult DeserializeDiscoveryNlpResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DiscoveryNlpResult DeserializeDiscoveryNlpResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(SolutionNlpMetadata.DeserializeSolutionNlpMetadata(item, options)); } @@ -102,17 +107,19 @@ internal static DiscoveryNlpResult DeserializeDiscoveryNlpResult(JsonElement ele } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new DiscoveryNlpResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new DiscoveryNlpResult(value ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -122,15 +129,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - DiscoveryNlpResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + DiscoveryNlpResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DiscoveryNlpResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDiscoveryNlpResult(document.RootElement, options); } default: @@ -138,6 +150,14 @@ DiscoveryNlpResult IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static DiscoveryNlpResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDiscoveryNlpResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpResult.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpResult.cs index b85e6546862a..149d31081a44 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpResult.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/DiscoveryNlpResult.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Successfully fetched list of solution metadata. - internal partial class DiscoveryNlpResult + public partial class DiscoveryNlpResult { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal DiscoveryNlpResult() @@ -53,14 +25,14 @@ internal DiscoveryNlpResult() /// Initializes a new instance of . /// The list of solution metadata. - /// Keeps track of any properties unknown to the library. - internal DiscoveryNlpResult(IReadOnlyList value, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DiscoveryNlpResult(IList value, IDictionary additionalBinaryDataProperties) { Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The list of solution metadata. - public IReadOnlyList Value { get; } + public IList Value { get; } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResult.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResult.Serialization.cs index 00c6fb5e84dd..3939eef2e943 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResult.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResult.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class KBSearchResult : IUtf8JsonSerializable, IJsonModel + /// Details of an AzureKB search result. + public partial class KBSearchResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(KBSearchResult)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SolutionId)) { writer.WritePropertyName("solutionId"u8); @@ -74,15 +74,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("link"u8); writer.WriteStringValue(Link); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -91,22 +91,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - KBSearchResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + KBSearchResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual KBSearchResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(KBSearchResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeKBSearchResult(document.RootElement, options); } - internal static KBSearchResult DeserializeKBSearchResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static KBSearchResult DeserializeKBSearchResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -119,68 +124,66 @@ internal static KBSearchResult DeserializeKBSearchResult(JsonElement element, Mo KBSearchResultType? resultType = default; int? rank = default; string link = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("solutionId"u8)) + if (prop.NameEquals("solutionId"u8)) { - solutionId = property.Value.GetString(); + solutionId = prop.Value.GetString(); continue; } - if (property.NameEquals("content"u8)) + if (prop.NameEquals("content"u8)) { - content = property.Value.GetString(); + content = prop.Value.GetString(); continue; } - if (property.NameEquals("title"u8)) + if (prop.NameEquals("title"u8)) { - title = property.Value.GetString(); + title = prop.Value.GetString(); continue; } - if (property.NameEquals("confidence"u8)) + if (prop.NameEquals("confidence"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - confidence = new SelfHelpConfidence(property.Value.GetString()); + confidence = new SelfHelpConfidence(prop.Value.GetString()); continue; } - if (property.NameEquals("source"u8)) + if (prop.NameEquals("source"u8)) { - source = property.Value.GetString(); + source = prop.Value.GetString(); continue; } - if (property.NameEquals("resultType"u8)) + if (prop.NameEquals("resultType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - resultType = new KBSearchResultType(property.Value.GetString()); + resultType = new KBSearchResultType(prop.Value.GetString()); continue; } - if (property.NameEquals("rank"u8)) + if (prop.NameEquals("rank"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - rank = property.Value.GetInt32(); + rank = prop.Value.GetInt32(); continue; } - if (property.NameEquals("link"u8)) + if (prop.NameEquals("link"u8)) { - link = property.Value.GetString(); + link = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new KBSearchResult( solutionId, content, @@ -190,13 +193,16 @@ internal static KBSearchResult DeserializeKBSearchResult(JsonElement element, Mo resultType, rank, link, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -206,15 +212,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - KBSearchResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + KBSearchResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual KBSearchResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeKBSearchResult(document.RootElement, options); } default: @@ -222,6 +233,7 @@ KBSearchResult IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResult.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResult.cs index a70621fac101..74a498ae17cf 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResult.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResult.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Details of an AzureKB search result. public partial class KBSearchResult { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal KBSearchResult() @@ -59,8 +30,8 @@ internal KBSearchResult() /// Result type of the search result. /// rank of the search result. /// Link to the document. - /// Keeps track of any properties unknown to the library. - internal KBSearchResult(string solutionId, string content, string title, SelfHelpConfidence? confidence, string source, KBSearchResultType? resultType, int? rank, string link, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal KBSearchResult(string solutionId, string content, string title, SelfHelpConfidence? confidence, string source, KBSearchResultType? resultType, int? rank, string link, IDictionary additionalBinaryDataProperties) { SolutionId = solutionId; Content = content; @@ -70,23 +41,30 @@ internal KBSearchResult(string solutionId, string content, string title, SelfHel ResultType = resultType; Rank = rank; Link = link; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Unique id of the result. public string SolutionId { get; } + /// Content of the search result. public string Content { get; } + /// Title of the search result. public string Title { get; } + /// Confidence of the search result. public SelfHelpConfidence? Confidence { get; } + /// Source of the search result. public string Source { get; } + /// Result type of the search result. public KBSearchResultType? ResultType { get; } + /// rank of the search result. public int? Rank { get; } + /// Link to the document. public string Link { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResultType.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResultType.cs index 0fd0bdbc6daa..1b71c95deee8 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResultType.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBSearchResultType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,38 +15,55 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct KBSearchResultType : IEquatable { private readonly string _value; + private const string CommunityValue = "Community"; + private const string DocumentationValue = "Documentation"; /// Initializes a new instance of . + /// The value. /// is null. public KBSearchResultType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string CommunityValue = "Community"; - private const string DocumentationValue = "Documentation"; + _value = value; + } - /// Community. + /// Gets the Community. public static KBSearchResultType Community { get; } = new KBSearchResultType(CommunityValue); - /// Documentation. + + /// Gets the Documentation. public static KBSearchResultType Documentation { get; } = new KBSearchResultType(DocumentationValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(KBSearchResultType left, KBSearchResultType 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 !=(KBSearchResultType left, KBSearchResultType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator KBSearchResultType(string value) => new KBSearchResultType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator KBSearchResultType?(string value) => value == null ? null : new KBSearchResultType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is KBSearchResultType other && Equals(other); - /// + + /// public bool Equals(KBSearchResultType 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBWebResult.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBWebResult.Serialization.cs index 17cf0c16ed70..513ba53a2a18 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBWebResult.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBWebResult.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class KBWebResult : IUtf8JsonSerializable, IJsonModel + /// AzureKB web result. + public partial class KBWebResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(KBWebResult)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ReplacementKey)) { writer.WritePropertyName("replacementKey"u8); @@ -43,21 +43,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("searchResults"u8); writer.WriteStartArray(); - foreach (var item in SearchResults) + foreach (KBSearchResult item in SearchResults) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,45 +66,49 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - KBWebResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + KBWebResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual KBWebResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(KBWebResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeKBWebResult(document.RootElement, options); } - internal static KBWebResult DeserializeKBWebResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static KBWebResult DeserializeKBWebResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string replacementKey = default; - IReadOnlyList searchResults = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList searchResults = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("replacementKey"u8)) + if (prop.NameEquals("replacementKey"u8)) { - replacementKey = property.Value.GetString(); + replacementKey = prop.Value.GetString(); continue; } - if (property.NameEquals("searchResults"u8)) + if (prop.NameEquals("searchResults"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(KBSearchResult.DeserializeKBSearchResult(item, options)); } @@ -113,17 +117,19 @@ internal static KBWebResult DeserializeKBWebResult(JsonElement element, ModelRea } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new KBWebResult(replacementKey, searchResults ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new KBWebResult(replacementKey, searchResults ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -133,15 +139,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions options } } - KBWebResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + KBWebResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual KBWebResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeKBWebResult(document.RootElement, options); } default: @@ -149,6 +160,7 @@ KBWebResult IPersistableModel.Create(BinaryData data, ModelReaderWr } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBWebResult.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBWebResult.cs index 92d0f7225d4a..c8231ffeea65 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBWebResult.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/KBWebResult.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// AzureKB web result. public partial class KBWebResult { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal KBWebResult() @@ -54,17 +26,18 @@ internal KBWebResult() /// Initializes a new instance of . /// Place holder used in HTML Content replace control with the content. /// AzureKB search results. - /// Keeps track of any properties unknown to the library. - internal KBWebResult(string replacementKey, IReadOnlyList searchResults, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal KBWebResult(string replacementKey, IList searchResults, IDictionary additionalBinaryDataProperties) { ReplacementKey = replacementKey; SearchResults = searchResults; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Place holder used in HTML Content replace control with the content. public string ReplacementKey { get; } + /// AzureKB search results. - public IReadOnlyList SearchResults { get; } + public IList SearchResults { get; } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/MetricsBasedChart.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/MetricsBasedChart.Serialization.cs index 99830e928879..2d28d47da590 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/MetricsBasedChart.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/MetricsBasedChart.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class MetricsBasedChart : IUtf8JsonSerializable, IJsonModel + /// Solutions metrics based chart. + public partial class MetricsBasedChart : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(MetricsBasedChart)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -64,15 +64,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("replacementKey"u8); writer.WriteStringValue(ReplacementKey); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -81,22 +81,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - MetricsBasedChart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + MetricsBasedChart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MetricsBasedChart JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(MetricsBasedChart)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeMetricsBasedChart(document.RootElement, options); } - internal static MetricsBasedChart DeserializeMetricsBasedChart(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MetricsBasedChart DeserializeMetricsBasedChart(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -107,58 +112,56 @@ internal static MetricsBasedChart DeserializeMetricsBasedChart(JsonElement eleme string title = default; ChartFilterGroup filterGroup = default; string replacementKey = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("aggregationType"u8)) + if (prop.NameEquals("aggregationType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - aggregationType = new ChartAggregationType(property.Value.GetString()); + aggregationType = new ChartAggregationType(prop.Value.GetString()); continue; } - if (property.NameEquals("timeSpanDuration"u8)) + if (prop.NameEquals("timeSpanDuration"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - timeSpanDuration = property.Value.GetTimeSpan("P"); + timeSpanDuration = prop.Value.GetTimeSpan("P"); continue; } - if (property.NameEquals("title"u8)) + if (prop.NameEquals("title"u8)) { - title = property.Value.GetString(); + title = prop.Value.GetString(); continue; } - if (property.NameEquals("filterGroup"u8)) + if (prop.NameEquals("filterGroup"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - filterGroup = ChartFilterGroup.DeserializeChartFilterGroup(property.Value, options); + filterGroup = ChartFilterGroup.DeserializeChartFilterGroup(prop.Value, options); continue; } - if (property.NameEquals("replacementKey"u8)) + if (prop.NameEquals("replacementKey"u8)) { - replacementKey = property.Value.GetString(); + replacementKey = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new MetricsBasedChart( name, aggregationType, @@ -166,13 +169,16 @@ internal static MetricsBasedChart DeserializeMetricsBasedChart(JsonElement eleme title, filterGroup, replacementKey, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -182,15 +188,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - MetricsBasedChart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + MetricsBasedChart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MetricsBasedChart 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeMetricsBasedChart(document.RootElement, options); } default: @@ -198,6 +209,7 @@ MetricsBasedChart IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/MetricsBasedChart.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/MetricsBasedChart.cs index 2c947d3947cf..c7be1a6e5c12 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/MetricsBasedChart.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/MetricsBasedChart.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Solutions metrics based chart. public partial class MetricsBasedChart { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal MetricsBasedChart() @@ -57,8 +28,8 @@ internal MetricsBasedChart() /// Chart title. /// Filter group. /// Place holder used in HTML Content replace control with the content. - /// Keeps track of any properties unknown to the library. - internal MetricsBasedChart(string name, ChartAggregationType? aggregationType, TimeSpan? timeSpanDuration, string title, ChartFilterGroup filterGroup, string replacementKey, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal MetricsBasedChart(string name, ChartAggregationType? aggregationType, TimeSpan? timeSpanDuration, string title, ChartFilterGroup filterGroup, string replacementKey, IDictionary additionalBinaryDataProperties) { Name = name; AggregationType = aggregationType; @@ -66,26 +37,34 @@ internal MetricsBasedChart(string name, ChartAggregationType? aggregationType, T Title = title; FilterGroup = filterGroup; ReplacementKey = replacementKey; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Chart name. public string Name { get; } + /// Allowed values are Sum, Avg, Count, Min, Max. Default is Sum. public ChartAggregationType? AggregationType { get; } + /// Time span duration. public TimeSpan? TimeSpanDuration { get; } + /// Chart title. public string Title { get; } + /// Filter group. internal ChartFilterGroup FilterGroup { get; } - /// List of filters. - public IReadOnlyList Filter - { - get => FilterGroup?.Filter; - } /// Place holder used in HTML Content replace control with the content. public string ReplacementKey { get; } + + /// List of filters. + public IList Filter + { + get + { + return FilterGroup.Filter; + } + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ReplacementMapsResult.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ReplacementMapsResult.Serialization.cs index 5e4100ffd133..2f2ce7255a11 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ReplacementMapsResult.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ReplacementMapsResult.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class ReplacementMapsResult : IUtf8JsonSerializable, IJsonModel + /// Solution replacement maps. + public partial class ReplacementMapsResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,17 +29,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ReplacementMapsResult)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(WebResults)) { writer.WritePropertyName("webResults"u8); writer.WriteStartArray(); - foreach (var item in WebResults) + foreach (KBWebResult item in WebResults) { writer.WriteObjectValue(item, options); } @@ -48,7 +48,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("videos"u8); writer.WriteStartArray(); - foreach (var item in Videos) + foreach (SelfHelpVideo item in Videos) { writer.WriteObjectValue(item, options); } @@ -58,21 +58,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("videoGroups"u8); writer.WriteStartArray(); - foreach (var item in VideoGroups) + foreach (VideoGroupDetail item in VideoGroups) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -81,69 +81,73 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ReplacementMapsResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ReplacementMapsResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ReplacementMapsResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ReplacementMapsResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeReplacementMapsResult(document.RootElement, options); } - internal static ReplacementMapsResult DeserializeReplacementMapsResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ReplacementMapsResult DeserializeReplacementMapsResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList webResults = default; - IReadOnlyList videos = default; - IReadOnlyList videoGroups = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList webResults = default; + IList videos = default; + IList videoGroups = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("webResults"u8)) + if (prop.NameEquals("webResults"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(KBWebResult.DeserializeKBWebResult(item, options)); } webResults = array; continue; } - if (property.NameEquals("videos"u8)) + if (prop.NameEquals("videos"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(SelfHelpVideo.DeserializeSelfHelpVideo(item, options)); } videos = array; continue; } - if (property.NameEquals("videoGroups"u8)) + if (prop.NameEquals("videoGroups"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(VideoGroupDetail.DeserializeVideoGroupDetail(item, options)); } @@ -152,17 +156,19 @@ internal static ReplacementMapsResult DeserializeReplacementMapsResult(JsonEleme } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ReplacementMapsResult(webResults ?? new ChangeTrackingList(), videos ?? new ChangeTrackingList(), videoGroups ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new ReplacementMapsResult(webResults ?? new ChangeTrackingList(), videos ?? new ChangeTrackingList(), videoGroups ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -172,15 +178,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - ReplacementMapsResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ReplacementMapsResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ReplacementMapsResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeReplacementMapsResult(document.RootElement, options); } default: @@ -188,6 +199,7 @@ ReplacementMapsResult IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ReplacementMapsResult.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ReplacementMapsResult.cs index 495ee2580a4a..2e365bcf5f92 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ReplacementMapsResult.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ReplacementMapsResult.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Solution replacement maps. public partial class ReplacementMapsResult { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal ReplacementMapsResult() @@ -57,20 +29,22 @@ internal ReplacementMapsResult() /// Solution AzureKB results. /// Video solutions, which have the power to engage the customer by stimulating their senses. /// Group of Videos. - /// Keeps track of any properties unknown to the library. - internal ReplacementMapsResult(IReadOnlyList webResults, IReadOnlyList videos, IReadOnlyList videoGroups, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ReplacementMapsResult(IList webResults, IList videos, IList videoGroups, IDictionary additionalBinaryDataProperties) { WebResults = webResults; Videos = videos; VideoGroups = videoGroups; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Solution AzureKB results. - public IReadOnlyList WebResults { get; } + public IList WebResults { get; } + /// Video solutions, which have the power to engage the customer by stimulating their senses. - public IReadOnlyList Videos { get; } + public IList Videos { get; } + /// Group of Videos. - public IReadOnlyList VideoGroups { get; } + public IList VideoGroups { get; } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseConfig.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseConfig.Serialization.cs index bdf7a932e92e..5aa21aaa0cf4 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseConfig.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseConfig.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class ResponseConfig : IUtf8JsonSerializable, IJsonModel + /// The status of the resource. + public partial class ResponseConfig : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ResponseConfig)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Key)) { writer.WritePropertyName("key"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("value"u8); writer.WriteStringValue(Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,55 +61,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ResponseConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ResponseConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResponseConfig JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ResponseConfig)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeResponseConfig(document.RootElement, options); } - internal static ResponseConfig DeserializeResponseConfig(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ResponseConfig DeserializeResponseConfig(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string key = default; string value = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("key"u8)) + if (prop.NameEquals("key"u8)) { - key = property.Value.GetString(); + key = prop.Value.GetString(); continue; } - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - value = property.Value.GetString(); + value = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ResponseConfig(key, value, serializedAdditionalRawData); + return new ResponseConfig(key, value, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -119,15 +125,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - ResponseConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ResponseConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResponseConfig 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeResponseConfig(document.RootElement, options); } default: @@ -135,6 +146,7 @@ ResponseConfig IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseConfig.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseConfig.cs index 3ad050325966..462b9e6dca9a 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseConfig.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseConfig.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// The status of the resource. public partial class ResponseConfig { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal ResponseConfig() @@ -53,16 +24,17 @@ internal ResponseConfig() /// Initializes a new instance of . /// Unique string. /// Option description. - /// Keeps track of any properties unknown to the library. - internal ResponseConfig(string key, string value, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ResponseConfig(string key, string value, IDictionary additionalBinaryDataProperties) { Key = key; Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Unique string. public string Key { get; } + /// Option description. public string Value { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseValidationProperties.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseValidationProperties.Serialization.cs index 05479eaefab8..b0da7b8f150c 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseValidationProperties.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseValidationProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class ResponseValidationProperties : IUtf8JsonSerializable, IJsonModel + /// Troubleshooter step input response validation properties. + public partial class ResponseValidationProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ResponseValidationProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Regex)) { writer.WritePropertyName("regex"u8); @@ -59,15 +59,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("maxLength"u8); writer.WriteNumberValue(MaxLength.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -76,22 +76,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ResponseValidationProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ResponseValidationProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResponseValidationProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ResponseValidationProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeResponseValidationProperties(document.RootElement, options); } - internal static ResponseValidationProperties DeserializeResponseValidationProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ResponseValidationProperties DeserializeResponseValidationProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -101,66 +106,67 @@ internal static ResponseValidationProperties DeserializeResponseValidationProper bool? isRequired = default; string validationErrorMessage = default; long? maxLength = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("regex"u8)) + if (prop.NameEquals("regex"u8)) { - regex = property.Value.GetString(); + regex = prop.Value.GetString(); continue; } - if (property.NameEquals("validationScope"u8)) + if (prop.NameEquals("validationScope"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - validationScope = new TroubleshooterValidationScope(property.Value.GetString()); + validationScope = new TroubleshooterValidationScope(prop.Value.GetString()); continue; } - if (property.NameEquals("isRequired"u8)) + if (prop.NameEquals("isRequired"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isRequired = property.Value.GetBoolean(); + isRequired = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("validationErrorMessage"u8)) + if (prop.NameEquals("validationErrorMessage"u8)) { - validationErrorMessage = property.Value.GetString(); + validationErrorMessage = prop.Value.GetString(); continue; } - if (property.NameEquals("maxLength"u8)) + if (prop.NameEquals("maxLength"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - maxLength = property.Value.GetInt64(); + maxLength = prop.Value.GetInt64(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new ResponseValidationProperties( regex, validationScope, isRequired, validationErrorMessage, maxLength, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -170,15 +176,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - ResponseValidationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ResponseValidationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResponseValidationProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeResponseValidationProperties(document.RootElement, options); } default: @@ -186,6 +197,7 @@ ResponseValidationProperties IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseValidationProperties.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseValidationProperties.cs index a7b7c7a3c2cf..66f6f79dbdcc 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseValidationProperties.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/ResponseValidationProperties.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Troubleshooter step input response validation properties. public partial class ResponseValidationProperties { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal ResponseValidationProperties() @@ -56,25 +27,29 @@ internal ResponseValidationProperties() /// Default True. /// Validation Error Message. /// Max text input (open Ended Text). - /// Keeps track of any properties unknown to the library. - internal ResponseValidationProperties(string regex, TroubleshooterValidationScope? validationScope, bool? isRequired, string validationErrorMessage, long? maxLength, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ResponseValidationProperties(string regex, TroubleshooterValidationScope? validationScope, bool? isRequired, string validationErrorMessage, long? maxLength, IDictionary additionalBinaryDataProperties) { Regex = regex; ValidationScope = validationScope; IsRequired = isRequired; ValidationErrorMessage = validationErrorMessage; MaxLength = maxLength; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Regex used for the input validation. public string Regex { get; } + /// Validation scope. public TroubleshooterValidationScope? ValidationScope { get; } + /// Default True. public bool? IsRequired { get; } + /// Validation Error Message. public string ValidationErrorMessage { get; } + /// Max text input (open Ended Text). public long? MaxLength { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/RestartTroubleshooterResult.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/RestartTroubleshooterResult.Serialization.cs index b8a654c54d37..e38260985a2a 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/RestartTroubleshooterResult.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/RestartTroubleshooterResult.Serialization.cs @@ -9,14 +9,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class RestartTroubleshooterResult : IUtf8JsonSerializable, IJsonModel + /// Troubleshooter restart response. + public partial class RestartTroubleshooterResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,26 +30,25 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(RestartTroubleshooterResult)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(TroubleshooterResourceName)) { writer.WritePropertyName("troubleshooterResourceName"u8); writer.WriteStringValue(TroubleshooterResourceName); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -56,49 +57,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - RestartTroubleshooterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + RestartTroubleshooterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RestartTroubleshooterResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(RestartTroubleshooterResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeRestartTroubleshooterResult(document.RootElement, options); } - internal static RestartTroubleshooterResult DeserializeRestartTroubleshooterResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RestartTroubleshooterResult DeserializeRestartTroubleshooterResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string troubleshooterResourceName = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("troubleshooterResourceName"u8)) + if (prop.NameEquals("troubleshooterResourceName"u8)) { - troubleshooterResourceName = property.Value.GetString(); + troubleshooterResourceName = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new RestartTroubleshooterResult(troubleshooterResourceName, serializedAdditionalRawData); + return new RestartTroubleshooterResult(troubleshooterResourceName, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -108,15 +115,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - RestartTroubleshooterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + RestartTroubleshooterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RestartTroubleshooterResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeRestartTroubleshooterResult(document.RootElement, options); } default: @@ -124,6 +136,14 @@ RestartTroubleshooterResult IPersistableModel.Creat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static RestartTroubleshooterResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRestartTroubleshooterResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/RestartTroubleshooterResult.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/RestartTroubleshooterResult.cs index 00e063c91e8b..cf429368ffa8 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/RestartTroubleshooterResult.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/RestartTroubleshooterResult.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Troubleshooter restart response. public partial class RestartTroubleshooterResult { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal RestartTroubleshooterResult() @@ -52,11 +23,11 @@ internal RestartTroubleshooterResult() /// Initializes a new instance of . /// Updated TroubleshooterResource Name . - /// Keeps track of any properties unknown to the library. - internal RestartTroubleshooterResult(string troubleshooterResourceName, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal RestartTroubleshooterResult(string troubleshooterResourceName, IDictionary additionalBinaryDataProperties) { TroubleshooterResourceName = troubleshooterResourceName; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Updated TroubleshooterResource Name . diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpConfidence.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpConfidence.cs index 67357d88f0b9..9b314f335609 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpConfidence.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpConfidence.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,41 +15,59 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct SelfHelpConfidence : IEquatable { private readonly string _value; + private const string LowValue = "Low"; + private const string MediumValue = "Medium"; + private const string HighValue = "High"; /// Initializes a new instance of . + /// The value. /// is null. public SelfHelpConfidence(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string LowValue = "Low"; - private const string MediumValue = "Medium"; - private const string HighValue = "High"; + _value = value; + } - /// Low. + /// Gets the Low. public static SelfHelpConfidence Low { get; } = new SelfHelpConfidence(LowValue); - /// Medium. + + /// Gets the Medium. public static SelfHelpConfidence Medium { get; } = new SelfHelpConfidence(MediumValue); - /// High. + + /// Gets the High. public static SelfHelpConfidence High { get; } = new SelfHelpConfidence(HighValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(SelfHelpConfidence left, SelfHelpConfidence 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 !=(SelfHelpConfidence left, SelfHelpConfidence right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator SelfHelpConfidence(string value) => new SelfHelpConfidence(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator SelfHelpConfidence?(string value) => value == null ? null : new SelfHelpConfidence(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is SelfHelpConfidence other && Equals(other); - /// + + /// public bool Equals(SelfHelpConfidence 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInfo.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInfo.Serialization.cs index 5fd2f63f087e..c226a0b875d9 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInfo.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInfo.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SelfHelpDiagnosticInfo : IUtf8JsonSerializable, IJsonModel + /// Properties returned with in an insight. + public partial class SelfHelpDiagnosticInfo : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpDiagnosticInfo)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SolutionId)) { writer.WritePropertyName("solutionId"u8); @@ -48,7 +48,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("insights"u8); writer.WriteStartArray(); - foreach (var item in Insights) + foreach (SelfHelpDiagnosticInsight item in Insights) { writer.WriteObjectValue(item, options); } @@ -59,15 +59,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("error"u8); writer.WriteObjectValue(Error, options); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -76,22 +76,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SelfHelpDiagnosticInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpDiagnosticInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpDiagnosticInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpDiagnosticInfo)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpDiagnosticInfo(document.RootElement, options); } - internal static SelfHelpDiagnosticInfo DeserializeSelfHelpDiagnosticInfo(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpDiagnosticInfo DeserializeSelfHelpDiagnosticInfo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -100,60 +105,61 @@ internal static SelfHelpDiagnosticInfo DeserializeSelfHelpDiagnosticInfo(JsonEle SelfHelpDiagnosticStatus? status = default; IReadOnlyList insights = default; SelfHelpError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("solutionId"u8)) + if (prop.NameEquals("solutionId"u8)) { - solutionId = property.Value.GetString(); + solutionId = prop.Value.GetString(); continue; } - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - status = new SelfHelpDiagnosticStatus(property.Value.GetString()); + status = new SelfHelpDiagnosticStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("insights"u8)) + if (prop.NameEquals("insights"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(SelfHelpDiagnosticInsight.DeserializeSelfHelpDiagnosticInsight(item, options)); } insights = array; continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = SelfHelpError.DeserializeSelfHelpError(property.Value, options); + error = SelfHelpError.DeserializeSelfHelpError(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpDiagnosticInfo(solutionId, status, insights ?? new ChangeTrackingList(), error, serializedAdditionalRawData); + return new SelfHelpDiagnosticInfo(solutionId, status, insights ?? new ChangeTrackingList(), error, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -163,15 +169,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - SelfHelpDiagnosticInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpDiagnosticInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpDiagnosticInfo 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpDiagnosticInfo(document.RootElement, options); } default: @@ -179,6 +190,7 @@ SelfHelpDiagnosticInfo IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInfo.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInfo.cs index 9ab6ba706170..4e6af44ab047 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInfo.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInfo.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Properties returned with in an insight. public partial class SelfHelpDiagnosticInfo { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal SelfHelpDiagnosticInfo() @@ -56,22 +28,25 @@ internal SelfHelpDiagnosticInfo() /// Denotes the status of the diagnostic resource. /// The problems (if any) detected by this insight. /// Error definition. - /// Keeps track of any properties unknown to the library. - internal SelfHelpDiagnosticInfo(string solutionId, SelfHelpDiagnosticStatus? status, IReadOnlyList insights, SelfHelpError error, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SelfHelpDiagnosticInfo(string solutionId, SelfHelpDiagnosticStatus? status, IReadOnlyList insights, SelfHelpError error, IDictionary additionalBinaryDataProperties) { SolutionId = solutionId; Status = status; Insights = insights; Error = error; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Solution Id. public string SolutionId { get; } + /// Denotes the status of the diagnostic resource. public SelfHelpDiagnosticStatus? Status { get; } + /// The problems (if any) detected by this insight. public IReadOnlyList Insights { get; } + /// Error definition. public SelfHelpError Error { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInsight.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInsight.Serialization.cs index 1fab3a48f477..ed0b0d237d2b 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInsight.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInsight.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SelfHelpDiagnosticInsight : IUtf8JsonSerializable, IJsonModel + /// Detailed insights(s) obtained via the invocation of an insight diagnostic. + public partial class SelfHelpDiagnosticInsight : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpDiagnosticInsight)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Id)) { writer.WritePropertyName("id"u8); @@ -54,15 +54,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("importanceLevel"u8); writer.WriteStringValue(InsightImportanceLevel.Value.ToString()); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -71,22 +71,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SelfHelpDiagnosticInsight IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpDiagnosticInsight IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpDiagnosticInsight JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpDiagnosticInsight)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpDiagnosticInsight(document.RootElement, options); } - internal static SelfHelpDiagnosticInsight DeserializeSelfHelpDiagnosticInsight(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpDiagnosticInsight DeserializeSelfHelpDiagnosticInsight(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -94,48 +99,49 @@ internal static SelfHelpDiagnosticInsight DeserializeSelfHelpDiagnosticInsight(J string id = default; string title = default; string results = default; - SelfHelpImportanceLevel? importanceLevel = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + SelfHelpImportanceLevel? insightImportanceLevel = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = property.Value.GetString(); + id = prop.Value.GetString(); continue; } - if (property.NameEquals("title"u8)) + if (prop.NameEquals("title"u8)) { - title = property.Value.GetString(); + title = prop.Value.GetString(); continue; } - if (property.NameEquals("results"u8)) + if (prop.NameEquals("results"u8)) { - results = property.Value.GetString(); + results = prop.Value.GetString(); continue; } - if (property.NameEquals("importanceLevel"u8)) + if (prop.NameEquals("importanceLevel"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - importanceLevel = new SelfHelpImportanceLevel(property.Value.GetString()); + insightImportanceLevel = new SelfHelpImportanceLevel(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpDiagnosticInsight(id, title, results, importanceLevel, serializedAdditionalRawData); + return new SelfHelpDiagnosticInsight(id, title, results, insightImportanceLevel, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -145,15 +151,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO } } - SelfHelpDiagnosticInsight IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpDiagnosticInsight IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpDiagnosticInsight 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpDiagnosticInsight(document.RootElement, options); } default: @@ -161,6 +172,7 @@ SelfHelpDiagnosticInsight IPersistableModel.Create(Bi } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInsight.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInsight.cs index 4d48ca9d4f91..ca354561e4b4 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInsight.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInsight.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Detailed insights(s) obtained via the invocation of an insight diagnostic. public partial class SelfHelpDiagnosticInsight { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal SelfHelpDiagnosticInsight() @@ -55,22 +26,25 @@ internal SelfHelpDiagnosticInsight() /// This insight's title. /// Detailed result content. /// Importance level of the insight. - /// Keeps track of any properties unknown to the library. - internal SelfHelpDiagnosticInsight(string id, string title, string results, SelfHelpImportanceLevel? insightImportanceLevel, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SelfHelpDiagnosticInsight(string id, string title, string results, SelfHelpImportanceLevel? insightImportanceLevel, IDictionary additionalBinaryDataProperties) { Id = id; Title = title; Results = results; InsightImportanceLevel = insightImportanceLevel; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Article id. public string Id { get; } + /// This insight's title. public string Title { get; } + /// Detailed result content. public string Results { get; } + /// Importance level of the insight. public SelfHelpImportanceLevel? InsightImportanceLevel { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInvocation.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInvocation.Serialization.cs index 306c6dca3e5e..a02a54fe28c7 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInvocation.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInvocation.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SelfHelpDiagnosticInvocation : IUtf8JsonSerializable, IJsonModel + /// Solution Invocation with additional params needed for invocation. + public partial class SelfHelpDiagnosticInvocation : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpDiagnosticInvocation)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SolutionId)) { writer.WritePropertyName("solutionId"u8); @@ -46,19 +46,24 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in AdditionalParameters) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -67,64 +72,77 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SelfHelpDiagnosticInvocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpDiagnosticInvocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpDiagnosticInvocation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpDiagnosticInvocation)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpDiagnosticInvocation(document.RootElement, options); } - internal static SelfHelpDiagnosticInvocation DeserializeSelfHelpDiagnosticInvocation(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpDiagnosticInvocation DeserializeSelfHelpDiagnosticInvocation(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string solutionId = default; IDictionary additionalParameters = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("solutionId"u8)) + if (prop.NameEquals("solutionId"u8)) { - solutionId = property.Value.GetString(); + solutionId = prop.Value.GetString(); continue; } - if (property.NameEquals("additionalParameters"u8)) + if (prop.NameEquals("additionalParameters"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } additionalParameters = dictionary; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpDiagnosticInvocation(solutionId, additionalParameters ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new SelfHelpDiagnosticInvocation(solutionId, additionalParameters ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -134,15 +152,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - SelfHelpDiagnosticInvocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpDiagnosticInvocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpDiagnosticInvocation 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpDiagnosticInvocation(document.RootElement, options); } default: @@ -150,6 +173,7 @@ SelfHelpDiagnosticInvocation IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInvocation.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInvocation.cs index b0102a78f5f9..7677236e7336 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInvocation.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticInvocation.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Solution Invocation with additional params needed for invocation. public partial class SelfHelpDiagnosticInvocation { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public SelfHelpDiagnosticInvocation() @@ -54,16 +26,17 @@ public SelfHelpDiagnosticInvocation() /// Initializes a new instance of . /// Solution Id to invoke. /// Additional parameters required to invoke the solutionId. - /// Keeps track of any properties unknown to the library. - internal SelfHelpDiagnosticInvocation(string solutionId, IDictionary additionalParameters, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SelfHelpDiagnosticInvocation(string solutionId, IDictionary additionalParameters, IDictionary additionalBinaryDataProperties) { SolutionId = solutionId; AdditionalParameters = additionalParameters; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Solution Id to invoke. public string SolutionId { get; set; } + /// Additional parameters required to invoke the solutionId. public IDictionary AdditionalParameters { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticResourceProperties.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticResourceProperties.Serialization.cs new file mode 100644 index 000000000000..aee85839df0a --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticResourceProperties.Serialization.cs @@ -0,0 +1,254 @@ +// 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.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Diagnostic resource properties. + internal partial class SelfHelpDiagnosticResourceProperties : IJsonModel + { + /// 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(SelfHelpDiagnosticResourceProperties)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(GlobalParameters)) + { + writer.WritePropertyName("globalParameters"u8); + writer.WriteStartObject(); + foreach (var item in GlobalParameters) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsCollectionDefined(Insights)) + { + writer.WritePropertyName("insights"u8); + writer.WriteStartArray(); + foreach (SelfHelpDiagnosticInvocation item in Insights) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(AcceptedOn)) + { + writer.WritePropertyName("acceptedAt"u8); + writer.WriteStringValue(AcceptedOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Diagnostics)) + { + writer.WritePropertyName("diagnostics"u8); + writer.WriteStartArray(); + foreach (SelfHelpDiagnosticInfo item in Diagnostics) + { + 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. + SelfHelpDiagnosticResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpDiagnosticResourceProperties 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(SelfHelpDiagnosticResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSelfHelpDiagnosticResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpDiagnosticResourceProperties DeserializeSelfHelpDiagnosticResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary globalParameters = default; + IList insights = default; + DateTimeOffset? acceptedOn = default; + SelfHelpProvisioningState? provisioningState = default; + IReadOnlyList diagnostics = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("globalParameters"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()); + } + } + globalParameters = dictionary; + continue; + } + if (prop.NameEquals("insights"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(SelfHelpDiagnosticInvocation.DeserializeSelfHelpDiagnosticInvocation(item, options)); + } + insights = array; + continue; + } + if (prop.NameEquals("acceptedAt"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + acceptedOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new SelfHelpProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("diagnostics"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(SelfHelpDiagnosticInfo.DeserializeSelfHelpDiagnosticInfo(item, options)); + } + diagnostics = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SelfHelpDiagnosticResourceProperties( + globalParameters ?? new ChangeTrackingDictionary(), + insights ?? new ChangeTrackingList(), + acceptedOn, + provisioningState, + diagnostics ?? new ChangeTrackingList(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerSelfHelpContext.Default); + default: + throw new FormatException($"The model {nameof(SelfHelpDiagnosticResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpDiagnosticResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpDiagnosticResourceProperties 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 DeserializeSelfHelpDiagnosticResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SelfHelpDiagnosticResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticResourceProperties.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticResourceProperties.cs new file mode 100644 index 000000000000..6a475d88de16 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticResourceProperties.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.ResourceManager.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Diagnostic resource properties. + internal partial class SelfHelpDiagnosticResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SelfHelpDiagnosticResourceProperties() + { + GlobalParameters = new ChangeTrackingDictionary(); + Insights = new ChangeTrackingList(); + Diagnostics = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Global parameters is an optional map which can be used to add key and value to request body to improve the diagnostics results. + /// SolutionIds that are needed to be invoked. + /// Diagnostic Request Accepted time. + /// Status of diagnostic provisioning. + /// Array of Diagnostics. + /// Keeps track of any properties unknown to the library. + internal SelfHelpDiagnosticResourceProperties(IDictionary globalParameters, IList insights, DateTimeOffset? acceptedOn, SelfHelpProvisioningState? provisioningState, IReadOnlyList diagnostics, IDictionary additionalBinaryDataProperties) + { + GlobalParameters = globalParameters; + Insights = insights; + AcceptedOn = acceptedOn; + ProvisioningState = provisioningState; + Diagnostics = diagnostics; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Global parameters is an optional map which can be used to add key and value to request body to improve the diagnostics results. + public IDictionary GlobalParameters { get; } = new ChangeTrackingDictionary(); + + /// SolutionIds that are needed to be invoked. + public IList Insights { get; } = new ChangeTrackingList(); + + /// Diagnostic Request Accepted time. + public DateTimeOffset? AcceptedOn { get; } + + /// Status of diagnostic provisioning. + public SelfHelpProvisioningState? ProvisioningState { get; } + + /// Array of Diagnostics. + public IReadOnlyList Diagnostics { get; } = new ChangeTrackingList(); + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticStatus.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticStatus.cs index e700d961c1ce..8519f69941da 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticStatus.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiagnosticStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,47 +15,72 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct SelfHelpDiagnosticStatus : IEquatable { private readonly string _value; + /// Diagnostic creation failed. + private const string FailedValue = "Failed"; + /// Request is missing required inputs to run. + private const string MissingInputsValue = "MissingInputs"; + /// Diagnostic is still running. + private const string RunningValue = "Running"; + /// Diagnostic creation succeeded. + private const string SucceededValue = "Succeeded"; + /// Diagnostic was timed out. + private const string TimeoutValue = "Timeout"; /// Initializes a new instance of . + /// The value. /// is null. public SelfHelpDiagnosticStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string FailedValue = "Failed"; - private const string MissingInputsValue = "MissingInputs"; - private const string RunningValue = "Running"; - private const string SucceededValue = "Succeeded"; - private const string TimeoutValue = "Timeout"; + _value = value; + } /// Diagnostic creation failed. public static SelfHelpDiagnosticStatus Failed { get; } = new SelfHelpDiagnosticStatus(FailedValue); + /// Request is missing required inputs to run. public static SelfHelpDiagnosticStatus MissingInputs { get; } = new SelfHelpDiagnosticStatus(MissingInputsValue); + /// Diagnostic is still running. public static SelfHelpDiagnosticStatus Running { get; } = new SelfHelpDiagnosticStatus(RunningValue); + /// Diagnostic creation succeeded. public static SelfHelpDiagnosticStatus Succeeded { get; } = new SelfHelpDiagnosticStatus(SucceededValue); + /// Diagnostic was timed out. public static SelfHelpDiagnosticStatus Timeout { get; } = new SelfHelpDiagnosticStatus(TimeoutValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(SelfHelpDiagnosticStatus left, SelfHelpDiagnosticStatus 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 !=(SelfHelpDiagnosticStatus left, SelfHelpDiagnosticStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator SelfHelpDiagnosticStatus(string value) => new SelfHelpDiagnosticStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator SelfHelpDiagnosticStatus?(string value) => value == null ? null : new SelfHelpDiagnosticStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is SelfHelpDiagnosticStatus other && Equals(other); - /// + + /// public bool Equals(SelfHelpDiagnosticStatus 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiscoverySolutionResult.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiscoverySolutionResult.Serialization.cs index e6c04f706e7a..a11af8a4a6bb 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiscoverySolutionResult.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiscoverySolutionResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - internal partial class SelfHelpDiscoverySolutionResult : IUtf8JsonSerializable, IJsonModel + /// Discovery response. + internal partial class SelfHelpDiscoverySolutionResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal SelfHelpDiscoverySolutionResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpDiscoverySolutionResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (SelfHelpSolutionMetadata item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SelfHelpDiscoverySolutionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpDiscoverySolutionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpDiscoverySolutionResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpDiscoverySolutionResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpDiscoverySolutionResult(document.RootElement, options); } - internal static SelfHelpDiscoverySolutionResult DeserializeSelfHelpDiscoverySolutionResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpDiscoverySolutionResult DeserializeSelfHelpDiscoverySolutionResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(SelfHelpSolutionMetadata.DeserializeSelfHelpSolutionMetadata(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = new Uri(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpDiscoverySolutionResult(value, nextLink, serializedAdditionalRawData); + return new SelfHelpDiscoverySolutionResult(value, nextLink, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - SelfHelpDiscoverySolutionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpDiscoverySolutionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpDiscoverySolutionResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpDiscoverySolutionResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ SelfHelpDiscoverySolutionResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static SelfHelpDiscoverySolutionResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSelfHelpDiscoverySolutionResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiscoverySolutionResult.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiscoverySolutionResult.cs index 8498f79dc583..f89ba734e2d4 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiscoverySolutionResult.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpDiscoverySolutionResult.cs @@ -14,66 +14,30 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Discovery response. internal partial class SelfHelpDiscoverySolutionResult { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The SolutionMetadataResource items on this page. - /// is null. internal SelfHelpDiscoverySolutionResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The SolutionMetadataResource items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal SelfHelpDiscoverySolutionResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SelfHelpDiscoverySolutionResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal SelfHelpDiscoverySolutionResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The SolutionMetadataResource items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpError.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpError.Serialization.cs index aa88f1db38fe..43c5f1545197 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpError.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpError.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SelfHelpError : IUtf8JsonSerializable, IJsonModel + /// Error definition. + public partial class SelfHelpError : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpError)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(Code)) { writer.WritePropertyName("code"u8); @@ -53,21 +53,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("details"u8); writer.WriteStartArray(); - foreach (var item in Details) + foreach (SelfHelpError item in Details) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -76,57 +76,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SelfHelpError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpError JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpError)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpError(document.RootElement, options); } - internal static SelfHelpError DeserializeSelfHelpError(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpError DeserializeSelfHelpError(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string code = default; - string type = default; + string errorType = default; string message = default; IReadOnlyList details = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("code"u8)) + if (prop.NameEquals("code"u8)) { - code = property.Value.GetString(); + code = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = property.Value.GetString(); + errorType = prop.Value.GetString(); continue; } - if (property.NameEquals("message"u8)) + if (prop.NameEquals("message"u8)) { - message = property.Value.GetString(); + message = prop.Value.GetString(); continue; } - if (property.NameEquals("details"u8)) + if (prop.NameEquals("details"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DeserializeSelfHelpError(item, options)); } @@ -135,17 +139,19 @@ internal static SelfHelpError DeserializeSelfHelpError(JsonElement element, Mode } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpError(code, type, message, details ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new SelfHelpError(code, errorType, message, details ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -155,15 +161,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions optio } } - SelfHelpError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpError 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpError(document.RootElement, options); } default: @@ -171,6 +182,7 @@ SelfHelpError IPersistableModel.Create(BinaryData data, ModelRead } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpError.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpError.cs index 7a73ddd49985..b7572d1d0b6c 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpError.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpError.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Error definition. public partial class SelfHelpError { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal SelfHelpError() @@ -56,22 +28,25 @@ internal SelfHelpError() /// Service specific error type which serves as additional context for the error herein. /// Description of the error. /// An array of additional nested error response info objects, as described by this contract. - /// Keeps track of any properties unknown to the library. - internal SelfHelpError(string code, string errorType, string message, IReadOnlyList details, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SelfHelpError(string code, string errorType, string message, IReadOnlyList details, IDictionary additionalBinaryDataProperties) { Code = code; ErrorType = errorType; Message = message; Details = details; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Service specific error code which serves as the substatus for the HTTP error code. public string Code { get; } + /// Service specific error type which serves as additional context for the error herein. public string ErrorType { get; } + /// Description of the error. public string Message { get; } + /// An array of additional nested error response info objects, as described by this contract. public IReadOnlyList Details { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpFilter.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpFilter.Serialization.cs index be7cf174adf0..783562b4760d 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpFilter.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpFilter.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SelfHelpFilter : IUtf8JsonSerializable, IJsonModel + /// Filter criterion. + public partial class SelfHelpFilter : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpFilter)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("operator"u8); writer.WriteStringValue(Operator); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,22 +66,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SelfHelpFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpFilter)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpFilter(document.RootElement, options); } - internal static SelfHelpFilter DeserializeSelfHelpFilter(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpFilter DeserializeSelfHelpFilter(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,38 +94,39 @@ internal static SelfHelpFilter DeserializeSelfHelpFilter(JsonElement element, Mo string name = default; string values = default; string @operator = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("values"u8)) + if (prop.NameEquals("values"u8)) { - values = property.Value.GetString(); + values = prop.Value.GetString(); continue; } - if (property.NameEquals("operator"u8)) + if (prop.NameEquals("operator"u8)) { - @operator = property.Value.GetString(); + @operator = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpFilter(name, values, @operator, serializedAdditionalRawData); + return new SelfHelpFilter(name, values, @operator, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -130,15 +136,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - SelfHelpFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpFilter 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpFilter(document.RootElement, options); } default: @@ -146,6 +157,7 @@ SelfHelpFilter IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpFilter.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpFilter.cs index 51b52e3ee819..035aa4f834c2 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpFilter.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpFilter.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Filter criterion. public partial class SelfHelpFilter { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal SelfHelpFilter() @@ -54,19 +25,21 @@ internal SelfHelpFilter() /// Filter name. /// Filter values. /// Filter operator. - /// Keeps track of any properties unknown to the library. - internal SelfHelpFilter(string name, string values, string @operator, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SelfHelpFilter(string name, string values, string @operator, IDictionary additionalBinaryDataProperties) { Name = name; Values = values; Operator = @operator; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Filter name. public string Name { get; } + /// Filter values. public string Values { get; } + /// Filter operator. public string Operator { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpImportanceLevel.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpImportanceLevel.cs index 1cc87f0b0a6f..26f9abbf23d3 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpImportanceLevel.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpImportanceLevel.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,41 +15,62 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct SelfHelpImportanceLevel : IEquatable { private readonly string _value; + /// A critical insight has been found after running the diagnostic. + private const string CriticalValue = "Critical"; + /// A warning insight has been found after running the diagnostic. + private const string WarningValue = "Warning"; + /// An information insight has been found after running the diagnostic. + private const string InformationValue = "Information"; /// Initializes a new instance of . + /// The value. /// is null. public SelfHelpImportanceLevel(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string CriticalValue = "Critical"; - private const string WarningValue = "Warning"; - private const string InformationValue = "Information"; + _value = value; + } /// A critical insight has been found after running the diagnostic. public static SelfHelpImportanceLevel Critical { get; } = new SelfHelpImportanceLevel(CriticalValue); + /// A warning insight has been found after running the diagnostic. public static SelfHelpImportanceLevel Warning { get; } = new SelfHelpImportanceLevel(WarningValue); + /// An information insight has been found after running the diagnostic. public static SelfHelpImportanceLevel Information { get; } = new SelfHelpImportanceLevel(InformationValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(SelfHelpImportanceLevel left, SelfHelpImportanceLevel 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 !=(SelfHelpImportanceLevel left, SelfHelpImportanceLevel right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator SelfHelpImportanceLevel(string value) => new SelfHelpImportanceLevel(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator SelfHelpImportanceLevel?(string value) => value == null ? null : new SelfHelpImportanceLevel(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is SelfHelpImportanceLevel other && Equals(other); - /// + + /// public bool Equals(SelfHelpImportanceLevel 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpName.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpName.cs index 69a510f175a3..77f61637bdf7 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpName.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpName.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,41 +15,59 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct SelfHelpName : IEquatable { private readonly string _value; + private const string SolutionIdValue = "SolutionId"; + private const string ProblemClassificationIdValue = "ProblemClassificationId"; + private const string ReplacementKeyValue = "ReplacementKey"; /// Initializes a new instance of . + /// The value. /// is null. public SelfHelpName(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SolutionIdValue = "SolutionId"; - private const string ProblemClassificationIdValue = "ProblemClassificationId"; - private const string ReplacementKeyValue = "ReplacementKey"; + _value = value; + } - /// SolutionId. + /// Gets the SolutionId. public static SelfHelpName SolutionId { get; } = new SelfHelpName(SolutionIdValue); - /// ProblemClassificationId. + + /// Gets the ProblemClassificationId. public static SelfHelpName ProblemClassificationId { get; } = new SelfHelpName(ProblemClassificationIdValue); - /// ReplacementKey. + + /// Gets the ReplacementKey. public static SelfHelpName ReplacementKey { get; } = new SelfHelpName(ReplacementKeyValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(SelfHelpName left, SelfHelpName 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 !=(SelfHelpName left, SelfHelpName right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator SelfHelpName(string value) => new SelfHelpName(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator SelfHelpName?(string value) => value == null ? null : new SelfHelpName(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is SelfHelpName other && Equals(other); - /// + + /// public bool Equals(SelfHelpName 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityContent.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityContent.Serialization.cs deleted file mode 100644 index 17774c3051e8..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityContent.Serialization.cs +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.SelfHelp.Models -{ - public partial class SelfHelpNameAvailabilityContent : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SelfHelpNameAvailabilityContent)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(ResourceName)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(ResourceName); - } - if (Optional.IsDefined(ResourceType)) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType.Value); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - SelfHelpNameAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SelfHelpNameAvailabilityContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSelfHelpNameAvailabilityContent(document.RootElement, options); - } - - internal static SelfHelpNameAvailabilityContent DeserializeSelfHelpNameAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - ResourceType? type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - type = new ResourceType(property.Value.GetString()); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpNameAvailabilityContent(name, type, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerSelfHelpContext.Default); - default: - throw new FormatException($"The model {nameof(SelfHelpNameAvailabilityContent)} does not support writing '{options.Format}' format."); - } - } - - SelfHelpNameAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeSelfHelpNameAvailabilityContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SelfHelpNameAvailabilityContent)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityContent.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityContent.cs deleted file mode 100644 index 933d1df8c907..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityContent.cs +++ /dev/null @@ -1,70 +0,0 @@ -// 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.SelfHelp.Models -{ - /// The check availability request body. - public partial class SelfHelpNameAvailabilityContent - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public SelfHelpNameAvailabilityContent() - { - } - - /// Initializes a new instance of . - /// The name of the resource for which availability needs to be checked. - /// The resource type. - /// Keeps track of any properties unknown to the library. - internal SelfHelpNameAvailabilityContent(string resourceName, ResourceType? resourceType, IDictionary serializedAdditionalRawData) - { - ResourceName = resourceName; - ResourceType = resourceType; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The name of the resource for which availability needs to be checked. - public string ResourceName { get; set; } - /// The resource type. - public ResourceType? ResourceType { get; set; } - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityResult.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityResult.Serialization.cs deleted file mode 100644 index 90895389ed45..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityResult.Serialization.cs +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.SelfHelp.Models -{ - public partial class SelfHelpNameAvailabilityResult : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SelfHelpNameAvailabilityResult)} does not support writing '{format}' format."); - } - - if (Optional.IsDefined(IsNameAvailable)) - { - writer.WritePropertyName("nameAvailable"u8); - writer.WriteBooleanValue(IsNameAvailable.Value); - } - if (Optional.IsDefined(Reason)) - { - writer.WritePropertyName("reason"u8); - writer.WriteStringValue(Reason); - } - if (Optional.IsDefined(Message)) - { - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - SelfHelpNameAvailabilityResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SelfHelpNameAvailabilityResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSelfHelpNameAvailabilityResult(document.RootElement, options); - } - - internal static SelfHelpNameAvailabilityResult DeserializeSelfHelpNameAvailabilityResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - bool? nameAvailable = default; - string reason = default; - string message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("nameAvailable"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - nameAvailable = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("reason"u8)) - { - reason = property.Value.GetString(); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpNameAvailabilityResult(nameAvailable, reason, message, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerSelfHelpContext.Default); - default: - throw new FormatException($"The model {nameof(SelfHelpNameAvailabilityResult)} does not support writing '{options.Format}' format."); - } - } - - SelfHelpNameAvailabilityResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeSelfHelpNameAvailabilityResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SelfHelpNameAvailabilityResult)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityResult.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityResult.cs deleted file mode 100644 index dbca1b802986..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNameAvailabilityResult.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.SelfHelp.Models -{ - /// Response for whether the requested resource name is available or not. - public partial class SelfHelpNameAvailabilityResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - internal SelfHelpNameAvailabilityResult() - { - } - - /// Initializes a new instance of . - /// Returns true or false depending on the availability of the name. - /// Reason for why value is not available. This field is returned if nameAvailable is false. - /// Gets an error message explaining the 'reason' value with more details. This field is returned iif nameAvailable is false. - /// Keeps track of any properties unknown to the library. - internal SelfHelpNameAvailabilityResult(bool? isNameAvailable, string reason, string message, IDictionary serializedAdditionalRawData) - { - IsNameAvailable = isNameAvailable; - Reason = reason; - Message = message; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Returns true or false depending on the availability of the name. - public bool? IsNameAvailable { get; } - /// Reason for why value is not available. This field is returned if nameAvailable is false. - public string Reason { get; } - /// Gets an error message explaining the 'reason' value with more details. This field is returned iif nameAvailable is false. - public string Message { get; } - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNlpSolutions.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNlpSolutions.Serialization.cs new file mode 100644 index 000000000000..87393bf1df3b --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNlpSolutions.Serialization.cs @@ -0,0 +1,231 @@ +// 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.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Nlp metadata. + internal partial class SelfHelpNlpSolutions : IJsonModel + { + /// 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(SelfHelpNlpSolutions)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ProblemTitle)) + { + writer.WritePropertyName("problemTitle"u8); + writer.WriteStringValue(ProblemTitle); + } + if (Optional.IsDefined(ProblemDescription)) + { + writer.WritePropertyName("problemDescription"u8); + writer.WriteStringValue(ProblemDescription); + } + if (Optional.IsDefined(ServiceId)) + { + writer.WritePropertyName("serviceId"u8); + writer.WriteStringValue(ServiceId); + } + if (Optional.IsDefined(ProblemClassificationId)) + { + writer.WritePropertyName("problemClassificationId"u8); + writer.WriteStringValue(ProblemClassificationId); + } + if (Optional.IsCollectionDefined(Solutions)) + { + writer.WritePropertyName("solutions"u8); + writer.WriteStartArray(); + foreach (SolutionMetadataProperties item in Solutions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(RelatedServices)) + { + writer.WritePropertyName("relatedServices"u8); + writer.WriteStartArray(); + foreach (ClassificationService item in RelatedServices) + { + 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. + SelfHelpNlpSolutions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpNlpSolutions 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(SelfHelpNlpSolutions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSelfHelpNlpSolutions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpNlpSolutions DeserializeSelfHelpNlpSolutions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string problemTitle = default; + string problemDescription = default; + string serviceId = default; + string problemClassificationId = default; + IList solutions = default; + IList relatedServices = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("problemTitle"u8)) + { + problemTitle = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("problemDescription"u8)) + { + problemDescription = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("serviceId"u8)) + { + serviceId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("problemClassificationId"u8)) + { + problemClassificationId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("solutions"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(SolutionMetadataProperties.DeserializeSolutionMetadataProperties(item, options)); + } + solutions = array; + continue; + } + if (prop.NameEquals("relatedServices"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ClassificationService.DeserializeClassificationService(item, options)); + } + relatedServices = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SelfHelpNlpSolutions( + problemTitle, + problemDescription, + serviceId, + problemClassificationId, + solutions ?? new ChangeTrackingList(), + relatedServices ?? new ChangeTrackingList(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerSelfHelpContext.Default); + default: + throw new FormatException($"The model {nameof(SelfHelpNlpSolutions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpNlpSolutions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpNlpSolutions 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 DeserializeSelfHelpNlpSolutions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SelfHelpNlpSolutions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNlpSolutions.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNlpSolutions.cs new file mode 100644 index 000000000000..2ff24c42025e --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpNlpSolutions.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Nlp metadata. + internal partial class SelfHelpNlpSolutions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SelfHelpNlpSolutions() + { + Solutions = new ChangeTrackingList(); + RelatedServices = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Title of the problem classification. + /// Description of the problem classification. + /// Id of the service (https://learn.microsoft.com/en-us/rest/api/support/services?view=rest-support-2020-04-01) that may be used to create a support ticket. + /// Id of the ProblemClassification (https://learn.microsoft.com/en-us/rest/api/support/problem-classifications?view=rest-support-2020-04-01) that may be used to create a support ticket. + /// The list of solution metadata. + /// The set of services that are most likely related to the request. If relatedServices is included in the response then solutions may not be discovered until the client calls a second time specifying one of the service Ids in the relatedServices object. + /// Keeps track of any properties unknown to the library. + internal SelfHelpNlpSolutions(string problemTitle, string problemDescription, string serviceId, string problemClassificationId, IList solutions, IList relatedServices, IDictionary additionalBinaryDataProperties) + { + ProblemTitle = problemTitle; + ProblemDescription = problemDescription; + ServiceId = serviceId; + ProblemClassificationId = problemClassificationId; + Solutions = solutions; + RelatedServices = relatedServices; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Title of the problem classification. + public string ProblemTitle { get; set; } + + /// Description of the problem classification. + public string ProblemDescription { get; set; } + + /// Id of the service (https://learn.microsoft.com/en-us/rest/api/support/services?view=rest-support-2020-04-01) that may be used to create a support ticket. + public string ServiceId { get; set; } + + /// Id of the ProblemClassification (https://learn.microsoft.com/en-us/rest/api/support/problem-classifications?view=rest-support-2020-04-01) that may be used to create a support ticket. + public string ProblemClassificationId { get; set; } + + /// The list of solution metadata. + public IList Solutions { get; } = new ChangeTrackingList(); + + /// The set of services that are most likely related to the request. If relatedServices is included in the response then solutions may not be discovered until the client calls a second time specifying one of the service Ids in the relatedServices object. + public IList RelatedServices { get; } = new ChangeTrackingList(); + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpProvisioningState.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpProvisioningState.cs index b62503459457..c2eb28de8359 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpProvisioningState.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpProvisioningState.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,47 +15,72 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct SelfHelpProvisioningState : IEquatable { private readonly string _value; + /// All Diagnostics in the Batch succeeded. + private const string SucceededValue = "Succeeded"; + /// Some Diagnostics are still running or failed. + private const string PartialCompleteValue = "PartialComplete"; + /// All Diagnostics failed to run. + private const string FailedValue = "Failed"; + /// All Diagnostics are still running. + private const string RunningValue = "Running"; + /// When Diagnostic request gets canceled. + private const string CanceledValue = "Canceled"; /// Initializes a new instance of . + /// The value. /// is null. public SelfHelpProvisioningState(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SucceededValue = "Succeeded"; - private const string PartialCompleteValue = "PartialComplete"; - private const string FailedValue = "Failed"; - private const string RunningValue = "Running"; - private const string CanceledValue = "Canceled"; + _value = value; + } /// All Diagnostics in the Batch succeeded. public static SelfHelpProvisioningState Succeeded { get; } = new SelfHelpProvisioningState(SucceededValue); + /// Some Diagnostics are still running or failed. public static SelfHelpProvisioningState PartialComplete { get; } = new SelfHelpProvisioningState(PartialCompleteValue); + /// All Diagnostics failed to run. public static SelfHelpProvisioningState Failed { get; } = new SelfHelpProvisioningState(FailedValue); + /// All Diagnostics are still running. public static SelfHelpProvisioningState Running { get; } = new SelfHelpProvisioningState(RunningValue); + /// When Diagnostic request gets canceled. public static SelfHelpProvisioningState Canceled { get; } = new SelfHelpProvisioningState(CanceledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(SelfHelpProvisioningState left, SelfHelpProvisioningState 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 !=(SelfHelpProvisioningState left, SelfHelpProvisioningState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator SelfHelpProvisioningState(string value) => new SelfHelpProvisioningState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator SelfHelpProvisioningState?(string value) => value == null ? null : new SelfHelpProvisioningState(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is SelfHelpProvisioningState other && Equals(other); - /// + + /// public bool Equals(SelfHelpProvisioningState 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSection.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSection.Serialization.cs index 78b68f2b5384..dc92da13d150 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSection.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSection.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SelfHelpSection : IUtf8JsonSerializable, IJsonModel + /// Part of the solution and are dividers in the solution rendering. + public partial class SelfHelpSection : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpSection)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Title)) { writer.WritePropertyName("title"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("replacementMaps"u8); writer.WriteObjectValue(ReplacementMaps, options); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,22 +66,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SelfHelpSection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpSection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpSection JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpSection)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpSection(document.RootElement, options); } - internal static SelfHelpSection DeserializeSelfHelpSection(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpSection DeserializeSelfHelpSection(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,42 +94,43 @@ internal static SelfHelpSection DeserializeSelfHelpSection(JsonElement element, string title = default; string content = default; SolutionReplacementMaps replacementMaps = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("title"u8)) + if (prop.NameEquals("title"u8)) { - title = property.Value.GetString(); + title = prop.Value.GetString(); continue; } - if (property.NameEquals("content"u8)) + if (prop.NameEquals("content"u8)) { - content = property.Value.GetString(); + content = prop.Value.GetString(); continue; } - if (property.NameEquals("replacementMaps"u8)) + if (prop.NameEquals("replacementMaps"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - replacementMaps = SolutionReplacementMaps.DeserializeSolutionReplacementMaps(property.Value, options); + replacementMaps = SolutionReplacementMaps.DeserializeSolutionReplacementMaps(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpSection(title, content, replacementMaps, serializedAdditionalRawData); + return new SelfHelpSection(title, content, replacementMaps, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -134,15 +140,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - SelfHelpSection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpSection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpSection 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpSection(document.RootElement, options); } default: @@ -150,6 +161,7 @@ SelfHelpSection IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSection.cs index 4774398ddfc4..9048b831b424 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSection.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSection.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Part of the solution and are dividers in the solution rendering. public partial class SelfHelpSection { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal SelfHelpSection() @@ -54,19 +25,21 @@ internal SelfHelpSection() /// Solution sections title. /// Solution sections content. /// Solution replacement maps. - /// Keeps track of any properties unknown to the library. - internal SelfHelpSection(string title, string content, SolutionReplacementMaps replacementMaps, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SelfHelpSection(string title, string content, SolutionReplacementMaps replacementMaps, IDictionary additionalBinaryDataProperties) { Title = title; Content = content; ReplacementMaps = replacementMaps; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Solution sections title. public string Title { get; } + /// Solution sections content. public string Content { get; } + /// Solution replacement maps. public SolutionReplacementMaps ReplacementMaps { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionMetadata.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionMetadata.Serialization.cs index 90f98ade4e0c..d1622abf5ff1 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionMetadata.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionMetadata.Serialization.cs @@ -12,11 +12,15 @@ using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SelfHelpSolutionMetadata : IUtf8JsonSerializable, IJsonModel + /// Metadata resource. + public partial class SelfHelpSolutionMetadata : ResourceData, IJsonModel { + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,126 +32,114 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpSolutionMetadata)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Solutions)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("solutions"u8); - writer.WriteStartArray(); - foreach (var item in Solutions) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - writer.WriteEndObject(); } - SelfHelpSolutionMetadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpSolutionMetadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SelfHelpSolutionMetadata)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpSolutionMetadata)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpSolutionMetadata(document.RootElement, options); } - internal static SelfHelpSolutionMetadata DeserializeSelfHelpSolutionMetadata(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpSolutionMetadata DeserializeSelfHelpSolutionMetadata(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - IList solutions = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + SelfHelpSolutions properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("solutions"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(SolutionMetadataProperties.DeserializeSolutionMetadataProperties(item, options)); - } - solutions = array; - continue; - } - } + properties = SelfHelpSolutions.DeserializeSelfHelpSolutions(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new SelfHelpSolutionMetadata( id, name, - type, + resourceType, systemData, - solutions ?? new ChangeTrackingList(), - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -157,15 +149,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - SelfHelpSolutionMetadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpSolutionMetadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SelfHelpSolutionMetadata)PersistableModelCreateCore(data, options); + /// 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpSolutionMetadata(document.RootElement, options); } default: @@ -173,6 +170,7 @@ SelfHelpSolutionMetadata IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionMetadata.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionMetadata.cs index 8d6d12d8ef18..52546fb758f1 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionMetadata.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionMetadata.cs @@ -15,58 +15,41 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Metadata resource. public partial class SelfHelpSolutionMetadata : ResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public SelfHelpSolutionMetadata() { - Solutions = new ChangeTrackingList(); } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// List of metadata. - /// Keeps track of any properties unknown to the library. - internal SelfHelpSolutionMetadata(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IList solutions, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + /// 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. + /// Solution metadata Resource properties. + internal SelfHelpSolutionMetadata(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, SelfHelpSolutions properties) : base(id, name, resourceType, systemData) { - Solutions = solutions; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } + /// Solution metadata Resource properties. + internal SelfHelpSolutions Properties { get; set; } + /// List of metadata. - public IList Solutions { get; } + public IList Solutions + { + get + { + if (Properties is null) + { + Properties = new SelfHelpSolutions(); + } + return Properties.Solutions; + } + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionPatch.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionPatch.Serialization.cs index 76c29830be30..63b3be74bc42 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionPatch.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionPatch.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SelfHelpSolutionPatch : IUtf8JsonSerializable, IJsonModel + /// Solution PatchRequest body. + public partial class SelfHelpSolutionPatch : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,80 +30,25 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpSolutionPatch)} does not support writing '{format}' format."); } - - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(TriggerCriteria)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("triggerCriteria"u8); - writer.WriteStartArray(); - foreach (var item in TriggerCriteria) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsCollectionDefined(Parameters)) - { - writer.WritePropertyName("parameters"u8); - writer.WriteStartObject(); - foreach (var item in Parameters) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - if (options.Format != "W" && Optional.IsDefined(SolutionId)) - { - writer.WritePropertyName("solutionId"u8); - writer.WriteStringValue(SolutionId); - } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) - { - writer.WritePropertyName("provisioningState"u8); - writer.WriteStringValue(ProvisioningState.Value.ToString()); - } - if (options.Format != "W" && Optional.IsDefined(Title)) - { - writer.WritePropertyName("title"u8); - writer.WriteStringValue(Title); - } - if (options.Format != "W" && Optional.IsDefined(Content)) - { - writer.WritePropertyName("content"u8); - writer.WriteStringValue(Content); - } - if (options.Format != "W" && Optional.IsDefined(ReplacementMaps)) - { - writer.WritePropertyName("replacementMaps"u8); - writer.WriteObjectValue(ReplacementMaps, options); - } - if (options.Format != "W" && Optional.IsCollectionDefined(Sections)) - { - writer.WritePropertyName("sections"u8); - writer.WriteStartArray(); - foreach (var item in Sections) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -110,147 +57,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SelfHelpSolutionPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpSolutionPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpSolutionPatch JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpSolutionPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpSolutionPatch(document.RootElement, options); } - internal static SelfHelpSolutionPatch DeserializeSelfHelpSolutionPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpSolutionPatch DeserializeSelfHelpSolutionPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IList triggerCriteria = default; - IDictionary parameters = default; - string solutionId = default; - SolutionProvisioningState? provisioningState = default; - string title = default; - string content = default; - SolutionReplacementMaps replacementMaps = default; - IReadOnlyList sections = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + SolutionResourceProperties properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("triggerCriteria"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(SolutionTriggerCriterion.DeserializeSolutionTriggerCriterion(item, options)); - } - triggerCriteria = array; - continue; - } - if (property0.NameEquals("parameters"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property1 in property0.Value.EnumerateObject()) - { - dictionary.Add(property1.Name, property1.Value.GetString()); - } - parameters = dictionary; - continue; - } - if (property0.NameEquals("solutionId"u8)) - { - solutionId = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("provisioningState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new SolutionProvisioningState(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("title"u8)) - { - title = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("content"u8)) - { - content = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("replacementMaps"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - replacementMaps = SolutionReplacementMaps.DeserializeSolutionReplacementMaps(property0.Value, options); - continue; - } - if (property0.NameEquals("sections"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(SelfHelpSection.DeserializeSelfHelpSection(item, options)); - } - sections = array; - continue; - } - } + properties = SolutionResourceProperties.DeserializeSolutionResourceProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpSolutionPatch( - triggerCriteria ?? new ChangeTrackingList(), - parameters ?? new ChangeTrackingDictionary(), - solutionId, - provisioningState, - title, - content, - replacementMaps, - sections ?? new ChangeTrackingList(), - serializedAdditionalRawData); + return new SelfHelpSolutionPatch(properties, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -260,15 +119,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - SelfHelpSolutionPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpSolutionPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpSolutionPatch 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpSolutionPatch(document.RootElement, options); } default: @@ -276,6 +140,19 @@ SelfHelpSolutionPatch IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(SelfHelpSolutionPatch selfHelpSolutionPatch) + { + if (selfHelpSolutionPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(selfHelpSolutionPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionPatch.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionPatch.cs index a195e255bc57..64ce4ac2e762 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionPatch.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionPatch.cs @@ -13,84 +13,108 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Solution PatchRequest body. public partial class SelfHelpSolutionPatch { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public SelfHelpSolutionPatch() { - TriggerCriteria = new ChangeTrackingList(); - Parameters = new ChangeTrackingDictionary(); - Sections = new ChangeTrackingList(); } /// Initializes a new instance of . - /// Solution request trigger criteria. - /// Client input parameters to run Solution. - /// Solution Id to identify single solution. - /// Status of solution provisioning. - /// The title. - /// The HTML content that needs to be rendered and shown to customer. - /// Solution replacement maps. - /// List of section object. - /// Keeps track of any properties unknown to the library. - internal SelfHelpSolutionPatch(IList triggerCriteria, IDictionary parameters, string solutionId, SolutionProvisioningState? provisioningState, string title, string content, SolutionReplacementMaps replacementMaps, IReadOnlyList sections, IDictionary serializedAdditionalRawData) + /// Solution result. + /// Keeps track of any properties unknown to the library. + internal SelfHelpSolutionPatch(SolutionResourceProperties properties, IDictionary additionalBinaryDataProperties) { - TriggerCriteria = triggerCriteria; - Parameters = parameters; - SolutionId = solutionId; - ProvisioningState = provisioningState; - Title = title; - Content = content; - ReplacementMaps = replacementMaps; - Sections = sections; - _serializedAdditionalRawData = serializedAdditionalRawData; + Properties = properties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } + /// Solution result. + internal SolutionResourceProperties Properties { get; set; } + /// Solution request trigger criteria. - public IList TriggerCriteria { get; } + public IList TriggerCriteria + { + get + { + if (Properties is null) + { + Properties = new SolutionResourceProperties(); + } + return Properties.TriggerCriteria; + } + } + /// Client input parameters to run Solution. - public IDictionary Parameters { get; } + public IDictionary Parameters + { + get + { + if (Properties is null) + { + Properties = new SolutionResourceProperties(); + } + return Properties.Parameters; + } + } + /// Solution Id to identify single solution. - public string SolutionId { get; } + public string SolutionId + { + get + { + return Properties is null ? default : Properties.SolutionId; + } + } + /// Status of solution provisioning. - public SolutionProvisioningState? ProvisioningState { get; } + public SolutionProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + /// The title. - public string Title { get; } + public string Title + { + get + { + return Properties is null ? default : Properties.Title; + } + } + /// The HTML content that needs to be rendered and shown to customer. - public string Content { get; } + public string Content + { + get + { + return Properties is null ? default : Properties.Content; + } + } + /// Solution replacement maps. - public SolutionReplacementMaps ReplacementMaps { get; } + public SolutionReplacementMaps ReplacementMaps + { + get + { + return Properties is null ? default : Properties.ReplacementMaps; + } + } + /// List of section object. - public IReadOnlyList Sections { get; } + public IReadOnlyList Sections + { + get + { + if (Properties is null) + { + Properties = new SolutionResourceProperties(); + } + return Properties.Sections; + } + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionResult.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionResult.Serialization.cs deleted file mode 100644 index 48dbbd1948e3..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionResult.Serialization.cs +++ /dev/null @@ -1,232 +0,0 @@ -// 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.Models; - -namespace Azure.ResourceManager.SelfHelp.Models -{ - public partial class SelfHelpSolutionResult : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SelfHelpSolutionResult)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (options.Format != "W" && Optional.IsDefined(SolutionId)) - { - writer.WritePropertyName("solutionId"u8); - writer.WriteStringValue(SolutionId); - } - if (options.Format != "W" && Optional.IsDefined(Title)) - { - writer.WritePropertyName("title"u8); - writer.WriteStringValue(Title); - } - if (options.Format != "W" && Optional.IsDefined(Content)) - { - writer.WritePropertyName("content"u8); - writer.WriteStringValue(Content); - } - if (options.Format != "W" && Optional.IsDefined(ReplacementMaps)) - { - writer.WritePropertyName("replacementMaps"u8); - writer.WriteObjectValue(ReplacementMaps, options); - } - if (options.Format != "W" && Optional.IsCollectionDefined(Sections)) - { - writer.WritePropertyName("sections"u8); - writer.WriteStartArray(); - foreach (var item in Sections) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - writer.WriteEndObject(); - } - - SelfHelpSolutionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SelfHelpSolutionResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSelfHelpSolutionResult(document.RootElement, options); - } - - internal static SelfHelpSolutionResult DeserializeSelfHelpSolutionResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ResourceIdentifier id = default; - string name = default; - ResourceType type = default; - SystemData systemData = default; - string solutionId = default; - string title = default; - string content = default; - ReplacementMapsResult replacementMaps = default; - IReadOnlyList sections = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new ResourceType(property.Value.GetString()); - continue; - } - if (property.NameEquals("systemData"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); - continue; - } - if (property.NameEquals("properties"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("solutionId"u8)) - { - solutionId = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("title"u8)) - { - title = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("content"u8)) - { - content = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("replacementMaps"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - replacementMaps = ReplacementMapsResult.DeserializeReplacementMapsResult(property0.Value, options); - continue; - } - if (property0.NameEquals("sections"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(SolutionSection.DeserializeSolutionSection(item, options)); - } - sections = array; - continue; - } - } - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpSolutionResult( - id, - name, - type, - systemData, - solutionId, - title, - content, - replacementMaps, - sections ?? new ChangeTrackingList(), - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerSelfHelpContext.Default); - default: - throw new FormatException($"The model {nameof(SelfHelpSolutionResult)} does not support writing '{options.Format}' format."); - } - } - - SelfHelpSolutionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeSelfHelpSolutionResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SelfHelpSolutionResult)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionResult.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionResult.cs deleted file mode 100644 index 71470a45422b..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionResult.cs +++ /dev/null @@ -1,88 +0,0 @@ -// 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.SelfHelp.Models -{ - /// Self Help Solution response. - public partial class SelfHelpSolutionResult : ResourceData - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public SelfHelpSolutionResult() - { - Sections = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. - /// The title. - /// The HTML content that needs to be rendered and shown to customer. - /// Solution replacement maps. - /// List of section object. - /// Keeps track of any properties unknown to the library. - internal SelfHelpSolutionResult(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string solutionId, string title, string content, ReplacementMapsResult replacementMaps, IReadOnlyList sections, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) - { - SolutionId = solutionId; - Title = title; - Content = content; - ReplacementMaps = replacementMaps; - Sections = sections; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. - public string SolutionId { get; } - /// The title. - public string Title { get; } - /// The HTML content that needs to be rendered and shown to customer. - public string Content { get; } - /// Solution replacement maps. - public ReplacementMapsResult ReplacementMaps { get; } - /// List of section object. - public IReadOnlyList Sections { get; } - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionType.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionType.cs index fb9718c646bd..ffd4a862ea97 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionType.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutionType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,44 +15,67 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct SelfHelpSolutionType : IEquatable { private readonly string _value; + /// Diagnostics resource type. + private const string DiagnosticsValue = "Diagnostics"; + /// Solutions resource type. + private const string SolutionsValue = "Solutions"; + /// Troubleshooters resource type. + private const string TroubleshootersValue = "Troubleshooters"; + /// SelfHelp resource type. + private const string SelfHelpValue = "SelfHelp"; /// Initializes a new instance of . + /// The value. /// is null. public SelfHelpSolutionType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string DiagnosticsValue = "Diagnostics"; - private const string SolutionsValue = "Solutions"; - private const string TroubleshootersValue = "Troubleshooters"; - private const string SelfHelpValue = "SelfHelp"; + _value = value; + } /// Diagnostics resource type. public static SelfHelpSolutionType Diagnostics { get; } = new SelfHelpSolutionType(DiagnosticsValue); + /// Solutions resource type. public static SelfHelpSolutionType Solutions { get; } = new SelfHelpSolutionType(SolutionsValue); + /// Troubleshooters resource type. public static SelfHelpSolutionType Troubleshooters { get; } = new SelfHelpSolutionType(TroubleshootersValue); + /// SelfHelp resource type. public static SelfHelpSolutionType SelfHelp { get; } = new SelfHelpSolutionType(SelfHelpValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(SelfHelpSolutionType left, SelfHelpSolutionType 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 !=(SelfHelpSolutionType left, SelfHelpSolutionType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator SelfHelpSolutionType(string value) => new SelfHelpSolutionType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator SelfHelpSolutionType?(string value) => value == null ? null : new SelfHelpSolutionType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is SelfHelpSolutionType other && Equals(other); - /// + + /// public bool Equals(SelfHelpSolutionType 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutions.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutions.Serialization.cs new file mode 100644 index 000000000000..c80ca10e626a --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutions.Serialization.cs @@ -0,0 +1,155 @@ +// 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.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// List of solutions. + internal partial class SelfHelpSolutions : IJsonModel + { + /// 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(SelfHelpSolutions)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Solutions)) + { + writer.WritePropertyName("solutions"u8); + writer.WriteStartArray(); + foreach (SolutionMetadataProperties item in Solutions) + { + 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. + SelfHelpSolutions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpSolutions 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(SelfHelpSolutions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSelfHelpSolutions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpSolutions DeserializeSelfHelpSolutions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList solutions = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("solutions"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(SolutionMetadataProperties.DeserializeSolutionMetadataProperties(item, options)); + } + solutions = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SelfHelpSolutions(solutions ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerSelfHelpContext.Default); + default: + throw new FormatException($"The model {nameof(SelfHelpSolutions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpSolutions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpSolutions 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 DeserializeSelfHelpSolutions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SelfHelpSolutions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutions.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutions.cs new file mode 100644 index 000000000000..31f9c9e6ef6d --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpSolutions.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.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// List of solutions. + internal partial class SelfHelpSolutions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SelfHelpSolutions() + { + Solutions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of metadata. + /// Keeps track of any properties unknown to the library. + internal SelfHelpSolutions(IList solutions, IDictionary additionalBinaryDataProperties) + { + Solutions = solutions; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// List of metadata. + public IList Solutions { get; } = new ChangeTrackingList(); + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpStep.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpStep.Serialization.cs index 1f458ec03894..690fd4f59735 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpStep.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpStep.Serialization.cs @@ -10,14 +10,16 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SelfHelpStep : IUtf8JsonSerializable, IJsonModel + /// Troubleshooter step. + public partial class SelfHelpStep : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -29,12 +31,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpStep)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Id)) { writer.WritePropertyName("id"u8); @@ -79,7 +80,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("inputs"u8); writer.WriteStartArray(); - foreach (var item in Inputs) + foreach (TroubleshooterStepInput item in Inputs) { writer.WriteObjectValue(item, options); } @@ -94,7 +95,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("insights"u8); writer.WriteStartArray(); - foreach (var item in Insights) + foreach (SelfHelpDiagnosticInsight item in Insights) { writer.WriteObjectValue(item, options); } @@ -105,15 +106,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("error"u8); ((IJsonModel)Error).Write(writer, options); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -122,22 +123,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SelfHelpStep IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpStep IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SelfHelpStep JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpStep)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpStep(document.RootElement, options); } - internal static SelfHelpStep DeserializeSelfHelpStep(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpStep DeserializeSelfHelpStep(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -148,120 +154,118 @@ internal static SelfHelpStep DeserializeSelfHelpStep(JsonElement element, ModelR string guidance = default; TroubleshooterExecutionStatus? executionStatus = default; string executionStatusDescription = default; - SelfHelpType? type = default; + SelfHelpType? stepType = default; bool? isLastStep = default; - IReadOnlyList inputs = default; + IList inputs = default; AutomatedCheckResult automatedCheckResults = default; - IReadOnlyList insights = default; + IList insights = default; ResponseError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = property.Value.GetString(); + id = prop.Value.GetString(); continue; } - if (property.NameEquals("title"u8)) + if (prop.NameEquals("title"u8)) { - title = property.Value.GetString(); + title = prop.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("guidance"u8)) + if (prop.NameEquals("guidance"u8)) { - guidance = property.Value.GetString(); + guidance = prop.Value.GetString(); continue; } - if (property.NameEquals("executionStatus"u8)) + if (prop.NameEquals("executionStatus"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - executionStatus = new TroubleshooterExecutionStatus(property.Value.GetString()); + executionStatus = new TroubleshooterExecutionStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("executionStatusDescription"u8)) + if (prop.NameEquals("executionStatusDescription"u8)) { - executionStatusDescription = property.Value.GetString(); + executionStatusDescription = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new SelfHelpType(property.Value.GetString()); + stepType = new SelfHelpType(prop.Value.GetString()); continue; } - if (property.NameEquals("isLastStep"u8)) + if (prop.NameEquals("isLastStep"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - isLastStep = property.Value.GetBoolean(); + isLastStep = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("inputs"u8)) + if (prop.NameEquals("inputs"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(TroubleshooterStepInput.DeserializeTroubleshooterStepInput(item, options)); } inputs = array; continue; } - if (property.NameEquals("automatedCheckResults"u8)) + if (prop.NameEquals("automatedCheckResults"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - automatedCheckResults = AutomatedCheckResult.DeserializeAutomatedCheckResult(property.Value, options); + automatedCheckResults = AutomatedCheckResult.DeserializeAutomatedCheckResult(prop.Value, options); continue; } - if (property.NameEquals("insights"u8)) + if (prop.NameEquals("insights"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(SelfHelpDiagnosticInsight.DeserializeSelfHelpDiagnosticInsight(item, options)); } insights = array; continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerSelfHelpContext.Default); + error = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new SelfHelpStep( id, title, @@ -269,19 +273,22 @@ internal static SelfHelpStep DeserializeSelfHelpStep(JsonElement element, ModelR guidance, executionStatus, executionStatusDescription, - type, + stepType, isLastStep, inputs ?? new ChangeTrackingList(), automatedCheckResults, insights ?? new ChangeTrackingList(), error, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -291,15 +298,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions option } } - SelfHelpStep IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpStep IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SelfHelpStep 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpStep(document.RootElement, options); } default: @@ -307,6 +319,7 @@ SelfHelpStep IPersistableModel.Create(BinaryData data, ModelReader } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpStep.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpStep.cs index 3ca05c758a41..87db554de57f 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpStep.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpStep.cs @@ -7,43 +7,16 @@ using System; using System.Collections.Generic; +using Azure; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Troubleshooter step. public partial class SelfHelpStep { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal SelfHelpStep() @@ -65,8 +38,8 @@ internal SelfHelpStep() /// Only for AutomatedStep type. /// /// The error detail. - /// Keeps track of any properties unknown to the library. - internal SelfHelpStep(string id, string title, string description, string guidance, TroubleshooterExecutionStatus? executionStatus, string executionStatusDescription, SelfHelpType? stepType, bool? isLastStep, IReadOnlyList inputs, AutomatedCheckResult automatedCheckResults, IReadOnlyList insights, ResponseError error, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SelfHelpStep(string id, string title, string description, string guidance, TroubleshooterExecutionStatus? executionStatus, string executionStatusDescription, SelfHelpType? stepType, bool? isLastStep, IList inputs, AutomatedCheckResult automatedCheckResults, IList insights, ResponseError error, IDictionary additionalBinaryDataProperties) { Id = id; Title = title; @@ -80,31 +53,42 @@ internal SelfHelpStep(string id, string title, string description, string guidan AutomatedCheckResults = automatedCheckResults; Insights = insights; Error = error; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Unique step id. public string Id { get; } + /// Step title. public string Title { get; } + /// Step description. public string Description { get; } + /// Get or sets the Step guidance. public string Guidance { get; } + /// Status of Troubleshooter Step execution. public TroubleshooterExecutionStatus? ExecutionStatus { get; } + /// This field has more detailed status description of the execution status. public string ExecutionStatusDescription { get; } + /// Type of Troubleshooting step. public SelfHelpType? StepType { get; } + /// is this last step of the workflow. public bool? IsLastStep { get; } - /// Gets the inputs. - public IReadOnlyList Inputs { get; } + + /// Gets the Inputs. + public IList Inputs { get; } + /// Only for AutomatedStep type. public AutomatedCheckResult AutomatedCheckResults { get; } - /// Gets the insights. - public IReadOnlyList Insights { get; } + + /// Gets the Insights. + public IList Insights { get; } + /// The error detail. public ResponseError Error { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpType.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpType.cs index 9a5dc7c3d31c..e5ec22f57d7c 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpType.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,47 +15,67 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct SelfHelpType : IEquatable { private readonly string _value; + private const string DecisionValue = "Decision"; + private const string SolutionValue = "Solution"; + private const string InsightValue = "Insight"; + private const string AutomatedCheckValue = "AutomatedCheck"; + private const string InputValue = "Input"; /// Initializes a new instance of . + /// The value. /// is null. public SelfHelpType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string DecisionValue = "Decision"; - private const string SolutionValue = "Solution"; - private const string InsightValue = "Insight"; - private const string AutomatedCheckValue = "AutomatedCheck"; - private const string InputValue = "Input"; + _value = value; + } - /// Decision. + /// Gets the Decision. public static SelfHelpType Decision { get; } = new SelfHelpType(DecisionValue); - /// Solution. + + /// Gets the Solution. public static SelfHelpType Solution { get; } = new SelfHelpType(SolutionValue); - /// Insight. + + /// Gets the Insight. public static SelfHelpType Insight { get; } = new SelfHelpType(InsightValue); - /// AutomatedCheck. + + /// Gets the AutomatedCheck. public static SelfHelpType AutomatedCheck { get; } = new SelfHelpType(AutomatedCheckValue); - /// Input. + + /// Gets the Input. public static SelfHelpType Input { get; } = new SelfHelpType(InputValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(SelfHelpType left, SelfHelpType 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 !=(SelfHelpType left, SelfHelpType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator SelfHelpType(string value) => new SelfHelpType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator SelfHelpType?(string value) => value == null ? null : new SelfHelpType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is SelfHelpType other && Equals(other); - /// + + /// public bool Equals(SelfHelpType 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpVideo.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpVideo.Serialization.cs index 4314df855991..c6a79f6c6a01 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpVideo.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpVideo.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SelfHelpVideo : IUtf8JsonSerializable, IJsonModel + /// Video detail. + public partial class SelfHelpVideo : VideoGroupVideo, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpVideo)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(ReplacementKey)) { @@ -42,61 +42,67 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - SelfHelpVideo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpVideo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SelfHelpVideo)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override VideoGroupVideo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpVideo)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpVideo(document.RootElement, options); } - internal static SelfHelpVideo DeserializeSelfHelpVideo(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpVideo DeserializeSelfHelpVideo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string replacementKey = default; string src = default; string title = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string replacementKey = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("replacementKey"u8)) + if (prop.NameEquals("src"u8)) { - replacementKey = property.Value.GetString(); + src = prop.Value.GetString(); continue; } - if (property.NameEquals("src"u8)) + if (prop.NameEquals("title"u8)) { - src = property.Value.GetString(); + title = prop.Value.GetString(); continue; } - if (property.NameEquals("title"u8)) + if (prop.NameEquals("replacementKey"u8)) { - title = property.Value.GetString(); + replacementKey = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpVideo(src, title, serializedAdditionalRawData, replacementKey); + return new SelfHelpVideo(src, title, additionalBinaryDataProperties, replacementKey); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -106,15 +112,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions optio } } - SelfHelpVideo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpVideo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SelfHelpVideo)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override VideoGroupVideo 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpVideo(document.RootElement, options); } default: @@ -122,6 +133,7 @@ SelfHelpVideo IPersistableModel.Create(BinaryData data, ModelRead } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpVideo.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpVideo.cs index f64d241dfec0..761bbf1b3abd 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpVideo.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SelfHelpVideo.cs @@ -21,9 +21,9 @@ internal SelfHelpVideo() /// Initializes a new instance of . /// Link to the video. /// Title of the video. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Place holder used in HTML Content replace control with the insight content. - internal SelfHelpVideo(string src, string title, IDictionary serializedAdditionalRawData, string replacementKey) : base(src, title, serializedAdditionalRawData) + internal SelfHelpVideo(string src, string title, IDictionary additionalBinaryDataProperties, string replacementKey) : base(src, title, additionalBinaryDataProperties) { ReplacementKey = replacementKey; } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SimplifiedSolutionsResourceProperties.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SimplifiedSolutionsResourceProperties.Serialization.cs new file mode 100644 index 000000000000..908107990676 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SimplifiedSolutionsResourceProperties.Serialization.cs @@ -0,0 +1,261 @@ +// 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.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Simplified Solutions result. + internal partial class SimplifiedSolutionsResourceProperties : IJsonModel + { + /// 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(SimplifiedSolutionsResourceProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(SolutionId)) + { + writer.WritePropertyName("solutionId"u8); + writer.WriteStringValue(SolutionId); + } + if (Optional.IsCollectionDefined(Parameters)) + { + writer.WritePropertyName("parameters"u8); + writer.WriteStartObject(); + foreach (var item in Parameters) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsDefined(Title)) + { + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Appendix)) + { + writer.WritePropertyName("appendix"u8); + writer.WriteStartObject(); + foreach (var item in Appendix) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsDefined(Content)) + { + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + } + 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. + SimplifiedSolutionsResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SimplifiedSolutionsResourceProperties 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(SimplifiedSolutionsResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSimplifiedSolutionsResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SimplifiedSolutionsResourceProperties DeserializeSimplifiedSolutionsResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string solutionId = default; + IDictionary parameters = default; + string title = default; + IReadOnlyDictionary appendix = default; + string content = default; + SolutionProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("solutionId"u8)) + { + solutionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"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()); + } + } + parameters = dictionary; + continue; + } + if (prop.NameEquals("title"u8)) + { + title = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("appendix"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()); + } + } + appendix = dictionary; + continue; + } + if (prop.NameEquals("content"u8)) + { + content = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new SolutionProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SimplifiedSolutionsResourceProperties( + solutionId, + parameters ?? new ChangeTrackingDictionary(), + title, + appendix ?? new ChangeTrackingDictionary(), + content, + provisioningState, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerSelfHelpContext.Default); + default: + throw new FormatException($"The model {nameof(SimplifiedSolutionsResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SimplifiedSolutionsResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SimplifiedSolutionsResourceProperties 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 DeserializeSimplifiedSolutionsResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SimplifiedSolutionsResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SimplifiedSolutionsResourceProperties.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SimplifiedSolutionsResourceProperties.cs new file mode 100644 index 000000000000..c188a1e7b9b1 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SimplifiedSolutionsResourceProperties.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Simplified Solutions result. + internal partial class SimplifiedSolutionsResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SimplifiedSolutionsResourceProperties() + { + Parameters = new ChangeTrackingDictionary(); + Appendix = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Solution Id to identify single Simplified Solution. + /// Client input parameters to run Simplified Solutions. + /// The title. + /// Additional parameter response for Simplified Solutions. + /// The HTML content that needs to be rendered and shown to customer. + /// Status of Simplified Solution provisioning. + /// Keeps track of any properties unknown to the library. + internal SimplifiedSolutionsResourceProperties(string solutionId, IDictionary parameters, string title, IReadOnlyDictionary appendix, string content, SolutionProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + SolutionId = solutionId; + Parameters = parameters; + Title = title; + Appendix = appendix; + Content = content; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Solution Id to identify single Simplified Solution. + public string SolutionId { get; set; } + + /// Client input parameters to run Simplified Solutions. + public IDictionary Parameters { get; } = new ChangeTrackingDictionary(); + + /// The title. + public string Title { get; } + + /// Additional parameter response for Simplified Solutions. + public IReadOnlyDictionary Appendix { get; } = new ChangeTrackingDictionary(); + + /// The HTML content that needs to be rendered and shown to customer. + public string Content { get; } + + /// Status of Simplified Solution provisioning. + public SolutionProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionMetadataProperties.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionMetadataProperties.Serialization.cs index 17f97c755a50..5e803e14e80d 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionMetadataProperties.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionMetadataProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SolutionMetadataProperties : IUtf8JsonSerializable, IJsonModel + /// Metadata Properties. + public partial class SolutionMetadataProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionMetadataProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SolutionId)) { writer.WritePropertyName("solutionId"u8); @@ -53,21 +53,26 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("requiredInputs"u8); writer.WriteStartArray(); - foreach (var item in RequiredInputs) + foreach (string item in RequiredInputs) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -76,22 +81,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SolutionMetadataProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SolutionMetadataProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SolutionMetadataProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionMetadataProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSolutionMetadataProperties(document.RootElement, options); } - internal static SolutionMetadataProperties DeserializeSolutionMetadataProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SolutionMetadataProperties DeserializeSolutionMetadataProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -100,56 +110,64 @@ internal static SolutionMetadataProperties DeserializeSolutionMetadataProperties SelfHelpSolutionType? solutionType = default; string description = default; IReadOnlyList requiredInputs = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("solutionId"u8)) + if (prop.NameEquals("solutionId"u8)) { - solutionId = property.Value.GetString(); + solutionId = prop.Value.GetString(); continue; } - if (property.NameEquals("solutionType"u8)) + if (prop.NameEquals("solutionType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - solutionType = new SelfHelpSolutionType(property.Value.GetString()); + solutionType = new SelfHelpSolutionType(prop.Value.GetString()); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("requiredInputs"u8)) + if (prop.NameEquals("requiredInputs"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } requiredInputs = array; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SolutionMetadataProperties(solutionId, solutionType, description, requiredInputs ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new SolutionMetadataProperties(solutionId, solutionType, description, requiredInputs ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -159,15 +177,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriter } } - SolutionMetadataProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SolutionMetadataProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SolutionMetadataProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSolutionMetadataProperties(document.RootElement, options); } default: @@ -175,6 +198,7 @@ SolutionMetadataProperties IPersistableModel.Create( } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionMetadataProperties.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionMetadataProperties.cs index 304a52284c6d..2b8edd216206 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionMetadataProperties.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionMetadataProperties.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Metadata Properties. public partial class SolutionMetadataProperties { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public SolutionMetadataProperties() @@ -56,22 +28,25 @@ public SolutionMetadataProperties() /// Solution Type. /// A detailed description of solution. /// Required parameters for invoking this particular solution. - /// Keeps track of any properties unknown to the library. - internal SolutionMetadataProperties(string solutionId, SelfHelpSolutionType? solutionType, string description, IReadOnlyList requiredInputs, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SolutionMetadataProperties(string solutionId, SelfHelpSolutionType? solutionType, string description, IReadOnlyList requiredInputs, IDictionary additionalBinaryDataProperties) { SolutionId = solutionId; SolutionType = solutionType; Description = description; RequiredInputs = requiredInputs; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Solution Id. public string SolutionId { get; set; } + /// Solution Type. public SelfHelpSolutionType? SolutionType { get; } + /// A detailed description of solution. public string Description { get; } + /// Required parameters for invoking this particular solution. public IReadOnlyList RequiredInputs { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionNlpMetadata.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionNlpMetadata.Serialization.cs index e0368be747ac..6837724b5df5 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionNlpMetadata.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionNlpMetadata.Serialization.cs @@ -12,13 +12,15 @@ using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SolutionNlpMetadata : IUtf8JsonSerializable, IJsonModel + /// Nlp Metadata resource. + public partial class SolutionNlpMetadata : ResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -30,200 +32,114 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionNlpMetadata)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(ProblemTitle)) - { - writer.WritePropertyName("problemTitle"u8); - writer.WriteStringValue(ProblemTitle); - } - if (Optional.IsDefined(ProblemDescription)) - { - writer.WritePropertyName("problemDescription"u8); - writer.WriteStringValue(ProblemDescription); - } - if (Optional.IsDefined(ServiceId)) - { - writer.WritePropertyName("serviceId"u8); - writer.WriteStringValue(ServiceId); - } - if (Optional.IsDefined(ProblemClassificationId)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("problemClassificationId"u8); - writer.WriteStringValue(ProblemClassificationId); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - if (Optional.IsCollectionDefined(Solutions)) - { - writer.WritePropertyName("solutions"u8); - writer.WriteStartArray(); - foreach (var item in Solutions) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsCollectionDefined(RelatedServices)) - { - writer.WritePropertyName("relatedServices"u8); - writer.WriteStartArray(); - foreach (var item in RelatedServices) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - writer.WriteEndObject(); } - SolutionNlpMetadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SolutionNlpMetadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SolutionNlpMetadata)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionNlpMetadata)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSolutionNlpMetadata(document.RootElement, options); } - internal static SolutionNlpMetadata DeserializeSolutionNlpMetadata(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SolutionNlpMetadata DeserializeSolutionNlpMetadata(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - string problemTitle = default; - string problemDescription = default; - string serviceId = default; - string problemClassificationId = default; - IList solutions = default; - IList relatedServices = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + SelfHelpNlpSolutions properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("problemTitle"u8)) - { - problemTitle = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("problemDescription"u8)) - { - problemDescription = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("serviceId"u8)) - { - serviceId = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("problemClassificationId"u8)) - { - problemClassificationId = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("solutions"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(SolutionMetadataProperties.DeserializeSolutionMetadataProperties(item, options)); - } - solutions = array; - continue; - } - if (property0.NameEquals("relatedServices"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(ClassificationService.DeserializeClassificationService(item, options)); - } - relatedServices = array; - continue; - } - } + properties = SelfHelpNlpSolutions.DeserializeSelfHelpNlpSolutions(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new SolutionNlpMetadata( id, name, - type, + resourceType, systemData, - problemTitle, - problemDescription, - serviceId, - problemClassificationId, - solutions ?? new ChangeTrackingList(), - relatedServices ?? new ChangeTrackingList(), - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -233,15 +149,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - SolutionNlpMetadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SolutionNlpMetadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SolutionNlpMetadata)PersistableModelCreateCore(data, options); + /// 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSolutionNlpMetadata(document.RootElement, options); } default: @@ -249,6 +170,7 @@ SolutionNlpMetadata IPersistableModel.Create(BinaryData dat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionNlpMetadata.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionNlpMetadata.cs index c67ca876d510..b8f6ec62ed84 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionNlpMetadata.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionNlpMetadata.cs @@ -15,79 +15,122 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Nlp Metadata resource. public partial class SolutionNlpMetadata : ResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public SolutionNlpMetadata() { - Solutions = new ChangeTrackingList(); - RelatedServices = new ChangeTrackingList(); } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// Title of the problem classification. - /// Description of the problem classification. - /// Id of the service (https://learn.microsoft.com/en-us/rest/api/support/services?view=rest-support-2020-04-01) that may be used to create a support ticket. - /// Id of the ProblemClassification (https://learn.microsoft.com/en-us/rest/api/support/problem-classifications?view=rest-support-2020-04-01) that may be used to create a support ticket. - /// The list of solution metadata. - /// The set of services that are most likely related to the request. If relatedServices is included in the response then solutions may not be discovered until the client calls a second time specifying one of the service Ids in the relatedServices object. - /// Keeps track of any properties unknown to the library. - internal SolutionNlpMetadata(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string problemTitle, string problemDescription, string serviceId, string problemClassificationId, IList solutions, IList relatedServices, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + /// 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. + /// Solution metadata Resource properties. + internal SolutionNlpMetadata(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, SelfHelpNlpSolutions properties) : base(id, name, resourceType, systemData) { - ProblemTitle = problemTitle; - ProblemDescription = problemDescription; - ServiceId = serviceId; - ProblemClassificationId = problemClassificationId; - Solutions = solutions; - RelatedServices = relatedServices; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } + /// Solution metadata Resource properties. + internal SelfHelpNlpSolutions Properties { get; set; } + /// Title of the problem classification. - public string ProblemTitle { get; set; } + public string ProblemTitle + { + get + { + return Properties is null ? default : Properties.ProblemTitle; + } + set + { + if (Properties is null) + { + Properties = new SelfHelpNlpSolutions(); + } + Properties.ProblemTitle = value; + } + } + /// Description of the problem classification. - public string ProblemDescription { get; set; } + public string ProblemDescription + { + get + { + return Properties is null ? default : Properties.ProblemDescription; + } + set + { + if (Properties is null) + { + Properties = new SelfHelpNlpSolutions(); + } + Properties.ProblemDescription = value; + } + } + /// Id of the service (https://learn.microsoft.com/en-us/rest/api/support/services?view=rest-support-2020-04-01) that may be used to create a support ticket. - public string ServiceId { get; set; } + public string ServiceId + { + get + { + return Properties is null ? default : Properties.ServiceId; + } + set + { + if (Properties is null) + { + Properties = new SelfHelpNlpSolutions(); + } + Properties.ServiceId = value; + } + } + /// Id of the ProblemClassification (https://learn.microsoft.com/en-us/rest/api/support/problem-classifications?view=rest-support-2020-04-01) that may be used to create a support ticket. - public string ProblemClassificationId { get; set; } + public string ProblemClassificationId + { + get + { + return Properties is null ? default : Properties.ProblemClassificationId; + } + set + { + if (Properties is null) + { + Properties = new SelfHelpNlpSolutions(); + } + Properties.ProblemClassificationId = value; + } + } + /// The list of solution metadata. - public IList Solutions { get; } + public IList Solutions + { + get + { + if (Properties is null) + { + Properties = new SelfHelpNlpSolutions(); + } + return Properties.Solutions; + } + } + /// The set of services that are most likely related to the request. If relatedServices is included in the response then solutions may not be discovered until the client calls a second time specifying one of the service Ids in the relatedServices object. - public IList RelatedServices { get; } + public IList RelatedServices + { + get + { + if (Properties is null) + { + Properties = new SelfHelpNlpSolutions(); + } + return Properties.RelatedServices; + } + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionProvisioningState.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionProvisioningState.cs index e037819aeac0..077bbf0f1588 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionProvisioningState.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionProvisioningState.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,47 +15,72 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct SolutionProvisioningState : IEquatable { private readonly string _value; + /// All Solutions in the Batch succeeded. + private const string SucceededValue = "Succeeded"; + /// Some Solutions are still running or failed. + private const string PartialCompleteValue = "PartialComplete"; + /// All Solutions failed to run. + private const string FailedValue = "Failed"; + /// All Solutions are still running. + private const string RunningValue = "Running"; + /// When Solutions request gets canceled. + private const string CanceledValue = "Canceled"; /// Initializes a new instance of . + /// The value. /// is null. public SolutionProvisioningState(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SucceededValue = "Succeeded"; - private const string PartialCompleteValue = "PartialComplete"; - private const string FailedValue = "Failed"; - private const string RunningValue = "Running"; - private const string CanceledValue = "Canceled"; + _value = value; + } /// All Solutions in the Batch succeeded. public static SolutionProvisioningState Succeeded { get; } = new SolutionProvisioningState(SucceededValue); + /// Some Solutions are still running or failed. public static SolutionProvisioningState PartialComplete { get; } = new SolutionProvisioningState(PartialCompleteValue); + /// All Solutions failed to run. public static SolutionProvisioningState Failed { get; } = new SolutionProvisioningState(FailedValue); + /// All Solutions are still running. public static SolutionProvisioningState Running { get; } = new SolutionProvisioningState(RunningValue); + /// When Solutions request gets canceled. public static SolutionProvisioningState Canceled { get; } = new SolutionProvisioningState(CanceledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(SolutionProvisioningState left, SolutionProvisioningState 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 !=(SolutionProvisioningState left, SolutionProvisioningState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator SolutionProvisioningState(string value) => new SolutionProvisioningState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator SolutionProvisioningState?(string value) => value == null ? null : new SolutionProvisioningState(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is SolutionProvisioningState other && Equals(other); - /// + + /// public bool Equals(SolutionProvisioningState 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionReplacementMaps.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionReplacementMaps.Serialization.cs index 79f44940733f..ac2ebfcdb70d 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionReplacementMaps.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionReplacementMaps.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SolutionReplacementMaps : IUtf8JsonSerializable, IJsonModel + /// Solution replacement maps. + public partial class SolutionReplacementMaps : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,17 +29,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionReplacementMaps)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(WebResults)) { writer.WritePropertyName("webResults"u8); writer.WriteStartArray(); - foreach (var item in WebResults) + foreach (KBWebResult item in WebResults) { writer.WriteObjectValue(item, options); } @@ -48,7 +48,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("diagnostics"u8); writer.WriteStartArray(); - foreach (var item in Diagnostics) + foreach (SolutionsDiagnostic item in Diagnostics) { writer.WriteObjectValue(item, options); } @@ -58,7 +58,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("troubleshooters"u8); writer.WriteStartArray(); - foreach (var item in Troubleshooters) + foreach (SolutionsTroubleshooters item in Troubleshooters) { writer.WriteObjectValue(item, options); } @@ -68,7 +68,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("metricsBasedCharts"u8); writer.WriteStartArray(); - foreach (var item in MetricsBasedCharts) + foreach (MetricsBasedChart item in MetricsBasedCharts) { writer.WriteObjectValue(item, options); } @@ -78,7 +78,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("videos"u8); writer.WriteStartArray(); - foreach (var item in Videos) + foreach (SelfHelpVideo item in Videos) { writer.WriteObjectValue(item, options); } @@ -88,21 +88,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("videoGroups"u8); writer.WriteStartArray(); - foreach (var item in VideoGroups) + foreach (VideoGroupDetail item in VideoGroups) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -111,114 +111,118 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SolutionReplacementMaps IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SolutionReplacementMaps IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SolutionReplacementMaps JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionReplacementMaps)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSolutionReplacementMaps(document.RootElement, options); } - internal static SolutionReplacementMaps DeserializeSolutionReplacementMaps(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SolutionReplacementMaps DeserializeSolutionReplacementMaps(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList webResults = default; - IReadOnlyList diagnostics = default; - IReadOnlyList troubleshooters = default; - IReadOnlyList metricsBasedCharts = default; - IReadOnlyList videos = default; - IReadOnlyList videoGroups = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList webResults = default; + IList diagnostics = default; + IList troubleshooters = default; + IList metricsBasedCharts = default; + IList videos = default; + IList videoGroups = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("webResults"u8)) + if (prop.NameEquals("webResults"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(KBWebResult.DeserializeKBWebResult(item, options)); } webResults = array; continue; } - if (property.NameEquals("diagnostics"u8)) + if (prop.NameEquals("diagnostics"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(SolutionsDiagnostic.DeserializeSolutionsDiagnostic(item, options)); } diagnostics = array; continue; } - if (property.NameEquals("troubleshooters"u8)) + if (prop.NameEquals("troubleshooters"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(SolutionsTroubleshooters.DeserializeSolutionsTroubleshooters(item, options)); } troubleshooters = array; continue; } - if (property.NameEquals("metricsBasedCharts"u8)) + if (prop.NameEquals("metricsBasedCharts"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(MetricsBasedChart.DeserializeMetricsBasedChart(item, options)); } metricsBasedCharts = array; continue; } - if (property.NameEquals("videos"u8)) + if (prop.NameEquals("videos"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(SelfHelpVideo.DeserializeSelfHelpVideo(item, options)); } videos = array; continue; } - if (property.NameEquals("videoGroups"u8)) + if (prop.NameEquals("videoGroups"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(VideoGroupDetail.DeserializeVideoGroupDetail(item, options)); } @@ -227,10 +231,9 @@ internal static SolutionReplacementMaps DeserializeSolutionReplacementMaps(JsonE } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new SolutionReplacementMaps( webResults ?? new ChangeTrackingList(), diagnostics ?? new ChangeTrackingList(), @@ -238,13 +241,16 @@ internal static SolutionReplacementMaps DeserializeSolutionReplacementMaps(JsonE metricsBasedCharts ?? new ChangeTrackingList(), videos ?? new ChangeTrackingList(), videoGroups ?? new ChangeTrackingList(), - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -254,15 +260,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - SolutionReplacementMaps IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SolutionReplacementMaps IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SolutionReplacementMaps 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSolutionReplacementMaps(document.RootElement, options); } default: @@ -270,6 +281,7 @@ SolutionReplacementMaps IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionReplacementMaps.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionReplacementMaps.cs index ce0e91ba70ef..fba5b60252b9 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionReplacementMaps.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionReplacementMaps.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Solution replacement maps. public partial class SolutionReplacementMaps { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal SolutionReplacementMaps() @@ -63,8 +35,8 @@ internal SolutionReplacementMaps() /// Solution metrics based charts. /// Video solutions, which have the power to engage the customer by stimulating their senses. /// Group of Videos. - /// Keeps track of any properties unknown to the library. - internal SolutionReplacementMaps(IReadOnlyList webResults, IReadOnlyList diagnostics, IReadOnlyList troubleshooters, IReadOnlyList metricsBasedCharts, IReadOnlyList videos, IReadOnlyList videoGroups, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SolutionReplacementMaps(IList webResults, IList diagnostics, IList troubleshooters, IList metricsBasedCharts, IList videos, IList videoGroups, IDictionary additionalBinaryDataProperties) { WebResults = webResults; Diagnostics = diagnostics; @@ -72,20 +44,25 @@ internal SolutionReplacementMaps(IReadOnlyList webResults, IReadOnl MetricsBasedCharts = metricsBasedCharts; Videos = videos; VideoGroups = videoGroups; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Solution AzureKB results. - public IReadOnlyList WebResults { get; } + public IList WebResults { get; } + /// Solution diagnostics results. - public IReadOnlyList Diagnostics { get; } + public IList Diagnostics { get; } + /// Solutions Troubleshooters. - public IReadOnlyList Troubleshooters { get; } + public IList Troubleshooters { get; } + /// Solution metrics based charts. - public IReadOnlyList MetricsBasedCharts { get; } + public IList MetricsBasedCharts { get; } + /// Video solutions, which have the power to engage the customer by stimulating their senses. - public IReadOnlyList Videos { get; } + public IList Videos { get; } + /// Group of Videos. - public IReadOnlyList VideoGroups { get; } + public IList VideoGroups { get; } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionResourceProperties.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionResourceProperties.Serialization.cs new file mode 100644 index 000000000000..0fa90b60edc8 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionResourceProperties.Serialization.cs @@ -0,0 +1,290 @@ +// 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.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Solution result. + internal partial class SolutionResourceProperties : IJsonModel + { + /// 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(SolutionResourceProperties)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(TriggerCriteria)) + { + writer.WritePropertyName("triggerCriteria"u8); + writer.WriteStartArray(); + foreach (SolutionTriggerCriterion item in TriggerCriteria) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Parameters)) + { + writer.WritePropertyName("parameters"u8); + writer.WriteStartObject(); + foreach (var item in Parameters) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsDefined(SolutionId)) + { + writer.WritePropertyName("solutionId"u8); + writer.WriteStringValue(SolutionId); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Title)) + { + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + if (options.Format != "W" && Optional.IsDefined(Content)) + { + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + } + if (options.Format != "W" && Optional.IsDefined(ReplacementMaps)) + { + writer.WritePropertyName("replacementMaps"u8); + writer.WriteObjectValue(ReplacementMaps, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Sections)) + { + writer.WritePropertyName("sections"u8); + writer.WriteStartArray(); + foreach (SelfHelpSection item in Sections) + { + 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. + SolutionResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SolutionResourceProperties 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(SolutionResourceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSolutionResourceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SolutionResourceProperties DeserializeSolutionResourceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList triggerCriteria = default; + IDictionary parameters = default; + string solutionId = default; + SolutionProvisioningState? provisioningState = default; + string title = default; + string content = default; + SolutionReplacementMaps replacementMaps = default; + IReadOnlyList sections = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("triggerCriteria"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(SolutionTriggerCriterion.DeserializeSolutionTriggerCriterion(item, options)); + } + triggerCriteria = array; + continue; + } + if (prop.NameEquals("parameters"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()); + } + } + parameters = dictionary; + continue; + } + if (prop.NameEquals("solutionId"u8)) + { + solutionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new SolutionProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("title"u8)) + { + title = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("replacementMaps"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + replacementMaps = SolutionReplacementMaps.DeserializeSolutionReplacementMaps(prop.Value, options); + continue; + } + if (prop.NameEquals("sections"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(SelfHelpSection.DeserializeSelfHelpSection(item, options)); + } + sections = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SolutionResourceProperties( + triggerCriteria ?? new ChangeTrackingList(), + parameters ?? new ChangeTrackingDictionary(), + solutionId, + provisioningState, + title, + content, + replacementMaps, + sections ?? new ChangeTrackingList(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerSelfHelpContext.Default); + default: + throw new FormatException($"The model {nameof(SolutionResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SolutionResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SolutionResourceProperties 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 DeserializeSolutionResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SolutionResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionResourceProperties.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionResourceProperties.cs new file mode 100644 index 000000000000..8981e6c98e4b --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionResourceProperties.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; +using Azure.ResourceManager.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Solution result. + internal partial class SolutionResourceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SolutionResourceProperties() + { + TriggerCriteria = new ChangeTrackingList(); + Parameters = new ChangeTrackingDictionary(); + Sections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Solution request trigger criteria. + /// Client input parameters to run Solution. + /// Solution Id to identify single solution. + /// Status of solution provisioning. + /// The title. + /// The HTML content that needs to be rendered and shown to customer. + /// Solution replacement maps. + /// List of section object. + /// Keeps track of any properties unknown to the library. + internal SolutionResourceProperties(IList triggerCriteria, IDictionary parameters, string solutionId, SolutionProvisioningState? provisioningState, string title, string content, SolutionReplacementMaps replacementMaps, IReadOnlyList sections, IDictionary additionalBinaryDataProperties) + { + TriggerCriteria = triggerCriteria; + Parameters = parameters; + SolutionId = solutionId; + ProvisioningState = provisioningState; + Title = title; + Content = content; + ReplacementMaps = replacementMaps; + Sections = sections; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Solution request trigger criteria. + public IList TriggerCriteria { get; } = new ChangeTrackingList(); + + /// Client input parameters to run Solution. + public IDictionary Parameters { get; } = new ChangeTrackingDictionary(); + + /// Solution Id to identify single solution. + public string SolutionId { get; } + + /// Status of solution provisioning. + public SolutionProvisioningState? ProvisioningState { get; } + + /// The title. + public string Title { get; } + + /// The HTML content that needs to be rendered and shown to customer. + public string Content { get; } + + /// Solution replacement maps. + public SolutionReplacementMaps ReplacementMaps { get; } + + /// List of section object. + public IReadOnlyList Sections { get; } = new ChangeTrackingList(); + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionSection.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionSection.Serialization.cs index b689cfa5ccd2..04df40dc0d9c 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionSection.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionSection.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SolutionSection : IUtf8JsonSerializable, IJsonModel + /// Part of the solution and are dividers in the solution rendering. + public partial class SolutionSection : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionSection)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Title)) { writer.WritePropertyName("title"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("replacementMaps"u8); writer.WriteObjectValue(ReplacementMaps, options); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,22 +66,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SolutionSection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SolutionSection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SolutionSection JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionSection)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSolutionSection(document.RootElement, options); } - internal static SolutionSection DeserializeSolutionSection(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SolutionSection DeserializeSolutionSection(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,42 +94,43 @@ internal static SolutionSection DeserializeSolutionSection(JsonElement element, string title = default; string content = default; ReplacementMapsResult replacementMaps = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("title"u8)) + if (prop.NameEquals("title"u8)) { - title = property.Value.GetString(); + title = prop.Value.GetString(); continue; } - if (property.NameEquals("content"u8)) + if (prop.NameEquals("content"u8)) { - content = property.Value.GetString(); + content = prop.Value.GetString(); continue; } - if (property.NameEquals("replacementMaps"u8)) + if (prop.NameEquals("replacementMaps"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - replacementMaps = ReplacementMapsResult.DeserializeReplacementMapsResult(property.Value, options); + replacementMaps = ReplacementMapsResult.DeserializeReplacementMapsResult(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SolutionSection(title, content, replacementMaps, serializedAdditionalRawData); + return new SolutionSection(title, content, replacementMaps, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -134,15 +140,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - SolutionSection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SolutionSection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SolutionSection 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSolutionSection(document.RootElement, options); } default: @@ -150,6 +161,7 @@ SolutionSection IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionSection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionSection.cs index e64d54e0a7b0..def687aa18f7 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionSection.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionSection.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Part of the solution and are dividers in the solution rendering. public partial class SolutionSection { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal SolutionSection() @@ -54,19 +25,21 @@ internal SolutionSection() /// Solution sections title. /// Solution sections content. /// Solution replacement maps. - /// Keeps track of any properties unknown to the library. - internal SolutionSection(string title, string content, ReplacementMapsResult replacementMaps, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SolutionSection(string title, string content, ReplacementMapsResult replacementMaps, IDictionary additionalBinaryDataProperties) { Title = title; Content = content; ReplacementMaps = replacementMaps; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Solution sections title. public string Title { get; } + /// Solution sections content. public string Content { get; } + /// Solution replacement maps. public ReplacementMapsResult ReplacementMaps { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionTriggerCriterion.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionTriggerCriterion.Serialization.cs index 362f0d4a31bd..0054a6c03bc1 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionTriggerCriterion.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionTriggerCriterion.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SolutionTriggerCriterion : IUtf8JsonSerializable, IJsonModel + /// Solution request trigger criterion. SolutionId/ProblemClassificationId is the only supported trigger type for Solution PUT request. ReplacementKey is the only supported trigger type for Solution PATCH request. + public partial class SolutionTriggerCriterion : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionTriggerCriterion)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("value"u8); writer.WriteStringValue(Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,59 +61,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SolutionTriggerCriterion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SolutionTriggerCriterion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SolutionTriggerCriterion JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionTriggerCriterion)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSolutionTriggerCriterion(document.RootElement, options); } - internal static SolutionTriggerCriterion DeserializeSolutionTriggerCriterion(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SolutionTriggerCriterion DeserializeSolutionTriggerCriterion(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } SelfHelpName? name = default; string value = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - name = new SelfHelpName(property.Value.GetString()); + name = new SelfHelpName(prop.Value.GetString()); continue; } - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - value = property.Value.GetString(); + value = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SolutionTriggerCriterion(name, value, serializedAdditionalRawData); + return new SolutionTriggerCriterion(name, value, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -123,15 +129,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - SolutionTriggerCriterion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SolutionTriggerCriterion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SolutionTriggerCriterion 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSolutionTriggerCriterion(document.RootElement, options); } default: @@ -139,6 +150,7 @@ SolutionTriggerCriterion IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionTriggerCriterion.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionTriggerCriterion.cs index 4176562eacdb..55b93453138c 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionTriggerCriterion.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionTriggerCriterion.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Solution request trigger criterion. SolutionId/ProblemClassificationId is the only supported trigger type for Solution PUT request. ReplacementKey is the only supported trigger type for Solution PATCH request. public partial class SolutionTriggerCriterion { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public SolutionTriggerCriterion() @@ -53,16 +24,17 @@ public SolutionTriggerCriterion() /// Initializes a new instance of . /// Trigger criterion name. /// Trigger criterion value. - /// Keeps track of any properties unknown to the library. - internal SolutionTriggerCriterion(SelfHelpName? name, string value, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SolutionTriggerCriterion(SelfHelpName? name, string value, IDictionary additionalBinaryDataProperties) { Name = name; Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Trigger criterion name. public SelfHelpName? Name { get; set; } + /// Trigger criterion value. public string Value { get; set; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionWarmUpContent.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionWarmUpContent.Serialization.cs index 081b3db5b605..21b7174f4de2 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionWarmUpContent.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionWarmUpContent.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SolutionWarmUpContent : IUtf8JsonSerializable, IJsonModel + /// Solution WarmUpRequest body. + public partial class SolutionWarmUpContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +30,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionWarmUpContent)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Parameters)) { writer.WritePropertyName("parameters"u8); @@ -41,19 +42,24 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Parameters) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -62,58 +68,71 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SolutionWarmUpContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SolutionWarmUpContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SolutionWarmUpContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionWarmUpContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSolutionWarmUpContent(document.RootElement, options); } - internal static SolutionWarmUpContent DeserializeSolutionWarmUpContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SolutionWarmUpContent DeserializeSolutionWarmUpContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IDictionary parameters = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("parameters"u8)) + if (prop.NameEquals("parameters"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } parameters = dictionary; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SolutionWarmUpContent(parameters ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new SolutionWarmUpContent(parameters ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -123,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - SolutionWarmUpContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SolutionWarmUpContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SolutionWarmUpContent 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSolutionWarmUpContent(document.RootElement, options); } default: @@ -139,6 +163,19 @@ SolutionWarmUpContent IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(SolutionWarmUpContent solutionWarmUpContent) + { + if (solutionWarmUpContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(solutionWarmUpContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionWarmUpContent.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionWarmUpContent.cs index 4aaf32f06dcc..7b7233cc62fe 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionWarmUpContent.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionWarmUpContent.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Solution WarmUpRequest body. public partial class SolutionWarmUpContent { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public SolutionWarmUpContent() @@ -53,11 +25,11 @@ public SolutionWarmUpContent() /// Initializes a new instance of . /// Dictionary of <string>. - /// Keeps track of any properties unknown to the library. - internal SolutionWarmUpContent(IDictionary parameters, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SolutionWarmUpContent(IDictionary parameters, IDictionary additionalBinaryDataProperties) { Parameters = parameters; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Dictionary of <string>. diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsDiagnostic.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsDiagnostic.Serialization.cs index 2d11b5439e07..b8bdb340d62f 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsDiagnostic.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsDiagnostic.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SolutionsDiagnostic : IUtf8JsonSerializable, IJsonModel + /// Solutions Diagnostic. + public partial class SolutionsDiagnostic : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionsDiagnostic)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SolutionId)) { writer.WritePropertyName("solutionId"u8); @@ -63,8 +63,13 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("requiredParameters"u8); writer.WriteStartArray(); - foreach (var item in RequiredParameters) + foreach (string item in RequiredParameters) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); @@ -73,21 +78,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("insights"u8); writer.WriteStartArray(); - foreach (var item in Insights) + foreach (SelfHelpDiagnosticInsight item in Insights) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -96,22 +101,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SolutionsDiagnostic IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SolutionsDiagnostic IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SolutionsDiagnostic JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionsDiagnostic)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSolutionsDiagnostic(document.RootElement, options); } - internal static SolutionsDiagnostic DeserializeSolutionsDiagnostic(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SolutionsDiagnostic DeserializeSolutionsDiagnostic(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -121,63 +131,69 @@ internal static SolutionsDiagnostic DeserializeSolutionsDiagnostic(JsonElement e string statusDetails = default; string replacementKey = default; string estimatedCompletionTime = default; - IReadOnlyList requiredParameters = default; - IReadOnlyList insights = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList requiredParameters = default; + IList insights = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("solutionId"u8)) + if (prop.NameEquals("solutionId"u8)) { - solutionId = property.Value.GetString(); + solutionId = prop.Value.GetString(); continue; } - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - status = new SelfHelpDiagnosticStatus(property.Value.GetString()); + status = new SelfHelpDiagnosticStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("statusDetails"u8)) + if (prop.NameEquals("statusDetails"u8)) { - statusDetails = property.Value.GetString(); + statusDetails = prop.Value.GetString(); continue; } - if (property.NameEquals("replacementKey"u8)) + if (prop.NameEquals("replacementKey"u8)) { - replacementKey = property.Value.GetString(); + replacementKey = prop.Value.GetString(); continue; } - if (property.NameEquals("estimatedCompletionTime"u8)) + if (prop.NameEquals("estimatedCompletionTime"u8)) { - estimatedCompletionTime = property.Value.GetString(); + estimatedCompletionTime = prop.Value.GetString(); continue; } - if (property.NameEquals("requiredParameters"u8)) + if (prop.NameEquals("requiredParameters"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } requiredParameters = array; continue; } - if (property.NameEquals("insights"u8)) + if (prop.NameEquals("insights"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(SelfHelpDiagnosticInsight.DeserializeSelfHelpDiagnosticInsight(item, options)); } @@ -186,10 +202,9 @@ internal static SolutionsDiagnostic DeserializeSolutionsDiagnostic(JsonElement e } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new SolutionsDiagnostic( solutionId, status, @@ -198,13 +213,16 @@ internal static SolutionsDiagnostic DeserializeSolutionsDiagnostic(JsonElement e estimatedCompletionTime, requiredParameters ?? new ChangeTrackingList(), insights ?? new ChangeTrackingList(), - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -214,15 +232,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - SolutionsDiagnostic IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SolutionsDiagnostic IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SolutionsDiagnostic 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSolutionsDiagnostic(document.RootElement, options); } default: @@ -230,6 +253,7 @@ SolutionsDiagnostic IPersistableModel.Create(BinaryData dat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsDiagnostic.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsDiagnostic.cs index 42637874c521..462b89be5790 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsDiagnostic.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsDiagnostic.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Solutions Diagnostic. public partial class SolutionsDiagnostic { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal SolutionsDiagnostic() @@ -60,8 +32,8 @@ internal SolutionsDiagnostic() /// Diagnostics estimated completion time in minutes. /// Required parameters of this item. /// Diagnostic insights. - /// Keeps track of any properties unknown to the library. - internal SolutionsDiagnostic(string solutionId, SelfHelpDiagnosticStatus? status, string statusDetails, string replacementKey, string estimatedCompletionTime, IReadOnlyList requiredParameters, IReadOnlyList insights, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SolutionsDiagnostic(string solutionId, SelfHelpDiagnosticStatus? status, string statusDetails, string replacementKey, string estimatedCompletionTime, IList requiredParameters, IList insights, IDictionary additionalBinaryDataProperties) { SolutionId = solutionId; Status = status; @@ -70,22 +42,28 @@ internal SolutionsDiagnostic(string solutionId, SelfHelpDiagnosticStatus? status EstimatedCompletionTime = estimatedCompletionTime; RequiredParameters = requiredParameters; Insights = insights; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Solution Id to identify single Solutions Diagnostic. public string SolutionId { get; } + /// Denotes the status of the diagnostic resource. public SelfHelpDiagnosticStatus? Status { get; } + /// Details of the status. public string StatusDetails { get; } + /// Place holder used in HTML Content replace control with the content. public string ReplacementKey { get; } + /// Diagnostics estimated completion time in minutes. public string EstimatedCompletionTime { get; } + /// Required parameters of this item. - public IReadOnlyList RequiredParameters { get; } + public IList RequiredParameters { get; } + /// Diagnostic insights. - public IReadOnlyList Insights { get; } + public IList Insights { get; } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsResourcePropertiesSelfHelp.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsResourcePropertiesSelfHelp.Serialization.cs new file mode 100644 index 000000000000..84ab352ccce1 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsResourcePropertiesSelfHelp.Serialization.cs @@ -0,0 +1,209 @@ +// 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.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Solution result. + internal partial class SolutionsResourcePropertiesSelfHelp : IJsonModel + { + /// 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(SolutionsResourcePropertiesSelfHelp)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(SolutionId)) + { + writer.WritePropertyName("solutionId"u8); + writer.WriteStringValue(SolutionId); + } + if (options.Format != "W" && Optional.IsDefined(Title)) + { + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + if (options.Format != "W" && Optional.IsDefined(Content)) + { + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + } + if (options.Format != "W" && Optional.IsDefined(ReplacementMaps)) + { + writer.WritePropertyName("replacementMaps"u8); + writer.WriteObjectValue(ReplacementMaps, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Sections)) + { + writer.WritePropertyName("sections"u8); + writer.WriteStartArray(); + foreach (SolutionSection item in Sections) + { + 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. + SolutionsResourcePropertiesSelfHelp IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SolutionsResourcePropertiesSelfHelp 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(SolutionsResourcePropertiesSelfHelp)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSolutionsResourcePropertiesSelfHelp(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SolutionsResourcePropertiesSelfHelp DeserializeSolutionsResourcePropertiesSelfHelp(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string solutionId = default; + string title = default; + string content = default; + ReplacementMapsResult replacementMaps = default; + IReadOnlyList sections = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("solutionId"u8)) + { + solutionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("title"u8)) + { + title = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("replacementMaps"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + replacementMaps = ReplacementMapsResult.DeserializeReplacementMapsResult(prop.Value, options); + continue; + } + if (prop.NameEquals("sections"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(SolutionSection.DeserializeSolutionSection(item, options)); + } + sections = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SolutionsResourcePropertiesSelfHelp( + solutionId, + title, + content, + replacementMaps, + sections ?? new ChangeTrackingList(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerSelfHelpContext.Default); + default: + throw new FormatException($"The model {nameof(SolutionsResourcePropertiesSelfHelp)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SolutionsResourcePropertiesSelfHelp IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SolutionsResourcePropertiesSelfHelp 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 DeserializeSolutionsResourcePropertiesSelfHelp(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SolutionsResourcePropertiesSelfHelp)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsResourcePropertiesSelfHelp.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsResourcePropertiesSelfHelp.cs new file mode 100644 index 000000000000..953be548b566 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsResourcePropertiesSelfHelp.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Solution result. + internal partial class SolutionsResourcePropertiesSelfHelp + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SolutionsResourcePropertiesSelfHelp() + { + Sections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + /// The title. + /// The HTML content that needs to be rendered and shown to customer. + /// Solution replacement maps. + /// List of section object. + /// Keeps track of any properties unknown to the library. + internal SolutionsResourcePropertiesSelfHelp(string solutionId, string title, string content, ReplacementMapsResult replacementMaps, IReadOnlyList sections, IDictionary additionalBinaryDataProperties) + { + SolutionId = solutionId; + Title = title; + Content = content; + ReplacementMaps = replacementMaps; + Sections = sections; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + public string SolutionId { get; } + + /// The title. + public string Title { get; } + + /// The HTML content that needs to be rendered and shown to customer. + public string Content { get; } + + /// Solution replacement maps. + public ReplacementMapsResult ReplacementMaps { get; } + + /// List of section object. + public IReadOnlyList Sections { get; } = new ChangeTrackingList(); + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsTroubleshooters.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsTroubleshooters.Serialization.cs index 0d9a9e7a3c47..0cd84381007a 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsTroubleshooters.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsTroubleshooters.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class SolutionsTroubleshooters : IUtf8JsonSerializable, IJsonModel + /// Troubleshooters in Solutions. + public partial class SolutionsTroubleshooters : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionsTroubleshooters)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SolutionId)) { writer.WritePropertyName("solutionId"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("summary"u8); writer.WriteStringValue(Summary); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,22 +66,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SolutionsTroubleshooters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SolutionsTroubleshooters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SolutionsTroubleshooters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SolutionsTroubleshooters)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSolutionsTroubleshooters(document.RootElement, options); } - internal static SolutionsTroubleshooters DeserializeSolutionsTroubleshooters(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SolutionsTroubleshooters DeserializeSolutionsTroubleshooters(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,38 +94,39 @@ internal static SolutionsTroubleshooters DeserializeSolutionsTroubleshooters(Jso string solutionId = default; string title = default; string summary = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("solutionId"u8)) + if (prop.NameEquals("solutionId"u8)) { - solutionId = property.Value.GetString(); + solutionId = prop.Value.GetString(); continue; } - if (property.NameEquals("title"u8)) + if (prop.NameEquals("title"u8)) { - title = property.Value.GetString(); + title = prop.Value.GetString(); continue; } - if (property.NameEquals("summary"u8)) + if (prop.NameEquals("summary"u8)) { - summary = property.Value.GetString(); + summary = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SolutionsTroubleshooters(solutionId, title, summary, serializedAdditionalRawData); + return new SolutionsTroubleshooters(solutionId, title, summary, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -130,15 +136,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - SolutionsTroubleshooters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SolutionsTroubleshooters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SolutionsTroubleshooters 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSolutionsTroubleshooters(document.RootElement, options); } default: @@ -146,6 +157,7 @@ SolutionsTroubleshooters IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsTroubleshooters.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsTroubleshooters.cs index 5f6a9d3fc5e2..4d76bacd713f 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsTroubleshooters.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/SolutionsTroubleshooters.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// Troubleshooters in Solutions. public partial class SolutionsTroubleshooters { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal SolutionsTroubleshooters() @@ -54,19 +25,21 @@ internal SolutionsTroubleshooters() /// Solution Id to identify single Solutions Troubleshooter. /// Troubleshooter title. /// Troubleshooter summary. - /// Keeps track of any properties unknown to the library. - internal SolutionsTroubleshooters(string solutionId, string title, string summary, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SolutionsTroubleshooters(string solutionId, string title, string summary, IDictionary additionalBinaryDataProperties) { SolutionId = solutionId; Title = title; Summary = summary; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Solution Id to identify single Solutions Troubleshooter. public string SolutionId { get; } + /// Troubleshooter title. public string Title { get; } + /// Troubleshooter summary. public string Summary { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterContinueContent.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterContinueContent.Serialization.cs index b2f1e15c3085..f347298ee4c6 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterContinueContent.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterContinueContent.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class TroubleshooterContinueContent : IUtf8JsonSerializable, IJsonModel + /// Troubleshooter ContinueRequest body. + public partial class TroubleshooterContinueContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +30,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TroubleshooterContinueContent)} does not support writing '{format}' format."); } - if (Optional.IsDefined(StepId)) { writer.WritePropertyName("stepId"u8); @@ -43,21 +44,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("responses"u8); writer.WriteStartArray(); - foreach (var item in Responses) + foreach (TroubleshooterResult item in Responses) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,45 +67,49 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TroubleshooterContinueContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TroubleshooterContinueContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TroubleshooterContinueContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TroubleshooterContinueContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTroubleshooterContinueContent(document.RootElement, options); } - internal static TroubleshooterContinueContent DeserializeTroubleshooterContinueContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TroubleshooterContinueContent DeserializeTroubleshooterContinueContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string stepId = default; IList responses = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("stepId"u8)) + if (prop.NameEquals("stepId"u8)) { - stepId = property.Value.GetString(); + stepId = prop.Value.GetString(); continue; } - if (property.NameEquals("responses"u8)) + if (prop.NameEquals("responses"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(TroubleshooterResult.DeserializeTroubleshooterResult(item, options)); } @@ -113,17 +118,19 @@ internal static TroubleshooterContinueContent DeserializeTroubleshooterContinueC } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TroubleshooterContinueContent(stepId, responses ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new TroubleshooterContinueContent(stepId, responses ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -133,15 +140,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - TroubleshooterContinueContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TroubleshooterContinueContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TroubleshooterContinueContent 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTroubleshooterContinueContent(document.RootElement, options); } default: @@ -149,6 +161,19 @@ TroubleshooterContinueContent IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TroubleshooterContinueContent troubleshooterContinueContent) + { + if (troubleshooterContinueContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(troubleshooterContinueContent, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterContinueContent.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterContinueContent.cs index 0d34451a4f2a..94ea02f4940e 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterContinueContent.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterContinueContent.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Troubleshooter ContinueRequest body. public partial class TroubleshooterContinueContent { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TroubleshooterContinueContent() @@ -54,17 +26,18 @@ public TroubleshooterContinueContent() /// Initializes a new instance of . /// Unique id of the result. /// - /// Keeps track of any properties unknown to the library. - internal TroubleshooterContinueContent(string stepId, IList responses, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TroubleshooterContinueContent(string stepId, IList responses, IDictionary additionalBinaryDataProperties) { StepId = stepId; Responses = responses; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Unique id of the result. public string StepId { get; set; } - /// Gets the responses. + + /// Gets the Responses. public IList Responses { get; } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterExecutionStatus.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterExecutionStatus.cs index a8c0fa380786..7531e59f4d1c 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterExecutionStatus.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterExecutionStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,44 +15,67 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct TroubleshooterExecutionStatus : IEquatable { private readonly string _value; + /// Step execution succeeded. + private const string SuccessValue = "Success"; + /// Step execution running. + private const string RunningValue = "Running"; + /// Step execution failed. + private const string FailedValue = "Failed"; + /// Step execution warning. + private const string WarningValue = "Warning"; /// Initializes a new instance of . + /// The value. /// is null. public TroubleshooterExecutionStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SuccessValue = "Success"; - private const string RunningValue = "Running"; - private const string FailedValue = "Failed"; - private const string WarningValue = "Warning"; + _value = value; + } /// Step execution succeeded. public static TroubleshooterExecutionStatus Success { get; } = new TroubleshooterExecutionStatus(SuccessValue); + /// Step execution running. public static TroubleshooterExecutionStatus Running { get; } = new TroubleshooterExecutionStatus(RunningValue); + /// Step execution failed. public static TroubleshooterExecutionStatus Failed { get; } = new TroubleshooterExecutionStatus(FailedValue); + /// Step execution warning. public static TroubleshooterExecutionStatus Warning { get; } = new TroubleshooterExecutionStatus(WarningValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TroubleshooterExecutionStatus left, TroubleshooterExecutionStatus 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 !=(TroubleshooterExecutionStatus left, TroubleshooterExecutionStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TroubleshooterExecutionStatus(string value) => new TroubleshooterExecutionStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TroubleshooterExecutionStatus?(string value) => value == null ? null : new TroubleshooterExecutionStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TroubleshooterExecutionStatus other && Equals(other); - /// + + /// public bool Equals(TroubleshooterExecutionStatus 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterInstanceProperties.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterInstanceProperties.Serialization.cs new file mode 100644 index 000000000000..3c69658f51bc --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterInstanceProperties.Serialization.cs @@ -0,0 +1,219 @@ +// 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.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Troubleshooter Instance properties. + internal partial class TroubleshooterInstanceProperties : IJsonModel + { + /// 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(TroubleshooterInstanceProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(SolutionId)) + { + writer.WritePropertyName("solutionId"u8); + writer.WriteStringValue(SolutionId); + } + if (Optional.IsCollectionDefined(Parameters)) + { + writer.WritePropertyName("parameters"u8); + writer.WriteStartObject(); + foreach (var item in Parameters) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Steps)) + { + writer.WritePropertyName("steps"u8); + writer.WriteStartArray(); + foreach (SelfHelpStep item in Steps) + { + 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. + TroubleshooterInstanceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TroubleshooterInstanceProperties 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(TroubleshooterInstanceProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTroubleshooterInstanceProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TroubleshooterInstanceProperties DeserializeTroubleshooterInstanceProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string solutionId = default; + IDictionary parameters = default; + TroubleshooterProvisioningState? provisioningState = default; + IReadOnlyList steps = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("solutionId"u8)) + { + solutionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"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()); + } + } + parameters = dictionary; + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new TroubleshooterProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("steps"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(SelfHelpStep.DeserializeSelfHelpStep(item, options)); + } + steps = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TroubleshooterInstanceProperties(solutionId, parameters ?? new ChangeTrackingDictionary(), provisioningState, steps ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerSelfHelpContext.Default); + default: + throw new FormatException($"The model {nameof(TroubleshooterInstanceProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + TroubleshooterInstanceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TroubleshooterInstanceProperties 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 DeserializeTroubleshooterInstanceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TroubleshooterInstanceProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterInstanceProperties.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterInstanceProperties.cs new file mode 100644 index 000000000000..724551600cc3 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterInstanceProperties.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; + +namespace Azure.ResourceManager.SelfHelp.Models +{ + /// Troubleshooter Instance properties. + internal partial class TroubleshooterInstanceProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TroubleshooterInstanceProperties() + { + Parameters = new ChangeTrackingDictionary(); + Steps = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Solution Id to identify single troubleshooter. + /// Client input parameters to run Troubleshooter Resource. + /// Status of troubleshooter provisioning. + /// List of step object. + /// Keeps track of any properties unknown to the library. + internal TroubleshooterInstanceProperties(string solutionId, IDictionary parameters, TroubleshooterProvisioningState? provisioningState, IReadOnlyList steps, IDictionary additionalBinaryDataProperties) + { + SolutionId = solutionId; + Parameters = parameters; + ProvisioningState = provisioningState; + Steps = steps; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Solution Id to identify single troubleshooter. + public string SolutionId { get; set; } + + /// Client input parameters to run Troubleshooter Resource. + public IDictionary Parameters { get; } = new ChangeTrackingDictionary(); + + /// Status of troubleshooter provisioning. + public TroubleshooterProvisioningState? ProvisioningState { get; } + + /// List of step object. + public IReadOnlyList Steps { get; } = new ChangeTrackingList(); + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterProvisioningState.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterProvisioningState.cs index 38807398f43c..8e184b893ee2 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterProvisioningState.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterProvisioningState.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,47 +15,67 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct TroubleshooterProvisioningState : IEquatable { private readonly string _value; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + private const string RunningValue = "Running"; + private const string AutoContinueValue = "AutoContinue"; /// Initializes a new instance of . + /// The value. /// is null. public TroubleshooterProvisioningState(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SucceededValue = "Succeeded"; - private const string FailedValue = "Failed"; - private const string CanceledValue = "Canceled"; - private const string RunningValue = "Running"; - private const string AutoContinueValue = "AutoContinue"; + _value = value; + } - /// Succeeded. + /// Gets the Succeeded. public static TroubleshooterProvisioningState Succeeded { get; } = new TroubleshooterProvisioningState(SucceededValue); - /// Failed. + + /// Gets the Failed. public static TroubleshooterProvisioningState Failed { get; } = new TroubleshooterProvisioningState(FailedValue); - /// Canceled. + + /// Gets the Canceled. public static TroubleshooterProvisioningState Canceled { get; } = new TroubleshooterProvisioningState(CanceledValue); - /// Running. + + /// Gets the Running. public static TroubleshooterProvisioningState Running { get; } = new TroubleshooterProvisioningState(RunningValue); - /// AutoContinue. + + /// Gets the AutoContinue. public static TroubleshooterProvisioningState AutoContinue { get; } = new TroubleshooterProvisioningState(AutoContinueValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TroubleshooterProvisioningState left, TroubleshooterProvisioningState 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 !=(TroubleshooterProvisioningState left, TroubleshooterProvisioningState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TroubleshooterProvisioningState(string value) => new TroubleshooterProvisioningState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TroubleshooterProvisioningState?(string value) => value == null ? null : new TroubleshooterProvisioningState(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TroubleshooterProvisioningState other && Equals(other); - /// + + /// public bool Equals(TroubleshooterProvisioningState 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterQuestionContentType.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterQuestionContentType.cs index 218bd981d8f4..ff79e5031ffc 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterQuestionContentType.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterQuestionContentType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,41 +15,59 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct TroubleshooterQuestionContentType : IEquatable { private readonly string _value; + private const string TextValue = "Text"; + private const string HtmlValue = "Html"; + private const string MarkdownValue = "Markdown"; /// Initializes a new instance of . + /// The value. /// is null. public TroubleshooterQuestionContentType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string TextValue = "Text"; - private const string HtmlValue = "Html"; - private const string MarkdownValue = "Markdown"; + _value = value; + } - /// Text. + /// Gets the Text. public static TroubleshooterQuestionContentType Text { get; } = new TroubleshooterQuestionContentType(TextValue); - /// Html. + + /// Gets the Html. public static TroubleshooterQuestionContentType Html { get; } = new TroubleshooterQuestionContentType(HtmlValue); - /// Markdown. + + /// Gets the Markdown. public static TroubleshooterQuestionContentType Markdown { get; } = new TroubleshooterQuestionContentType(MarkdownValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TroubleshooterQuestionContentType left, TroubleshooterQuestionContentType 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 !=(TroubleshooterQuestionContentType left, TroubleshooterQuestionContentType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TroubleshooterQuestionContentType(string value) => new TroubleshooterQuestionContentType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TroubleshooterQuestionContentType?(string value) => value == null ? null : new TroubleshooterQuestionContentType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TroubleshooterQuestionContentType other && Equals(other); - /// + + /// public bool Equals(TroubleshooterQuestionContentType 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterQuestionType.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterQuestionType.cs index ff69f51f372a..8d980a31e324 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterQuestionType.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterQuestionType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,50 +15,77 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct TroubleshooterQuestionType : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public TroubleshooterQuestionType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - + /// SingleChoice radio button. private const string RadioButtonValue = "RadioButton"; + /// SingleChoice dropdown. private const string DropdownValue = "Dropdown"; + /// Text Input. private const string TextInputValue = "TextInput"; + /// MultiLineInfoBox. private const string MultiLineInfoBoxValue = "MultiLineInfoBox"; + /// DateTime Picker. private const string DateTimePickerValue = "DateTimePicker"; + /// Multi Select. private const string MultiSelectValue = "MultiSelect"; + /// Initializes a new instance of . + /// The value. + /// is null. + public TroubleshooterQuestionType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// SingleChoice radio button. public static TroubleshooterQuestionType RadioButton { get; } = new TroubleshooterQuestionType(RadioButtonValue); + /// SingleChoice dropdown. public static TroubleshooterQuestionType Dropdown { get; } = new TroubleshooterQuestionType(DropdownValue); + /// Text Input. public static TroubleshooterQuestionType TextInput { get; } = new TroubleshooterQuestionType(TextInputValue); + /// MultiLineInfoBox. public static TroubleshooterQuestionType MultiLineInfoBox { get; } = new TroubleshooterQuestionType(MultiLineInfoBoxValue); + /// DateTime Picker. public static TroubleshooterQuestionType DateTimePicker { get; } = new TroubleshooterQuestionType(DateTimePickerValue); + /// Multi Select. public static TroubleshooterQuestionType MultiSelect { get; } = new TroubleshooterQuestionType(MultiSelectValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TroubleshooterQuestionType left, TroubleshooterQuestionType 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 !=(TroubleshooterQuestionType left, TroubleshooterQuestionType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TroubleshooterQuestionType(string value) => new TroubleshooterQuestionType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TroubleshooterQuestionType?(string value) => value == null ? null : new TroubleshooterQuestionType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TroubleshooterQuestionType other && Equals(other); - /// + + /// public bool Equals(TroubleshooterQuestionType 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterResult.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterResult.Serialization.cs index 52014fbd07f0..71efd2de8ad0 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterResult.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterResult.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class TroubleshooterResult : IUtf8JsonSerializable, IJsonModel + /// User Response for Troubleshooter continue request. + public partial class TroubleshooterResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TroubleshooterResult)} does not support writing '{format}' format."); } - if (Optional.IsDefined(QuestionId)) { writer.WritePropertyName("questionId"u8); @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("response"u8); writer.WriteStringValue(Response); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,22 +66,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TroubleshooterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TroubleshooterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TroubleshooterResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TroubleshooterResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTroubleshooterResult(document.RootElement, options); } - internal static TroubleshooterResult DeserializeTroubleshooterResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TroubleshooterResult DeserializeTroubleshooterResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,42 +94,43 @@ internal static TroubleshooterResult DeserializeTroubleshooterResult(JsonElement string questionId = default; TroubleshooterQuestionType? questionType = default; string response = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("questionId"u8)) + if (prop.NameEquals("questionId"u8)) { - questionId = property.Value.GetString(); + questionId = prop.Value.GetString(); continue; } - if (property.NameEquals("questionType"u8)) + if (prop.NameEquals("questionType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - questionType = new TroubleshooterQuestionType(property.Value.GetString()); + questionType = new TroubleshooterQuestionType(prop.Value.GetString()); continue; } - if (property.NameEquals("response"u8)) + if (prop.NameEquals("response"u8)) { - response = property.Value.GetString(); + response = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TroubleshooterResult(questionId, questionType, response, serializedAdditionalRawData); + return new TroubleshooterResult(questionId, questionType, response, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -134,15 +140,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - TroubleshooterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TroubleshooterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TroubleshooterResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTroubleshooterResult(document.RootElement, options); } default: @@ -150,6 +161,7 @@ TroubleshooterResult IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterResult.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterResult.cs index 536baeeda8bc..30846077bda5 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterResult.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterResult.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// User Response for Troubleshooter continue request. public partial class TroubleshooterResult { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TroubleshooterResult() @@ -54,19 +25,21 @@ public TroubleshooterResult() /// id of the question. /// Type of Question. /// Response key for SingleInput. For Multi-line test/open ended question it is free form text. - /// Keeps track of any properties unknown to the library. - internal TroubleshooterResult(string questionId, TroubleshooterQuestionType? questionType, string response, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TroubleshooterResult(string questionId, TroubleshooterQuestionType? questionType, string response, IDictionary additionalBinaryDataProperties) { QuestionId = questionId; QuestionType = questionType; Response = response; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// id of the question. public string QuestionId { get; set; } + /// Type of Question. public TroubleshooterQuestionType? QuestionType { get; set; } + /// Response key for SingleInput. For Multi-line test/open ended question it is free form text. public string Response { get; set; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterStepInput.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterStepInput.Serialization.cs index 55f03b8f05e7..89bb84823218 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterStepInput.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterStepInput.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class TroubleshooterStepInput : IUtf8JsonSerializable, IJsonModel + /// Details of step input. + public partial class TroubleshooterStepInput : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TroubleshooterStepInput)} does not support writing '{format}' format."); } - if (Optional.IsDefined(QuestionId)) { writer.WritePropertyName("questionId"u8); @@ -83,21 +83,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("responseOptions"u8); writer.WriteStartArray(); - foreach (var item in ResponseOptions) + foreach (ResponseConfig item in ResponseOptions) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -106,22 +106,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TroubleshooterStepInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TroubleshooterStepInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TroubleshooterStepInput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TroubleshooterStepInput)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTroubleshooterStepInput(document.RootElement, options); } - internal static TroubleshooterStepInput DeserializeTroubleshooterStepInput(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TroubleshooterStepInput DeserializeTroubleshooterStepInput(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -135,76 +140,75 @@ internal static TroubleshooterStepInput DeserializeTroubleshooterStepInput(JsonE string recommendedOption = default; string selectedOptionValue = default; ResponseValidationProperties responseValidationProperties = default; - IReadOnlyList responseOptions = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList responseOptions = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("questionId"u8)) + if (prop.NameEquals("questionId"u8)) { - questionId = property.Value.GetString(); + questionId = prop.Value.GetString(); continue; } - if (property.NameEquals("questionType"u8)) + if (prop.NameEquals("questionType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - questionType = new TroubleshooterQuestionType(property.Value.GetString()); + questionType = new TroubleshooterQuestionType(prop.Value.GetString()); continue; } - if (property.NameEquals("questionTitle"u8)) + if (prop.NameEquals("questionTitle"u8)) { - questionTitle = property.Value.GetString(); + questionTitle = prop.Value.GetString(); continue; } - if (property.NameEquals("questionContent"u8)) + if (prop.NameEquals("questionContent"u8)) { - questionContent = property.Value.GetString(); + questionContent = prop.Value.GetString(); continue; } - if (property.NameEquals("questionContentType"u8)) + if (prop.NameEquals("questionContentType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - questionContentType = new TroubleshooterQuestionContentType(property.Value.GetString()); + questionContentType = new TroubleshooterQuestionContentType(prop.Value.GetString()); continue; } - if (property.NameEquals("responseHint"u8)) + if (prop.NameEquals("responseHint"u8)) { - responseHint = property.Value.GetString(); + responseHint = prop.Value.GetString(); continue; } - if (property.NameEquals("recommendedOption"u8)) + if (prop.NameEquals("recommendedOption"u8)) { - recommendedOption = property.Value.GetString(); + recommendedOption = prop.Value.GetString(); continue; } - if (property.NameEquals("selectedOptionValue"u8)) + if (prop.NameEquals("selectedOptionValue"u8)) { - selectedOptionValue = property.Value.GetString(); + selectedOptionValue = prop.Value.GetString(); continue; } - if (property.NameEquals("responseValidationProperties"u8)) + if (prop.NameEquals("responseValidationProperties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - responseValidationProperties = ResponseValidationProperties.DeserializeResponseValidationProperties(property.Value, options); + responseValidationProperties = ResponseValidationProperties.DeserializeResponseValidationProperties(prop.Value, options); continue; } - if (property.NameEquals("responseOptions"u8)) + if (prop.NameEquals("responseOptions"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(ResponseConfig.DeserializeResponseConfig(item, options)); } @@ -213,10 +217,9 @@ internal static TroubleshooterStepInput DeserializeTroubleshooterStepInput(JsonE } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TroubleshooterStepInput( questionId, questionType, @@ -228,13 +231,16 @@ internal static TroubleshooterStepInput DeserializeTroubleshooterStepInput(JsonE selectedOptionValue, responseValidationProperties, responseOptions ?? new ChangeTrackingList(), - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -244,15 +250,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - TroubleshooterStepInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TroubleshooterStepInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TroubleshooterStepInput 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTroubleshooterStepInput(document.RootElement, options); } default: @@ -260,6 +271,7 @@ TroubleshooterStepInput IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterStepInput.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterStepInput.cs index 4d552226ff0f..6df91cf425f4 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterStepInput.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterStepInput.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Details of step input. public partial class TroubleshooterStepInput { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal TroubleshooterStepInput() @@ -62,8 +34,8 @@ internal TroubleshooterStepInput() /// Text of response that was selected. /// Troubleshooter step input response validation properties. /// - /// Keeps track of any properties unknown to the library. - internal TroubleshooterStepInput(string questionId, TroubleshooterQuestionType? questionType, string questionTitle, string questionContent, TroubleshooterQuestionContentType? questionContentType, string responseHint, string recommendedOption, string selectedOptionValue, ResponseValidationProperties responseValidationProperties, IReadOnlyList responseOptions, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TroubleshooterStepInput(string questionId, TroubleshooterQuestionType? questionType, string questionTitle, string questionContent, TroubleshooterQuestionContentType? questionContentType, string responseHint, string recommendedOption, string selectedOptionValue, ResponseValidationProperties responseValidationProperties, IList responseOptions, IDictionary additionalBinaryDataProperties) { QuestionId = questionId; QuestionType = questionType; @@ -75,28 +47,37 @@ internal TroubleshooterStepInput(string questionId, TroubleshooterQuestionType? SelectedOptionValue = selectedOptionValue; ResponseValidationProperties = responseValidationProperties; ResponseOptions = responseOptions; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Use Index as QuestionId. public string QuestionId { get; } + /// Type of Question. public TroubleshooterQuestionType? QuestionType { get; } + /// Question title. public string QuestionTitle { get; } + /// User question content. public string QuestionContent { get; } + /// Default is Text. public TroubleshooterQuestionContentType? QuestionContentType { get; } + /// Place holder text for response hints. public string ResponseHint { get; } + /// Result of Automate step. public string RecommendedOption { get; } + /// Text of response that was selected. public string SelectedOptionValue { get; } + /// Troubleshooter step input response validation properties. public ResponseValidationProperties ResponseValidationProperties { get; } - /// Gets the response options. - public IReadOnlyList ResponseOptions { get; } + + /// Gets the ResponseOptions. + public IList ResponseOptions { get; } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterValidationScope.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterValidationScope.cs index 972dc19200cd..478f3d44af39 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterValidationScope.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/TroubleshooterValidationScope.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { @@ -14,47 +15,67 @@ namespace Azure.ResourceManager.SelfHelp.Models public readonly partial struct TroubleshooterValidationScope : IEquatable { private readonly string _value; + private const string NoneValue = "None"; + private const string UrlFormatValue = "URLFormat"; + private const string GuidFormatValue = "GuidFormat"; + private const string IpAddressFormatValue = "IpAddressFormat"; + private const string NumberOnlyFormatValue = "NumberOnlyFormat"; /// Initializes a new instance of . + /// The value. /// is null. public TroubleshooterValidationScope(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string NoneValue = "None"; - private const string UrlFormatValue = "URLFormat"; - private const string GuidFormatValue = "GuidFormat"; - private const string IPAddressFormatValue = "IpAddressFormat"; - private const string NumberOnlyFormatValue = "NumberOnlyFormat"; + _value = value; + } - /// None. + /// Gets the None. public static TroubleshooterValidationScope None { get; } = new TroubleshooterValidationScope(NoneValue); - /// URLFormat. + + /// Gets the UrlFormat. public static TroubleshooterValidationScope UrlFormat { get; } = new TroubleshooterValidationScope(UrlFormatValue); - /// GuidFormat. + + /// Gets the GuidFormat. public static TroubleshooterValidationScope GuidFormat { get; } = new TroubleshooterValidationScope(GuidFormatValue); - /// IpAddressFormat. - public static TroubleshooterValidationScope IPAddressFormat { get; } = new TroubleshooterValidationScope(IPAddressFormatValue); - /// NumberOnlyFormat. + + /// Gets the IpAddressFormat. + public static TroubleshooterValidationScope IpAddressFormat { get; } = new TroubleshooterValidationScope(IpAddressFormatValue); + + /// Gets the NumberOnlyFormat. public static TroubleshooterValidationScope NumberOnlyFormat { get; } = new TroubleshooterValidationScope(NumberOnlyFormatValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TroubleshooterValidationScope left, TroubleshooterValidationScope 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 !=(TroubleshooterValidationScope left, TroubleshooterValidationScope right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TroubleshooterValidationScope(string value) => new TroubleshooterValidationScope(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TroubleshooterValidationScope?(string value) => value == null ? null : new TroubleshooterValidationScope(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TroubleshooterValidationScope other && Equals(other); - /// + + /// public bool Equals(TroubleshooterValidationScope 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/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupDetail.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupDetail.Serialization.cs index 24bb3d16f5df..ca08255f61cc 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupDetail.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupDetail.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class VideoGroupDetail : IUtf8JsonSerializable, IJsonModel + /// Video group detail. + public partial class VideoGroupDetail : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,17 +29,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(VideoGroupDetail)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Videos)) { writer.WritePropertyName("videos"u8); writer.WriteStartArray(); - foreach (var item in Videos) + foreach (VideoGroupVideo item in Videos) { writer.WriteObjectValue(item, options); } @@ -49,15 +49,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("replacementKey"u8); writer.WriteStringValue(ReplacementKey); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,64 +66,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - VideoGroupDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + VideoGroupDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual VideoGroupDetail JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(VideoGroupDetail)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeVideoGroupDetail(document.RootElement, options); } - internal static VideoGroupDetail DeserializeVideoGroupDetail(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static VideoGroupDetail DeserializeVideoGroupDetail(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList videos = default; + IList videos = default; string replacementKey = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("videos"u8)) + if (prop.NameEquals("videos"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(VideoGroupVideo.DeserializeVideoGroupVideo(item, options)); } videos = array; continue; } - if (property.NameEquals("replacementKey"u8)) + if (prop.NameEquals("replacementKey"u8)) { - replacementKey = property.Value.GetString(); + replacementKey = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new VideoGroupDetail(videos ?? new ChangeTrackingList(), replacementKey, serializedAdditionalRawData); + return new VideoGroupDetail(videos ?? new ChangeTrackingList(), replacementKey, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -133,15 +139,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - VideoGroupDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + VideoGroupDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual VideoGroupDetail 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeVideoGroupDetail(document.RootElement, options); } default: @@ -149,6 +160,7 @@ VideoGroupDetail IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupDetail.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupDetail.cs index 9714f440f522..dc4a5bb6826d 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupDetail.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupDetail.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { /// Video group detail. public partial class VideoGroupDetail { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal VideoGroupDetail() @@ -54,16 +26,17 @@ internal VideoGroupDetail() /// Initializes a new instance of . /// List of videos will be shown to customers. /// Place holder used in HTML Content replace control with the insight content. - /// Keeps track of any properties unknown to the library. - internal VideoGroupDetail(IReadOnlyList videos, string replacementKey, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal VideoGroupDetail(IList videos, string replacementKey, IDictionary additionalBinaryDataProperties) { Videos = videos; ReplacementKey = replacementKey; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// List of videos will be shown to customers. - public IReadOnlyList Videos { get; } + public IList Videos { get; } + /// Place holder used in HTML Content replace control with the insight content. public string ReplacementKey { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupVideo.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupVideo.Serialization.cs index 4293da029b14..54e621e9bb55 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupVideo.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupVideo.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SelfHelp; namespace Azure.ResourceManager.SelfHelp.Models { - public partial class VideoGroupVideo : IUtf8JsonSerializable, IJsonModel + /// VideoGroup video detail. + public partial class VideoGroupVideo : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(VideoGroupVideo)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Src)) { writer.WritePropertyName("src"u8); @@ -44,15 +44,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("title"u8); writer.WriteStringValue(Title); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,55 +61,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - VideoGroupVideo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + VideoGroupVideo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual VideoGroupVideo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(VideoGroupVideo)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeVideoGroupVideo(document.RootElement, options); } - internal static VideoGroupVideo DeserializeVideoGroupVideo(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static VideoGroupVideo DeserializeVideoGroupVideo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string src = default; string title = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("src"u8)) + if (prop.NameEquals("src"u8)) { - src = property.Value.GetString(); + src = prop.Value.GetString(); continue; } - if (property.NameEquals("title"u8)) + if (prop.NameEquals("title"u8)) { - title = property.Value.GetString(); + title = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new VideoGroupVideo(src, title, serializedAdditionalRawData); + return new VideoGroupVideo(src, title, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -119,15 +125,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - VideoGroupVideo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + VideoGroupVideo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual VideoGroupVideo 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeVideoGroupVideo(document.RootElement, options); } default: @@ -135,6 +146,7 @@ VideoGroupVideo IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupVideo.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupVideo.cs index a8eb07b9ef25..6bad8b5826d9 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupVideo.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/Models/VideoGroupVideo.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SelfHelp.Models /// VideoGroup video detail. public partial class VideoGroupVideo { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal VideoGroupVideo() @@ -53,16 +24,17 @@ internal VideoGroupVideo() /// Initializes a new instance of . /// Link to the video. /// Title of the video. - /// Keeps track of any properties unknown to the library. - internal VideoGroupVideo(string src, string title, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal VideoGroupVideo(string src, string title, IDictionary additionalBinaryDataProperties) { Src = src; Title = title; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Link to the video. public string Src { get; } + /// Title of the video. public string Title { get; } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/ProviderConstants.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/ProviderConstants.cs index 93312bff5f70..60a265a6f12b 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/ProviderConstants.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/ProviderConstants.cs @@ -9,8 +9,9 @@ namespace Azure.ResourceManager.SelfHelp { - internal static class ProviderConstants + internal static partial class ProviderConstants { + /// Gets the DefaultProviderNamespace. public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/CheckNameAvailabilityRestOperations.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/CheckNameAvailabilityRestOperations.cs deleted file mode 100644 index 7143a0d9b2a3..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/CheckNameAvailabilityRestOperations.cs +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.SelfHelp.Models; - -namespace Azure.ResourceManager.SelfHelp -{ - internal partial class CheckNameAvailabilityRestOperations - { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; - private readonly Uri _endpoint; - private readonly string _apiVersion; - - /// Initializes a new instance of CheckNameAvailabilityRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public CheckNameAvailabilityRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) - { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateCheckSelfHelpNameAvailabilityRequestUri(string scope, SelfHelpNameAvailabilityContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/checkNameAvailability", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateCheckSelfHelpNameAvailabilityRequest(string scope, SelfHelpNameAvailabilityContent content) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/checkNameAvailability", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - if (content != null) - { - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; - } - _userAgent.Apply(message); - return message; - } - - /// This API is used to check the uniqueness of a resource name used for a diagnostic, troubleshooter or solutions. - /// The fully qualified Azure Resource manager identifier of the resource. - /// The required parameters for availability check. - /// The cancellation token to use. - /// is null. - public async Task> CheckSelfHelpNameAvailabilityAsync(string scope, SelfHelpNameAvailabilityContent content = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - - using var message = CreateCheckSelfHelpNameAvailabilityRequest(scope, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SelfHelpNameAvailabilityResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SelfHelpNameAvailabilityResult.DeserializeSelfHelpNameAvailabilityResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// This API is used to check the uniqueness of a resource name used for a diagnostic, troubleshooter or solutions. - /// The fully qualified Azure Resource manager identifier of the resource. - /// The required parameters for availability check. - /// The cancellation token to use. - /// is null. - public Response CheckSelfHelpNameAvailability(string scope, SelfHelpNameAvailabilityContent content = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - - using var message = CreateCheckSelfHelpNameAvailabilityRequest(scope, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SelfHelpNameAvailabilityResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SelfHelpNameAvailabilityResult.DeserializeSelfHelpNameAvailabilityResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiagnosticResourcesRestOperations.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiagnosticResourcesRestOperations.cs index 8fe9685e6815..245aa9fb8f2d 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiagnosticResourcesRestOperations.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiagnosticResourcesRestOperations.cs @@ -6,205 +6,78 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; namespace Azure.ResourceManager.SelfHelp { - internal partial class DiagnosticResourcesRestOperations + internal partial class DiagnosticResources { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of DiagnosticResourcesRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public DiagnosticResourcesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of DiagnosticResources for mocking. + protected DiagnosticResources() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string scope, string diagnosticsResourceName) + /// Initializes a new instance of DiagnosticResources. + /// 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 DiagnosticResources(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/diagnostics/", false); - uri.AppendPath(diagnosticsResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRequest(string scope, string diagnosticsResourceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/diagnostics/", false); - uri.AppendPath(diagnosticsResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Unique resource name for insight resources. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string scope, string diagnosticsResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - - using var message = CreateGetRequest(scope, diagnosticsResourceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SelfHelpDiagnosticData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SelfHelpDiagnosticData.DeserializeSelfHelpDiagnosticData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((SelfHelpDiagnosticData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Unique resource name for insight resources. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response Get(string scope, string diagnosticsResourceName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetRequest(string scope, string diagnosticsResourceName, RequestContext context) { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - - using var message = CreateGetRequest(scope, diagnosticsResourceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SelfHelpDiagnosticData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SelfHelpDiagnosticData.DeserializeSelfHelpDiagnosticData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((SelfHelpDiagnosticData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateRequestUri(string scope, string diagnosticsResourceName, SelfHelpDiagnosticData data) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); uri.AppendPath("/providers/Microsoft.Help/diagnostics/", false); uri.AppendPath(diagnosticsResourceName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + 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 CreateCreateRequest(string scope, string diagnosticsResourceName, SelfHelpDiagnosticData data) + internal HttpMessage CreateCreateRequest(string scope, string diagnosticsResourceName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); uri.AppendPath("/providers/Microsoft.Help/diagnostics/", false); uri.AppendPath(diagnosticsResourceName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); - request.Content = content; - _userAgent.Apply(message); - return message; - } - - /// Creates a diagnostic for the specific resource using solutionId from discovery solutions. <br/>Diagnostics are powerful solutions that access product resources or other relevant data and provide the root cause of the issue and the steps to address the issue.<br/><br/>. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Unique resource name for insight resources. - /// The required request body for this insightResource invocation. - /// The cancellation token to use. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public async Task CreateAsync(string scope, string diagnosticsResourceName, SelfHelpDiagnosticData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(scope, diagnosticsResourceName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Creates a diagnostic for the specific resource using solutionId from discovery solutions. <br/>Diagnostics are powerful solutions that access product resources or other relevant data and provide the root cause of the issue and the steps to address the issue.<br/><br/>. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Unique resource name for insight resources. - /// The required request body for this insightResource invocation. - /// The cancellation token to use. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public Response Create(string scope, string diagnosticsResourceName, SelfHelpDiagnosticData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(scope, diagnosticsResourceName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) + request.Method = RequestMethod.Put; + if ("application/json" != null) { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); + request.Headers.SetValue("Content-Type", "application/json"); } + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionNLPOperationGroupRestOperations.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionNLPOperationGroupRestOperations.cs index 1430a5a34f2b..404594470012 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionNLPOperationGroupRestOperations.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionNLPOperationGroupRestOperations.cs @@ -6,107 +6,58 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp { - internal partial class DiscoverySolutionNLPOperationGroupRestOperations + internal partial class DiscoverySolutionNLPOperationGroup { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of DiscoverySolutionNLPOperationGroupRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public DiscoverySolutionNLPOperationGroupRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of DiscoverySolutionNLPOperationGroup for mocking. + protected DiscoverySolutionNLPOperationGroup() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateDiscoverSolutionsNlpRequestUri(DiscoveryNlpContent content) + /// Initializes a new instance of DiscoverySolutionNLPOperationGroup. + /// 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 DiscoverySolutionNLPOperationGroup(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Help/discoverSolutions", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateDiscoverSolutionsNlpRequest(DiscoveryNlpContent content) + /// 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 CreateDiscoverSolutionsNlpRequest(RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/providers/Microsoft.Help/discoverSolutions", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - if (content != null) + request.Method = RequestMethod.Post; + if ("application/json" != null) { - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; + request.Headers.SetValue("Content-Type", "application/json"); } - _userAgent.Apply(message); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; return message; } - - /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary. - /// The request body. - /// The cancellation token to use. - public async Task> DiscoverSolutionsNlpAsync(DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) - { - using var message = CreateDiscoverSolutionsNlpRequest(content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DiscoveryNlpResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DiscoveryNlpResult.DeserializeDiscoveryNlpResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary. - /// The request body. - /// The cancellation token to use. - public Response DiscoverSolutionsNlp(DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) - { - using var message = CreateDiscoverSolutionsNlpRequest(content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DiscoveryNlpResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DiscoveryNlpResult.DeserializeDiscoveryNlpResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionNLPRestOperations.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionNLPRestOperations.cs index cbadbbb5ecbe..8d41eeb2deb0 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionNLPRestOperations.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionNLPRestOperations.cs @@ -6,121 +6,60 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp { - internal partial class DiscoverySolutionNLPRestOperations + internal partial class DiscoverySolutionNLP { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of DiscoverySolutionNLPRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public DiscoverySolutionNLPRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of DiscoverySolutionNLP for mocking. + protected DiscoverySolutionNLP() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateDiscoverSolutionsNlpRequestUri(string subscriptionId, DiscoveryNlpContent content) + /// Initializes a new instance of DiscoverySolutionNLP. + /// 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 DiscoverySolutionNLP(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Help/discoverSolutions", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateDiscoverSolutionsNlpRequest(string subscriptionId, DiscoveryNlpContent content) + /// 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 CreateDiscoverSolutionsNlpRequest(Guid subscriptionId, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/providers/Microsoft.Help/discoverSolutions", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - if (content != null) + request.Method = RequestMethod.Post; + if ("application/json" != null) { - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; + request.Headers.SetValue("Content-Type", "application/json"); } - _userAgent.Apply(message); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; return message; } - - /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary and subscription. - /// The ID of the target subscription. The value must be an UUID. - /// The request body. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> DiscoverSolutionsNlpAsync(string subscriptionId, DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateDiscoverSolutionsNlpRequest(subscriptionId, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DiscoveryNlpResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DiscoveryNlpResult.DeserializeDiscoveryNlpResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Search for relevant Azure Diagnostics, Solutions and Troubleshooters using a natural language issue summary and subscription. - /// The ID of the target subscription. The value must be an UUID. - /// The request body. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response DiscoverSolutionsNlp(string subscriptionId, DiscoveryNlpContent content = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateDiscoverSolutionsNlpRequest(subscriptionId, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DiscoveryNlpResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DiscoveryNlpResult.DeserializeDiscoveryNlpResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionRestOperations.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionRestOperations.cs index 5e2795439ee9..37ca241e0f26 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionRestOperations.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/DiscoverySolutionRestOperations.cs @@ -6,59 +6,44 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp { - internal partial class DiscoverySolutionRestOperations + internal partial class DiscoverySolution { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of DiscoverySolutionRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public DiscoverySolutionRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of DiscoverySolution for mocking. + protected DiscoverySolution() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateDiscoverSolutionsRequestUri(string filter, string skiptoken) + /// Initializes a new instance of DiscoverySolution. + /// 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 DiscoverySolution(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Help/discoverySolutions", false); - uri.AppendQuery("api-version", _apiVersion, true); - if (filter != null) - { - uri.AppendQuery("$filter", filter, true); - } - if (skiptoken != null) - { - uri.AppendQuery("$skiptoken", skiptoken, true); - } - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateDiscoverSolutionsRequest(string filter, string skiptoken) + /// 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 CreateDiscoverSolutionsRequest(string filter, string skiptoken, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/providers/Microsoft.Help/discoverySolutions", false); uri.AppendQuery("api-version", _apiVersion, true); @@ -70,128 +55,24 @@ internal HttpMessage CreateDiscoverSolutionsRequest(string filter, string skipto { uri.AppendQuery("$skiptoken", skiptoken, true); } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Lists the relevant Azure Diagnostics, Solutions and Troubleshooters using [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) AND resourceUri or resourceType.<br/> Discovery Solutions is the initial entry point within Help API, which identifies relevant Azure diagnostics and solutions. <br/><br/> Required Input : problemClassificationId (Use the [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) <br/>Optional input: resourceUri OR resource Type <br/><br/> <b>Note: </b> ‘requiredInputs’ from Discovery solutions response must be passed via ‘additionalParameters’ as an input to Diagnostics and Solutions API. - /// 'ProblemClassificationId' is a mandatory filter to get solutions ids. It also supports optional 'ResourceType' and 'SolutionType' filters. The [$filter](https://learn.microsoft.com/en-us/odata/webapi/first-odata-api#filter) supports only 'and', 'or' and 'eq' operators. Example: $filter=ProblemClassificationId eq '1ddda5b4-cf6c-4d4f-91ad-bc38ab0e811e'. - /// Skiptoken is only used if a previous operation returned a partial result. - /// The cancellation token to use. - public async Task> DiscoverSolutionsAsync(string filter = null, string skiptoken = null, CancellationToken cancellationToken = default) - { - using var message = CreateDiscoverSolutionsRequest(filter, skiptoken); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SelfHelpDiscoverySolutionResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SelfHelpDiscoverySolutionResult.DeserializeSelfHelpDiscoverySolutionResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists the relevant Azure Diagnostics, Solutions and Troubleshooters using [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) AND resourceUri or resourceType.<br/> Discovery Solutions is the initial entry point within Help API, which identifies relevant Azure diagnostics and solutions. <br/><br/> Required Input : problemClassificationId (Use the [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) <br/>Optional input: resourceUri OR resource Type <br/><br/> <b>Note: </b> ‘requiredInputs’ from Discovery solutions response must be passed via ‘additionalParameters’ as an input to Diagnostics and Solutions API. - /// 'ProblemClassificationId' is a mandatory filter to get solutions ids. It also supports optional 'ResourceType' and 'SolutionType' filters. The [$filter](https://learn.microsoft.com/en-us/odata/webapi/first-odata-api#filter) supports only 'and', 'or' and 'eq' operators. Example: $filter=ProblemClassificationId eq '1ddda5b4-cf6c-4d4f-91ad-bc38ab0e811e'. - /// Skiptoken is only used if a previous operation returned a partial result. - /// The cancellation token to use. - public Response DiscoverSolutions(string filter = null, string skiptoken = null, CancellationToken cancellationToken = default) - { - using var message = CreateDiscoverSolutionsRequest(filter, skiptoken); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SelfHelpDiscoverySolutionResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SelfHelpDiscoverySolutionResult.DeserializeSelfHelpDiscoverySolutionResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDiscoverSolutionsNextPageRequestUri(string nextLink, string filter, string skiptoken) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateDiscoverSolutionsNextPageRequest(string nextLink, string filter, string skiptoken) + internal HttpMessage CreateNextDiscoverSolutionsRequest(Uri nextPage, string filter, string skiptoken, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - - /// Lists the relevant Azure Diagnostics, Solutions and Troubleshooters using [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) AND resourceUri or resourceType.<br/> Discovery Solutions is the initial entry point within Help API, which identifies relevant Azure diagnostics and solutions. <br/><br/> Required Input : problemClassificationId (Use the [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) <br/>Optional input: resourceUri OR resource Type <br/><br/> <b>Note: </b> ‘requiredInputs’ from Discovery solutions response must be passed via ‘additionalParameters’ as an input to Diagnostics and Solutions API. - /// The URL to the next page of results. - /// 'ProblemClassificationId' is a mandatory filter to get solutions ids. It also supports optional 'ResourceType' and 'SolutionType' filters. The [$filter](https://learn.microsoft.com/en-us/odata/webapi/first-odata-api#filter) supports only 'and', 'or' and 'eq' operators. Example: $filter=ProblemClassificationId eq '1ddda5b4-cf6c-4d4f-91ad-bc38ab0e811e'. - /// Skiptoken is only used if a previous operation returned a partial result. - /// The cancellation token to use. - /// is null. - public async Task> DiscoverSolutionsNextPageAsync(string nextLink, string filter = null, string skiptoken = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - - using var message = CreateDiscoverSolutionsNextPageRequest(nextLink, filter, skiptoken); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SelfHelpDiscoverySolutionResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SelfHelpDiscoverySolutionResult.DeserializeSelfHelpDiscoverySolutionResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists the relevant Azure Diagnostics, Solutions and Troubleshooters using [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) AND resourceUri or resourceType.<br/> Discovery Solutions is the initial entry point within Help API, which identifies relevant Azure diagnostics and solutions. <br/><br/> Required Input : problemClassificationId (Use the [problemClassification API](https://learn.microsoft.com/rest/api/support/problem-classifications/list?tabs=HTTP)) <br/>Optional input: resourceUri OR resource Type <br/><br/> <b>Note: </b> ‘requiredInputs’ from Discovery solutions response must be passed via ‘additionalParameters’ as an input to Diagnostics and Solutions API. - /// The URL to the next page of results. - /// 'ProblemClassificationId' is a mandatory filter to get solutions ids. It also supports optional 'ResourceType' and 'SolutionType' filters. The [$filter](https://learn.microsoft.com/en-us/odata/webapi/first-odata-api#filter) supports only 'and', 'or' and 'eq' operators. Example: $filter=ProblemClassificationId eq '1ddda5b4-cf6c-4d4f-91ad-bc38ab0e811e'. - /// Skiptoken is only used if a previous operation returned a partial result. - /// The cancellation token to use. - /// is null. - public Response DiscoverSolutionsNextPage(string nextLink, string filter = null, string skiptoken = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - - using var message = CreateDiscoverSolutionsNextPageRequest(nextLink, filter, skiptoken); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SelfHelpDiscoverySolutionResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SelfHelpDiscoverySolutionResult.DeserializeSelfHelpDiscoverySolutionResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SimplifiedSolutionsResourcesRestOperations.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SimplifiedSolutionsResourcesRestOperations.cs index 8dac7f1f2da8..04aa21e17873 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SimplifiedSolutionsResourcesRestOperations.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SimplifiedSolutionsResourcesRestOperations.cs @@ -6,205 +6,78 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; namespace Azure.ResourceManager.SelfHelp { - internal partial class SimplifiedSolutionsResourcesRestOperations + internal partial class SimplifiedSolutionsResources { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of SimplifiedSolutionsResourcesRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public SimplifiedSolutionsResourcesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of SimplifiedSolutionsResources for mocking. + protected SimplifiedSolutionsResources() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string scope, string simplifiedSolutionsResourceName) + /// Initializes a new instance of SimplifiedSolutionsResources. + /// 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 SimplifiedSolutionsResources(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/simplifiedSolutions/", false); - uri.AppendPath(simplifiedSolutionsResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRequest(string scope, string simplifiedSolutionsResourceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/simplifiedSolutions/", false); - uri.AppendPath(simplifiedSolutionsResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Simplified Solutions Resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string scope, string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - - using var message = CreateGetRequest(scope, simplifiedSolutionsResourceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SelfHelpSimplifiedSolutionData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SelfHelpSimplifiedSolutionData.DeserializeSelfHelpSimplifiedSolutionData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((SelfHelpSimplifiedSolutionData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Simplified Solutions Resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response Get(string scope, string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetRequest(string scope, string simplifiedSolutionsResourceName, RequestContext context) { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - - using var message = CreateGetRequest(scope, simplifiedSolutionsResourceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SelfHelpSimplifiedSolutionData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SelfHelpSimplifiedSolutionData.DeserializeSelfHelpSimplifiedSolutionData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((SelfHelpSimplifiedSolutionData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateRequestUri(string scope, string simplifiedSolutionsResourceName, SelfHelpSimplifiedSolutionData data) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); uri.AppendPath("/providers/Microsoft.Help/simplifiedSolutions/", false); uri.AppendPath(simplifiedSolutionsResourceName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + 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 CreateCreateRequest(string scope, string simplifiedSolutionsResourceName, SelfHelpSimplifiedSolutionData data) + internal HttpMessage CreateCreateRequest(string scope, string simplifiedSolutionsResourceName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); uri.AppendPath("/providers/Microsoft.Help/simplifiedSolutions/", false); uri.AppendPath(simplifiedSolutionsResourceName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); - request.Content = content; - _userAgent.Apply(message); - return message; - } - - /// Creates Simplified Solutions for an Azure subscription using 'solutionId' from Discovery Solutions as the input. <br/><br/> Simplified Solutions API makes the consumption of solutions APIs easier while still providing access to the same powerful solutions rendered in Solutions API. With Simplified Solutions, users don't have to worry about stitching together the article using replacement maps and can use the content in the API response to directly render as HTML content.<br/>. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Simplified Solutions Resource Name. - /// The required request body for simplified Solutions resource creation. - /// The cancellation token to use. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public async Task CreateAsync(string scope, string simplifiedSolutionsResourceName, SelfHelpSimplifiedSolutionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(scope, simplifiedSolutionsResourceName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Creates Simplified Solutions for an Azure subscription using 'solutionId' from Discovery Solutions as the input. <br/><br/> Simplified Solutions API makes the consumption of solutions APIs easier while still providing access to the same powerful solutions rendered in Solutions API. With Simplified Solutions, users don't have to worry about stitching together the article using replacement maps and can use the content in the API response to directly render as HTML content.<br/>. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Simplified Solutions Resource Name. - /// The required request body for simplified Solutions resource creation. - /// The cancellation token to use. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public Response Create(string scope, string simplifiedSolutionsResourceName, SelfHelpSimplifiedSolutionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(scope, simplifiedSolutionsResourceName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) + request.Method = RequestMethod.Put; + if ("application/json" != null) { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); + request.Headers.SetValue("Content-Type", "application/json"); } + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SolutionResourcesRestOperations.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SolutionResourcesRestOperations.cs index 31d19d7a4dee..c002613db4a6 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SolutionResourcesRestOperations.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SolutionResourcesRestOperations.cs @@ -6,311 +6,105 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp { - internal partial class SolutionResourcesRestOperations + internal partial class SolutionResources { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of SolutionResourcesRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public SolutionResourcesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of SolutionResources for mocking. + protected SolutionResources() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string scope, string solutionResourceName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/solutions/", false); - uri.AppendPath(solutionResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string scope, string solutionResourceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/solutions/", false); - uri.AppendPath(solutionResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get the solution using the applicable solutionResourceName while creating the solution. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Solution resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string scope, string solutionResourceName, CancellationToken cancellationToken = default) + /// Initializes a new instance of SolutionResources. + /// 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 SolutionResources(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - - using var message = CreateGetRequest(scope, solutionResourceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SelfHelpSolutionData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SelfHelpSolutionData.DeserializeSelfHelpSolutionData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((SelfHelpSolutionData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Get the solution using the applicable solutionResourceName while creating the solution. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Solution resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response Get(string scope, string solutionResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(scope, solutionResourceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SelfHelpSolutionData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SelfHelpSolutionData.DeserializeSelfHelpSolutionData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((SelfHelpSolutionData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - internal RequestUriBuilder CreateCreateRequestUri(string scope, string solutionResourceName, SelfHelpSolutionData data) + internal HttpMessage CreateGetRequest(string scope, string solutionResourceName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); uri.AppendPath("/providers/Microsoft.Help/solutions/", false); uri.AppendPath(solutionResourceName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + 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 CreateCreateRequest(string scope, string solutionResourceName, SelfHelpSolutionData data) + internal HttpMessage CreateCreateRequest(string scope, string solutionResourceName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); uri.AppendPath("/providers/Microsoft.Help/solutions/", false); uri.AppendPath(solutionResourceName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); - request.Content = content; - _userAgent.Apply(message); - return message; - } - - /// Creates a solution for the specific Azure resource or subscription using the inputs ‘solutionId and requiredInputs’ from discovery solutions. <br/> Azure solutions comprise a comprehensive library of self-help resources that have been thoughtfully curated by Azure engineers to aid customers in resolving typical troubleshooting issues. These solutions encompass: <br/> (1.) Dynamic and context-aware diagnostics, guided troubleshooting wizards, and data visualizations. <br/> (2.) Rich instructional video tutorials and illustrative diagrams and images. <br/> (3.) Thoughtfully assembled textual troubleshooting instructions. <br/> All these components are seamlessly converged into unified solutions tailored to address a specific support problem area. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Solution resource Name. - /// The required request body for this solution resource creation. - /// The cancellation token to use. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public async Task CreateAsync(string scope, string solutionResourceName, SelfHelpSolutionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(scope, solutionResourceName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Creates a solution for the specific Azure resource or subscription using the inputs ‘solutionId and requiredInputs’ from discovery solutions. <br/> Azure solutions comprise a comprehensive library of self-help resources that have been thoughtfully curated by Azure engineers to aid customers in resolving typical troubleshooting issues. These solutions encompass: <br/> (1.) Dynamic and context-aware diagnostics, guided troubleshooting wizards, and data visualizations. <br/> (2.) Rich instructional video tutorials and illustrative diagrams and images. <br/> (3.) Thoughtfully assembled textual troubleshooting instructions. <br/> All these components are seamlessly converged into unified solutions tailored to address a specific support problem area. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Solution resource Name. - /// The required request body for this solution resource creation. - /// The cancellation token to use. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public Response Create(string scope, string solutionResourceName, SelfHelpSolutionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(scope, solutionResourceName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) + request.Method = RequestMethod.Put; + if ("application/json" != null) { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); + request.Headers.SetValue("Content-Type", "application/json"); } + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; } - internal RequestUriBuilder CreateUpdateRequestUri(string scope, string solutionResourceName, SelfHelpSolutionPatch patch) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/solutions/", false); - uri.AppendPath(solutionResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string scope, string solutionResourceName, SelfHelpSolutionPatch patch) + internal HttpMessage CreateUpdateRequest(string scope, string solutionResourceName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Patch; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); uri.AppendPath("/providers/Microsoft.Help/solutions/", false); uri.AppendPath(solutionResourceName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); - request.Content = content; - _userAgent.Apply(message); - return message; - } - - /// Update the requiredInputs or additional information needed to execute the solution. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Solution resource Name. - /// The required request body for updating a solution resource. - /// The cancellation token to use. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public async Task UpdateAsync(string scope, string solutionResourceName, SelfHelpSolutionPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(scope, solutionResourceName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 202: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Update the requiredInputs or additional information needed to execute the solution. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Solution resource Name. - /// The required request body for updating a solution resource. - /// The cancellation token to use. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public Response Update(string scope, string solutionResourceName, SelfHelpSolutionPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(scope, solutionResourceName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) + request.Method = RequestMethod.Patch; + if ("application/json" != null) { - case 200: - case 202: - return message.Response; - default: - throw new RequestFailedException(message.Response); + request.Headers.SetValue("Content-Type", "application/json"); } + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; } - internal RequestUriBuilder CreateWarmUpRequestUri(string scope, string solutionResourceName, SolutionWarmUpContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/solutions/", false); - uri.AppendPath(solutionResourceName, true); - uri.AppendPath("/warmup", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateWarmUpRequest(string scope, string solutionResourceName, SolutionWarmUpContent content) + internal HttpMessage CreateWarmUpRequest(string scope, string solutionResourceName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); @@ -318,62 +112,16 @@ internal HttpMessage CreateWarmUpRequest(string scope, string solutionResourceNa uri.AppendPath(solutionResourceName, true); uri.AppendPath("/warmup", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - if (content != null) + request.Method = RequestMethod.Post; + if ("application/json" != null) { - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; + request.Headers.SetValue("Content-Type", "application/json"); } - _userAgent.Apply(message); + request.Content = content; return message; } - - /// Warm up the solution resource by preloading asynchronous diagnostics results into cache. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Solution resource Name. - /// The required request body for warming up a solution resource. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task WarmUpAsync(string scope, string solutionResourceName, SolutionWarmUpContent content = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - - using var message = CreateWarmUpRequest(scope, solutionResourceName, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Warm up the solution resource by preloading asynchronous diagnostics results into cache. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Solution resource Name. - /// The required request body for warming up a solution resource. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response WarmUp(string scope, string solutionResourceName, SolutionWarmUpContent content = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - - using var message = CreateWarmUpRequest(scope, solutionResourceName, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SolutionSelfHelpRestOperations.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SolutionSelfHelpRestOperations.cs index 7455231cca91..9a467635497e 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SolutionSelfHelpRestOperations.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/SolutionSelfHelpRestOperations.cs @@ -6,110 +6,54 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp { - internal partial class SolutionSelfHelpRestOperations + internal partial class SolutionSelfHelp { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of SolutionSelfHelpRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public SolutionSelfHelpRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of SolutionSelfHelp for mocking. + protected SolutionSelfHelp() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetSelfHelpSolutionByIdRequestUri(string solutionId) + /// Initializes a new instance of SolutionSelfHelp. + /// 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 SolutionSelfHelp(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Help/selfHelp/", false); - uri.AppendPath(solutionId, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetSelfHelpSolutionByIdRequest(string solutionId) + /// 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 CreateGetSelfHelpSolutionByIdRequest(string solutionId, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/providers/Microsoft.Help/selfHelp/", false); uri.AppendPath(solutionId, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - - /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. - /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> GetSelfHelpSolutionByIdAsync(string solutionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(solutionId, nameof(solutionId)); - - using var message = CreateGetSelfHelpSolutionByIdRequest(solutionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SelfHelpSolutionResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SelfHelpSolutionResult.DeserializeSelfHelpSolutionResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. - /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response GetSelfHelpSolutionById(string solutionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(solutionId, nameof(solutionId)); - - using var message = CreateGetSelfHelpSolutionByIdRequest(solutionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SelfHelpSolutionResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SelfHelpSolutionResult.DeserializeSelfHelpSolutionResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/TroubleshooterResourcesRestOperations.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/TroubleshooterResourcesRestOperations.cs index 98fc22bc86fe..dc4ce533a494 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/TroubleshooterResourcesRestOperations.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/RestOperations/TroubleshooterResourcesRestOperations.cs @@ -6,237 +6,83 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp { - internal partial class TroubleshooterResourcesRestOperations + internal partial class TroubleshooterResources { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of TroubleshooterResourcesRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public TroubleshooterResourcesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) - { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateGetRequestUri(string scope, string troubleshooterName) + /// Initializes a new instance of TroubleshooterResources for mocking. + protected TroubleshooterResources() { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/troubleshooters/", false); - uri.AppendPath(troubleshooterName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; } - internal HttpMessage CreateGetRequest(string scope, string troubleshooterName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/troubleshooters/", false); - uri.AppendPath(troubleshooterName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Troubleshooter resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string scope, string troubleshooterName, CancellationToken cancellationToken = default) + /// Initializes a new instance of TroubleshooterResources. + /// 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 TroubleshooterResources(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - - using var message = CreateGetRequest(scope, troubleshooterName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SelfHelpTroubleshooterData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SelfHelpTroubleshooterData.DeserializeSelfHelpTroubleshooterData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((SelfHelpTroubleshooterData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Troubleshooter resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response Get(string scope, string troubleshooterName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(scope, troubleshooterName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SelfHelpTroubleshooterData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SelfHelpTroubleshooterData.DeserializeSelfHelpTroubleshooterData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((SelfHelpTroubleshooterData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - internal RequestUriBuilder CreateCreateRequestUri(string scope, string troubleshooterName, SelfHelpTroubleshooterData data) + internal HttpMessage CreateGetRequest(string scope, string troubleshooterName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); uri.AppendPath("/providers/Microsoft.Help/troubleshooters/", false); uri.AppendPath(troubleshooterName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + 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 CreateCreateRequest(string scope, string troubleshooterName, SelfHelpTroubleshooterData data) + internal HttpMessage CreateCreateRequest(string scope, string troubleshooterName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); uri.AppendPath("/providers/Microsoft.Help/troubleshooters/", false); uri.AppendPath(troubleshooterName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); - request.Content = content; - _userAgent.Apply(message); - return message; - } - - /// Creates the specific troubleshooter action under a resource or subscription using the ‘solutionId’ and ‘properties.parameters’ as the trigger. <br/> Azure Troubleshooters help with hard to classify issues, reducing the gap between customer observed problems and solutions by guiding the user effortlessly through the troubleshooting process. Each Troubleshooter flow represents a problem area within Azure and has a complex tree-like structure that addresses many root causes. These flows are prepared with the help of Subject Matter experts and customer support engineers by carefully considering previous support requests raised by customers. Troubleshooters terminate at a well curated solution based off of resource backend signals and customer manual selections. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Troubleshooter resource Name. - /// The required request body for this Troubleshooter resource creation. - /// The cancellation token to use. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> CreateAsync(string scope, string troubleshooterName, SelfHelpTroubleshooterData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(scope, troubleshooterName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - { - SelfHelpTroubleshooterData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SelfHelpTroubleshooterData.DeserializeSelfHelpTroubleshooterData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Creates the specific troubleshooter action under a resource or subscription using the ‘solutionId’ and ‘properties.parameters’ as the trigger. <br/> Azure Troubleshooters help with hard to classify issues, reducing the gap between customer observed problems and solutions by guiding the user effortlessly through the troubleshooting process. Each Troubleshooter flow represents a problem area within Azure and has a complex tree-like structure that addresses many root causes. These flows are prepared with the help of Subject Matter experts and customer support engineers by carefully considering previous support requests raised by customers. Troubleshooters terminate at a well curated solution based off of resource backend signals and customer manual selections. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Troubleshooter resource Name. - /// The required request body for this Troubleshooter resource creation. - /// The cancellation token to use. - /// , or is null. - /// is an empty string, and was expected to be non-empty. - public Response Create(string scope, string troubleshooterName, SelfHelpTroubleshooterData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(scope, troubleshooterName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) + request.Method = RequestMethod.Put; + if ("application/json" != null) { - case 200: - case 201: - { - SelfHelpTroubleshooterData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SelfHelpTroubleshooterData.DeserializeSelfHelpTroubleshooterData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); + request.Headers.SetValue("Content-Type", "application/json"); } + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; } - internal RequestUriBuilder CreateContinueRequestUri(string scope, string troubleshooterName, TroubleshooterContinueContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/troubleshooters/", false); - uri.AppendPath(troubleshooterName, true); - uri.AppendPath("/continue", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateContinueRequest(string scope, string troubleshooterName, TroubleshooterContinueContent content) + internal HttpMessage CreateContinueRequest(string scope, string troubleshooterName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); @@ -244,83 +90,21 @@ internal HttpMessage CreateContinueRequest(string scope, string troubleshooterNa uri.AppendPath(troubleshooterName, true); uri.AppendPath("/continue", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - if (content != null) + request.Method = RequestMethod.Post; + if ("application/json" != null) { - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; + request.Headers.SetValue("Content-Type", "application/json"); } - _userAgent.Apply(message); + request.Content = content; return message; } - /// Uses ‘stepId’ and ‘responses’ as the trigger to continue the troubleshooting steps for the respective troubleshooter resource name. <br/>Continue API is used to provide inputs that are required for the specific troubleshooter to progress into the next step in the process. This API is used after the Troubleshooter has been created using the Create API. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Troubleshooter resource Name. - /// The required request body for going to next step in Troubleshooter resource. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task ContinueAsync(string scope, string troubleshooterName, TroubleshooterContinueContent content = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - - using var message = CreateContinueRequest(scope, troubleshooterName, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Uses ‘stepId’ and ‘responses’ as the trigger to continue the troubleshooting steps for the respective troubleshooter resource name. <br/>Continue API is used to provide inputs that are required for the specific troubleshooter to progress into the next step in the process. This API is used after the Troubleshooter has been created using the Create API. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Troubleshooter resource Name. - /// The required request body for going to next step in Troubleshooter resource. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response Continue(string scope, string troubleshooterName, TroubleshooterContinueContent content = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - - using var message = CreateContinueRequest(scope, troubleshooterName, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateEndRequestUri(string scope, string troubleshooterName) + internal HttpMessage CreateEndRequest(string scope, string troubleshooterName, RequestContext context) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/troubleshooters/", false); - uri.AppendPath(troubleshooterName, true); - uri.AppendPath("/end", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateEndRequest(string scope, string troubleshooterName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); @@ -328,74 +112,16 @@ internal HttpMessage CreateEndRequest(string scope, string troubleshooterName) uri.AppendPath(troubleshooterName, true); uri.AppendPath("/end", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Post; return message; } - /// Ends the troubleshooter action. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Troubleshooter resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task EndAsync(string scope, string troubleshooterName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - - using var message = CreateEndRequest(scope, troubleshooterName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Ends the troubleshooter action. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Troubleshooter resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response End(string scope, string troubleshooterName, CancellationToken cancellationToken = default) + internal HttpMessage CreateRestartRequest(string scope, string troubleshooterName, RequestContext context) { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - - using var message = CreateEndRequest(scope, troubleshooterName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateRestartRequestUri(string scope, string troubleshooterName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/", false); - uri.AppendPath(scope, false); - uri.AppendPath("/providers/Microsoft.Help/troubleshooters/", false); - uri.AppendPath(troubleshooterName, true); - uri.AppendPath("/restart", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateRestartRequest(string scope, string troubleshooterName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/", false); uri.AppendPath(scope, false); @@ -403,64 +129,12 @@ internal HttpMessage CreateRestartRequest(string scope, string troubleshooterNam uri.AppendPath(troubleshooterName, true); uri.AppendPath("/restart", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); return message; } - - /// Restarts the troubleshooter API using applicable troubleshooter resource name as the input.<br/> It returns new resource name which should be used in subsequent request. The old resource name is obsolete after this API is invoked. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Troubleshooter resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> RestartAsync(string scope, string troubleshooterName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - - using var message = CreateRestartRequest(scope, troubleshooterName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - RestartTroubleshooterResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = RestartTroubleshooterResult.DeserializeRestartTroubleshooterResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Restarts the troubleshooter API using applicable troubleshooter resource name as the input.<br/> It returns new resource name which should be used in subsequent request. The old resource name is obsolete after this API is invoked. - /// The fully qualified Azure Resource manager identifier of the resource. - /// Troubleshooter resource Name. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response Restart(string scope, string troubleshooterName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(scope, nameof(scope)); - Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - - using var message = CreateRestartRequest(scope, troubleshooterName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - RestartTroubleshooterResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = RestartTroubleshooterResult.DeserializeRestartTroubleshooterResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticCollection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticCollection.cs index 88fae3be9eca..8d1ccf52b47f 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticCollection.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticCollection.cs @@ -8,8 +8,10 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.SelfHelp { @@ -20,42 +22,38 @@ namespace Azure.ResourceManager.SelfHelp /// public partial class SelfHelpDiagnosticCollection : ArmCollection { - private readonly ClientDiagnostics _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics; - private readonly DiagnosticResourcesRestOperations _selfHelpDiagnosticDiagnosticResourcesRestClient; + private readonly ClientDiagnostics _diagnosticResourcesClientDiagnostics; + private readonly DiagnosticResources _diagnosticResourcesRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of SelfHelpDiagnosticCollection for mocking. protected SelfHelpDiagnosticCollection() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. + /// The identifier of the resource that is the target of operations. internal SelfHelpDiagnosticCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", SelfHelpDiagnosticResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(SelfHelpDiagnosticResource.ResourceType, out string selfHelpDiagnosticDiagnosticResourcesApiVersion); - _selfHelpDiagnosticDiagnosticResourcesRestClient = new DiagnosticResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, selfHelpDiagnosticDiagnosticResourcesApiVersion); + TryGetApiVersion(SelfHelpDiagnosticResource.ResourceType, out string selfHelpDiagnosticApiVersion); + _diagnosticResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", SelfHelpDiagnosticResource.ResourceType.Namespace, Diagnostics); + _diagnosticResourcesRestClient = new DiagnosticResources(_diagnosticResourcesClientDiagnostics, Pipeline, Endpoint, selfHelpDiagnosticApiVersion ?? "2024-03-01-preview"); } /// /// Creates a diagnostic for the specific resource using solutionId from discovery solutions. <br/>Diagnostics are powerful solutions that access product resources or other relevant data and provide the root cause of the issue and the steps to address the issue.<br/><br/> /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Operation Id - /// DiagnosticResource_Create + /// Operation Id. + /// DiagnosticResources_Create. /// /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// @@ -63,21 +61,33 @@ internal SelfHelpDiagnosticCollection(ArmClient client, ResourceIdentifier id) : /// Unique resource name for insight resources. /// The required request body for this insightResource invocation. /// The cancellation token to use. + /// is null. /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string diagnosticsResourceName, SelfHelpDiagnosticData data, CancellationToken cancellationToken = default) + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string diagnosticsResourceName, SelfHelpDiagnosticData data = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - Argument.AssertNotNull(data, nameof(data)); - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.CreateOrUpdate"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _selfHelpDiagnosticDiagnosticResourcesRestClient.CreateAsync(Id, diagnosticsResourceName, data, cancellationToken).ConfigureAwait(false); - var operation = new SelfHelpArmOperation(new SelfHelpDiagnosticOperationSource(Client), _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics, Pipeline, _selfHelpDiagnosticDiagnosticResourcesRestClient.CreateCreateRequest(Id, diagnosticsResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateCreateRequest(Id, diagnosticsResourceName, SelfHelpDiagnosticData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpDiagnosticOperationSource(Client), + _diagnosticResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -91,20 +101,16 @@ public virtual async Task> CreateOrUpda /// Creates a diagnostic for the specific resource using solutionId from discovery solutions. <br/>Diagnostics are powerful solutions that access product resources or other relevant data and provide the root cause of the issue and the steps to address the issue.<br/><br/> /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} - /// - /// - /// Operation Id - /// DiagnosticResource_Create + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// DiagnosticResources_Create. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// @@ -112,21 +118,33 @@ public virtual async Task> CreateOrUpda /// Unique resource name for insight resources. /// The required request body for this insightResource invocation. /// The cancellation token to use. + /// is null. /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string diagnosticsResourceName, SelfHelpDiagnosticData data, CancellationToken cancellationToken = default) + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string diagnosticsResourceName, SelfHelpDiagnosticData data = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - Argument.AssertNotNull(data, nameof(data)); - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.CreateOrUpdate"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.CreateOrUpdate"); scope.Start(); try { - var response = _selfHelpDiagnosticDiagnosticResourcesRestClient.Create(Id, diagnosticsResourceName, data, cancellationToken); - var operation = new SelfHelpArmOperation(new SelfHelpDiagnosticOperationSource(Client), _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics, Pipeline, _selfHelpDiagnosticDiagnosticResourcesRestClient.CreateCreateRequest(Id, diagnosticsResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateCreateRequest(Id, diagnosticsResourceName, SelfHelpDiagnosticData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpDiagnosticOperationSource(Client), + _diagnosticResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -140,38 +158,42 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} - /// - /// - /// Operation Id - /// DiagnosticResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// DiagnosticResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Unique resource name for insight resources. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetAsync(string diagnosticsResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.Get"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.Get"); scope.Start(); try { - var response = await _selfHelpDiagnosticDiagnosticResourcesRestClient.GetAsync(Id, diagnosticsResourceName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateGetRequest(Id, diagnosticsResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpDiagnosticData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpDiagnosticResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -185,38 +207,42 @@ public virtual async Task> GetAsync(string /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} - /// - /// - /// Operation Id - /// DiagnosticResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// DiagnosticResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Unique resource name for insight resources. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Get(string diagnosticsResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.Get"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.Get"); scope.Start(); try { - var response = _selfHelpDiagnosticDiagnosticResourcesRestClient.Get(Id, diagnosticsResourceName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateGetRequest(Id, diagnosticsResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpDiagnosticData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpDiagnosticResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -227,39 +253,53 @@ public virtual Response Get(string diagnosticsResour } /// - /// Checks to see if the resource exists in azure. + /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} - /// - /// - /// Operation Id - /// DiagnosticResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// DiagnosticResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Unique resource name for insight resources. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> ExistsAsync(string diagnosticsResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.Exists"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.Exists"); scope.Start(); try { - var response = await _selfHelpDiagnosticDiagnosticResourcesRestClient.GetAsync(Id, diagnosticsResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateGetRequest(Id, diagnosticsResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpDiagnosticData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpDiagnosticData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -270,39 +310,53 @@ public virtual async Task> ExistsAsync(string diagnosticsResource } /// - /// Checks to see if the resource exists in azure. + /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} - /// - /// - /// Operation Id - /// DiagnosticResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// DiagnosticResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Unique resource name for insight resources. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Exists(string diagnosticsResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.Exists"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.Exists"); scope.Start(); try { - var response = _selfHelpDiagnosticDiagnosticResourcesRestClient.Get(Id, diagnosticsResourceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateGetRequest(Id, diagnosticsResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpDiagnosticData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpDiagnosticData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -313,41 +367,57 @@ public virtual Response Exists(string diagnosticsResourceName, Cancellatio } /// - /// Tries to get details for this resource from the service. + /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Operation Id - /// DiagnosticResource_Get + /// Operation Id. + /// DiagnosticResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Unique resource name for insight resources. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetIfExistsAsync(string diagnosticsResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.GetIfExists"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.GetIfExists"); scope.Start(); try { - var response = await _selfHelpDiagnosticDiagnosticResourcesRestClient.GetAsync(Id, diagnosticsResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateGetRequest(Id, diagnosticsResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpDiagnosticData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpDiagnosticData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpDiagnosticResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -358,41 +428,57 @@ public virtual async Task> GetIfExi } /// - /// Tries to get details for this resource from the service. + /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Operation Id - /// DiagnosticResource_Get + /// Operation Id. + /// DiagnosticResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Unique resource name for insight resources. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual NullableResponse GetIfExists(string diagnosticsResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(diagnosticsResourceName, nameof(diagnosticsResourceName)); - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.GetIfExists"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticCollection.GetIfExists"); scope.Start(); try { - var response = _selfHelpDiagnosticDiagnosticResourcesRestClient.Get(Id, diagnosticsResourceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateGetRequest(Id, diagnosticsResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpDiagnosticData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpDiagnosticData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpDiagnosticResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticData.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticData.Serialization.cs index a9e661091030..5c81f7e79bc5 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticData.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticData.Serialization.cs @@ -10,16 +10,18 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Models; using Azure.ResourceManager.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp { - public partial class SelfHelpDiagnosticData : IUtf8JsonSerializable, IJsonModel + /// Diagnostic resource. + public partial class SelfHelpDiagnosticData : ResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,211 +33,114 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpDiagnosticData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(GlobalParameters)) - { - writer.WritePropertyName("globalParameters"u8); - writer.WriteStartObject(); - foreach (var item in GlobalParameters) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - if (Optional.IsCollectionDefined(Insights)) - { - writer.WritePropertyName("insights"u8); - writer.WriteStartArray(); - foreach (var item in Insights) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (options.Format != "W" && Optional.IsDefined(AcceptedOn)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("acceptedAt"u8); - writer.WriteStringValue(AcceptedOn.Value, "O"); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) - { - writer.WritePropertyName("provisioningState"u8); - writer.WriteStringValue(ProvisioningState.Value.ToString()); - } - if (options.Format != "W" && Optional.IsCollectionDefined(Diagnostics)) - { - writer.WritePropertyName("diagnostics"u8); - writer.WriteStartArray(); - foreach (var item in Diagnostics) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - writer.WriteEndObject(); } - SelfHelpDiagnosticData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpDiagnosticData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SelfHelpDiagnosticData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpDiagnosticData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpDiagnosticData(document.RootElement, options); } - internal static SelfHelpDiagnosticData DeserializeSelfHelpDiagnosticData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpDiagnosticData DeserializeSelfHelpDiagnosticData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - IDictionary globalParameters = default; - IList insights = default; - DateTimeOffset? acceptedAt = default; - SelfHelpProvisioningState? provisioningState = default; - IReadOnlyList diagnostics = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + SelfHelpDiagnosticResourceProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("globalParameters"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property1 in property0.Value.EnumerateObject()) - { - dictionary.Add(property1.Name, property1.Value.GetString()); - } - globalParameters = dictionary; - continue; - } - if (property0.NameEquals("insights"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(SelfHelpDiagnosticInvocation.DeserializeSelfHelpDiagnosticInvocation(item, options)); - } - insights = array; - continue; - } - if (property0.NameEquals("acceptedAt"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - acceptedAt = property0.Value.GetDateTimeOffset("O"); - continue; - } - if (property0.NameEquals("provisioningState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new SelfHelpProvisioningState(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("diagnostics"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(SelfHelpDiagnosticInfo.DeserializeSelfHelpDiagnosticInfo(item, options)); - } - diagnostics = array; - continue; - } - } + properties = SelfHelpDiagnosticResourceProperties.DeserializeSelfHelpDiagnosticResourceProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new SelfHelpDiagnosticData( id, name, - type, + resourceType, systemData, - globalParameters ?? new ChangeTrackingDictionary(), - insights ?? new ChangeTrackingList(), - acceptedAt, - provisioningState, - diagnostics ?? new ChangeTrackingList(), - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -245,15 +150,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - SelfHelpDiagnosticData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpDiagnosticData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SelfHelpDiagnosticData)PersistableModelCreateCore(data, options); + /// 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpDiagnosticData(document.RootElement, options); } default: @@ -261,6 +171,26 @@ SelfHelpDiagnosticData IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(SelfHelpDiagnosticData selfHelpDiagnosticData) + { + if (selfHelpDiagnosticData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(selfHelpDiagnosticData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static SelfHelpDiagnosticData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSelfHelpDiagnosticData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticData.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticData.cs index 217608b36a3c..3d5f9f70ba6c 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticData.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticData.cs @@ -13,82 +13,88 @@ namespace Azure.ResourceManager.SelfHelp { - /// - /// A class representing the SelfHelpDiagnostic data model. - /// Diagnostic resource - /// + /// Diagnostic resource. public partial class SelfHelpDiagnosticData : ResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public SelfHelpDiagnosticData() { - GlobalParameters = new ChangeTrackingDictionary(); - Insights = new ChangeTrackingList(); - Diagnostics = new ChangeTrackingList(); } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// Global parameters is an optional map which can be used to add key and value to request body to improve the diagnostics results. - /// SolutionIds that are needed to be invoked. - /// Diagnostic Request Accepted time. - /// Status of diagnostic provisioning. - /// Array of Diagnostics. - /// Keeps track of any properties unknown to the library. - internal SelfHelpDiagnosticData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary globalParameters, IList insights, DateTimeOffset? acceptedOn, SelfHelpProvisioningState? provisioningState, IReadOnlyList diagnostics, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + /// 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. + /// Diagnostic Resource properties. + internal SelfHelpDiagnosticData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, SelfHelpDiagnosticResourceProperties properties) : base(id, name, resourceType, systemData) { - GlobalParameters = globalParameters; - Insights = insights; - AcceptedOn = acceptedOn; - ProvisioningState = provisioningState; - Diagnostics = diagnostics; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } + /// Diagnostic Resource properties. + internal SelfHelpDiagnosticResourceProperties Properties { get; set; } + /// Global parameters is an optional map which can be used to add key and value to request body to improve the diagnostics results. - public IDictionary GlobalParameters { get; } + public IDictionary GlobalParameters + { + get + { + if (Properties is null) + { + Properties = new SelfHelpDiagnosticResourceProperties(); + } + return Properties.GlobalParameters; + } + } + /// SolutionIds that are needed to be invoked. - public IList Insights { get; } + public IList Insights + { + get + { + if (Properties is null) + { + Properties = new SelfHelpDiagnosticResourceProperties(); + } + return Properties.Insights; + } + } + /// Diagnostic Request Accepted time. - public DateTimeOffset? AcceptedOn { get; } + public DateTimeOffset? AcceptedOn + { + get + { + return Properties is null ? default : Properties.AcceptedOn; + } + } + /// Status of diagnostic provisioning. - public SelfHelpProvisioningState? ProvisioningState { get; } + public SelfHelpProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + /// Array of Diagnostics. - public IReadOnlyList Diagnostics { get; } + public IReadOnlyList Diagnostics + { + get + { + if (Properties is null) + { + Properties = new SelfHelpDiagnosticResourceProperties(); + } + return Properties.Diagnostics; + } + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticResource.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticResource.Serialization.cs index c785a62c113d..88b0d02a3434 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticResource.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.SelfHelp { + /// public partial class SelfHelpDiagnosticResource : IJsonModel { - private static SelfHelpDiagnosticData s_dataDeserializationInstance; - private static SelfHelpDiagnosticData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new SelfHelpDiagnosticData(); + + /// 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); - SelfHelpDiagnosticData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + SelfHelpDiagnosticData 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, AzureResourceManagerSelfHelpContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. SelfHelpDiagnosticData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerSelfHelpContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticResource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticResource.cs index 255e004ca0c9..02c968aafb2c 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticResource.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpDiagnosticResource.cs @@ -6,44 +6,35 @@ #nullable disable using System; -using System.Globalization; +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.SelfHelp { /// - /// A Class representing a SelfHelpDiagnostic 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 GetSelfHelpDiagnosticResource method. - /// Otherwise you can get one from its parent resource using the GetSelfHelpDiagnostic method. + /// A class representing a SelfHelpDiagnostic 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 GetSelfHelpDiagnostics method. /// public partial class SelfHelpDiagnosticResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The scope. - /// The diagnosticsResourceName. - public static ResourceIdentifier CreateResourceIdentifier(string scope, string diagnosticsResourceName) - { - var resourceId = $"{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics; - private readonly DiagnosticResourcesRestOperations _selfHelpDiagnosticDiagnosticResourcesRestClient; + private readonly ClientDiagnostics _diagnosticResourcesClientDiagnostics; + private readonly DiagnosticResources _diagnosticResourcesRestClient; private readonly SelfHelpDiagnosticData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Help/diagnostics"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of SelfHelpDiagnosticResource for mocking. protected SelfHelpDiagnosticResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal SelfHelpDiagnosticResource(ArmClient client, SelfHelpDiagnosticData data) : this(client, data.Id) @@ -52,71 +43,91 @@ internal SelfHelpDiagnosticResource(ArmClient client, SelfHelpDiagnosticData dat _data = data; } - /// Initializes a new instance of the class. + /// 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 SelfHelpDiagnosticResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string selfHelpDiagnosticDiagnosticResourcesApiVersion); - _selfHelpDiagnosticDiagnosticResourcesRestClient = new DiagnosticResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, selfHelpDiagnosticDiagnosticResourcesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string selfHelpDiagnosticApiVersion); + _diagnosticResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ResourceType.Namespace, Diagnostics); + _diagnosticResourcesRestClient = new DiagnosticResources(_diagnosticResourcesClientDiagnostics, Pipeline, Endpoint, selfHelpDiagnosticApiVersion ?? "2024-03-01-preview"); + ValidateResourceId(id); } /// Gets whether or not the current instance has data. public virtual bool HasData { get; } /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. public virtual SelfHelpDiagnosticData 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 scope. + /// The diagnosticsResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string scope, string diagnosticsResourceName) + { + string resourceId = $"{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Operation Id - /// DiagnosticResource_Get + /// Operation Id. + /// DiagnosticResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticResource.Get"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticResource.Get"); scope.Start(); try { - var response = await _selfHelpDiagnosticDiagnosticResourcesRestClient.GetAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateGetRequest(Id.Parent, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpDiagnosticData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpDiagnosticResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -130,33 +141,41 @@ public virtual async Task> GetAsync(Cancell /// Get the diagnostics using the 'diagnosticsResourceName' you chose while creating the diagnostic. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Operation Id - /// DiagnosticResource_Get + /// Operation Id. + /// DiagnosticResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticResource.Get"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticResource.Get"); scope.Start(); try { - var response = _selfHelpDiagnosticDiagnosticResourcesRestClient.Get(Id.Parent, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateGetRequest(Id.Parent, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpDiagnosticData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpDiagnosticResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -170,39 +189,49 @@ public virtual Response Get(CancellationToken cancel /// Creates a diagnostic for the specific resource using solutionId from discovery solutions. <br/>Diagnostics are powerful solutions that access product resources or other relevant data and provide the root cause of the issue and the steps to address the issue.<br/><br/> /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Operation Id - /// DiagnosticResource_Create + /// Operation Id. + /// DiagnosticResources_Create. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// 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 required request body for this insightResource invocation. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, SelfHelpDiagnosticData data, CancellationToken cancellationToken = default) + public virtual async Task> UpdateAsync(WaitUntil waitUntil, SelfHelpDiagnosticData data = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticResource.Update"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticResource.Update"); scope.Start(); try { - var response = await _selfHelpDiagnosticDiagnosticResourcesRestClient.CreateAsync(Id.Parent, Id.Name, data, cancellationToken).ConfigureAwait(false); - var operation = new SelfHelpArmOperation(new SelfHelpDiagnosticOperationSource(Client), _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics, Pipeline, _selfHelpDiagnosticDiagnosticResourcesRestClient.CreateCreateRequest(Id.Parent, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateCreateRequest(Id.Parent, Id.Name, SelfHelpDiagnosticData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpDiagnosticOperationSource(Client), + _diagnosticResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -216,39 +245,49 @@ public virtual async Task> UpdateAsync( /// Creates a diagnostic for the specific resource using solutionId from discovery solutions. <br/>Diagnostics are powerful solutions that access product resources or other relevant data and provide the root cause of the issue and the steps to address the issue.<br/><br/> /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/diagnostics/{diagnosticsResourceName}. /// /// - /// Operation Id - /// DiagnosticResource_Create + /// Operation Id. + /// DiagnosticResources_Create. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// 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 required request body for this insightResource invocation. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, SelfHelpDiagnosticData data, CancellationToken cancellationToken = default) + public virtual ArmOperation Update(WaitUntil waitUntil, SelfHelpDiagnosticData data = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticResource.Update"); + using DiagnosticScope scope = _diagnosticResourcesClientDiagnostics.CreateScope("SelfHelpDiagnosticResource.Update"); scope.Start(); try { - var response = _selfHelpDiagnosticDiagnosticResourcesRestClient.Create(Id.Parent, Id.Name, data, cancellationToken); - var operation = new SelfHelpArmOperation(new SelfHelpDiagnosticOperationSource(Client), _selfHelpDiagnosticDiagnosticResourcesClientDiagnostics, Pipeline, _selfHelpDiagnosticDiagnosticResourcesRestClient.CreateCreateRequest(Id.Parent, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _diagnosticResourcesRestClient.CreateCreateRequest(Id.Parent, Id.Name, SelfHelpDiagnosticData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpDiagnosticOperationSource(Client), + _diagnosticResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionCollection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionCollection.cs deleted file mode 100644 index 52c9c51e3762..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionCollection.cs +++ /dev/null @@ -1,405 +0,0 @@ -// 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.Core; -using Azure.Core.Pipeline; - -namespace Azure.ResourceManager.SelfHelp -{ - /// - /// 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 GetSelfHelpSimplifiedSolutions method from an instance of . - /// - public partial class SelfHelpSimplifiedSolutionCollection : ArmCollection - { - private readonly ClientDiagnostics _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics; - private readonly SimplifiedSolutionsResourcesRestOperations _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient; - - /// Initializes a new instance of the class for mocking. - protected SelfHelpSimplifiedSolutionCollection() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. - internal SelfHelpSimplifiedSolutionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", SelfHelpSimplifiedSolutionResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(SelfHelpSimplifiedSolutionResource.ResourceType, out string selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesApiVersion); - _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient = new SimplifiedSolutionsResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesApiVersion); - } - - /// - /// Creates Simplified Solutions for an Azure subscription using 'solutionId' from Discovery Solutions as the input. <br/><br/> Simplified Solutions API makes the consumption of solutions APIs easier while still providing access to the same powerful solutions rendered in Solutions API. With Simplified Solutions, users don't have to worry about stitching together the article using replacement maps and can use the content in the API response to directly render as HTML content.<br/> - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Create - /// - /// - /// Default Api Version - /// 2024-03-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. - /// Simplified Solutions Resource Name. - /// The required request body for simplified Solutions resource creation. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string simplifiedSolutionsResourceName, SelfHelpSimplifiedSolutionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = await _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.CreateAsync(Id, simplifiedSolutionsResourceName, data, cancellationToken).ConfigureAwait(false); - var operation = new SelfHelpArmOperation(new SelfHelpSimplifiedSolutionOperationSource(Client), _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics, Pipeline, _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.CreateCreateRequest(Id, simplifiedSolutionsResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Creates Simplified Solutions for an Azure subscription using 'solutionId' from Discovery Solutions as the input. <br/><br/> Simplified Solutions API makes the consumption of solutions APIs easier while still providing access to the same powerful solutions rendered in Solutions API. With Simplified Solutions, users don't have to worry about stitching together the article using replacement maps and can use the content in the API response to directly render as HTML content.<br/> - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Create - /// - /// - /// Default Api Version - /// 2024-03-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. - /// Simplified Solutions Resource Name. - /// The required request body for simplified Solutions resource creation. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string simplifiedSolutionsResourceName, SelfHelpSimplifiedSolutionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.Create(Id, simplifiedSolutionsResourceName, data, cancellationToken); - var operation = new SelfHelpArmOperation(new SelfHelpSimplifiedSolutionOperationSource(Client), _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics, Pipeline, _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.CreateCreateRequest(Id, simplifiedSolutionsResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Simplified Solutions Resource Name. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetAsync(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionCollection.Get"); - scope.Start(); - try - { - var response = await _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.GetAsync(Id, simplifiedSolutionsResourceName, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new SelfHelpSimplifiedSolutionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Simplified Solutions Resource Name. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Get(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionCollection.Get"); - scope.Start(); - try - { - var response = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.Get(Id, simplifiedSolutionsResourceName, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new SelfHelpSimplifiedSolutionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Simplified Solutions Resource Name. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> ExistsAsync(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionCollection.Exists"); - scope.Start(); - try - { - var response = await _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.GetAsync(Id, simplifiedSolutionsResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); - 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 - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Simplified Solutions Resource Name. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Exists(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionCollection.Exists"); - scope.Start(); - try - { - var response = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.Get(Id, simplifiedSolutionsResourceName, cancellationToken: cancellationToken); - 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 - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Simplified Solutions Resource Name. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetIfExistsAsync(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionCollection.GetIfExists"); - scope.Start(); - try - { - var response = await _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.GetAsync(Id, simplifiedSolutionsResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new SelfHelpSimplifiedSolutionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Simplified Solutions Resource Name. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual NullableResponse GetIfExists(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); - - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionCollection.GetIfExists"); - scope.Start(); - try - { - var response = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.Get(Id, simplifiedSolutionsResourceName, cancellationToken: cancellationToken); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new SelfHelpSimplifiedSolutionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionData.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionData.Serialization.cs deleted file mode 100644 index 46b80555ada7..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionData.Serialization.cs +++ /dev/null @@ -1,261 +0,0 @@ -// 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.Models; -using Azure.ResourceManager.SelfHelp.Models; - -namespace Azure.ResourceManager.SelfHelp -{ - public partial class SelfHelpSimplifiedSolutionData : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SelfHelpSimplifiedSolutionData)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(SolutionId)) - { - writer.WritePropertyName("solutionId"u8); - writer.WriteStringValue(SolutionId); - } - if (Optional.IsCollectionDefined(Parameters)) - { - writer.WritePropertyName("parameters"u8); - writer.WriteStartObject(); - foreach (var item in Parameters) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - if (options.Format != "W" && Optional.IsDefined(Title)) - { - writer.WritePropertyName("title"u8); - writer.WriteStringValue(Title); - } - if (options.Format != "W" && Optional.IsCollectionDefined(Appendix)) - { - writer.WritePropertyName("appendix"u8); - writer.WriteStartObject(); - foreach (var item in Appendix) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - if (options.Format != "W" && Optional.IsDefined(Content)) - { - writer.WritePropertyName("content"u8); - writer.WriteStringValue(Content); - } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) - { - writer.WritePropertyName("provisioningState"u8); - writer.WriteStringValue(ProvisioningState.Value.ToString()); - } - writer.WriteEndObject(); - } - - SelfHelpSimplifiedSolutionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SelfHelpSimplifiedSolutionData)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSelfHelpSimplifiedSolutionData(document.RootElement, options); - } - - internal static SelfHelpSimplifiedSolutionData DeserializeSelfHelpSimplifiedSolutionData(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ResourceIdentifier id = default; - string name = default; - ResourceType type = default; - SystemData systemData = default; - string solutionId = default; - IDictionary parameters = default; - string title = default; - IReadOnlyDictionary appendix = default; - string content = default; - SolutionProvisioningState? provisioningState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new ResourceType(property.Value.GetString()); - continue; - } - if (property.NameEquals("systemData"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); - continue; - } - if (property.NameEquals("properties"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - property.ThrowNonNullablePropertyIsNull(); - continue; - } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("solutionId"u8)) - { - solutionId = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("parameters"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property1 in property0.Value.EnumerateObject()) - { - dictionary.Add(property1.Name, property1.Value.GetString()); - } - parameters = dictionary; - continue; - } - if (property0.NameEquals("title"u8)) - { - title = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("appendix"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property1 in property0.Value.EnumerateObject()) - { - dictionary.Add(property1.Name, property1.Value.GetString()); - } - appendix = dictionary; - continue; - } - if (property0.NameEquals("content"u8)) - { - content = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("provisioningState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new SolutionProvisioningState(property0.Value.GetString()); - continue; - } - } - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new SelfHelpSimplifiedSolutionData( - id, - name, - type, - systemData, - solutionId, - parameters ?? new ChangeTrackingDictionary(), - title, - appendix ?? new ChangeTrackingDictionary(), - content, - provisioningState, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerSelfHelpContext.Default); - default: - throw new FormatException($"The model {nameof(SelfHelpSimplifiedSolutionData)} does not support writing '{options.Format}' format."); - } - } - - SelfHelpSimplifiedSolutionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeSelfHelpSimplifiedSolutionData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SelfHelpSimplifiedSolutionData)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionData.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionData.cs deleted file mode 100644 index f44e3a11b1c4..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionData.cs +++ /dev/null @@ -1,97 +0,0 @@ -// 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; -using Azure.ResourceManager.SelfHelp.Models; - -namespace Azure.ResourceManager.SelfHelp -{ - /// - /// A class representing the SelfHelpSimplifiedSolution data model. - /// Simplified Solutions response. - /// - public partial class SelfHelpSimplifiedSolutionData : ResourceData - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public SelfHelpSimplifiedSolutionData() - { - Parameters = new ChangeTrackingDictionary(); - Appendix = new ChangeTrackingDictionary(); - } - - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// Solution Id to identify single Simplified Solution. - /// Client input parameters to run Simplified Solutions. - /// The title. - /// Additional parameter response for Simplified Solutions. - /// The HTML content that needs to be rendered and shown to customer. - /// Status of Simplified Solution provisioning. - /// Keeps track of any properties unknown to the library. - internal SelfHelpSimplifiedSolutionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string solutionId, IDictionary parameters, string title, IReadOnlyDictionary appendix, string content, SolutionProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) - { - SolutionId = solutionId; - Parameters = parameters; - Title = title; - Appendix = appendix; - Content = content; - ProvisioningState = provisioningState; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Solution Id to identify single Simplified Solution. - public string SolutionId { get; set; } - /// Client input parameters to run Simplified Solutions. - public IDictionary Parameters { get; } - /// The title. - public string Title { get; } - /// Additional parameter response for Simplified Solutions. - public IReadOnlyDictionary Appendix { get; } - /// The HTML content that needs to be rendered and shown to customer. - public string Content { get; } - /// Status of Simplified Solution provisioning. - public SolutionProvisioningState? ProvisioningState { get; } - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionResource.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionResource.Serialization.cs deleted file mode 100644 index 4e916436618d..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionResource.Serialization.cs +++ /dev/null @@ -1,29 +0,0 @@ -// 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.SelfHelp -{ - public partial class SelfHelpSimplifiedSolutionResource : IJsonModel - { - private static SelfHelpSimplifiedSolutionData s_dataDeserializationInstance; - private static SelfHelpSimplifiedSolutionData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - - SelfHelpSimplifiedSolutionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerSelfHelpContext.Default); - - SelfHelpSimplifiedSolutionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerSelfHelpContext.Default); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionResource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionResource.cs deleted file mode 100644 index 415faffc7fd9..000000000000 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionResource.cs +++ /dev/null @@ -1,261 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; - -namespace Azure.ResourceManager.SelfHelp -{ - /// - /// A Class representing a SelfHelpSimplifiedSolution 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 GetSelfHelpSimplifiedSolutionResource method. - /// Otherwise you can get one from its parent resource using the GetSelfHelpSimplifiedSolution method. - /// - public partial class SelfHelpSimplifiedSolutionResource : ArmResource - { - /// Generate the resource identifier of a instance. - /// The scope. - /// The simplifiedSolutionsResourceName. - public static ResourceIdentifier CreateResourceIdentifier(string scope, string simplifiedSolutionsResourceName) - { - var resourceId = $"{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics; - private readonly SimplifiedSolutionsResourcesRestOperations _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient; - private readonly SelfHelpSimplifiedSolutionData _data; - - /// Gets the resource type for the operations. - public static readonly ResourceType ResourceType = "Microsoft.Help/simplifiedSolutions"; - - /// Initializes a new instance of the class for mocking. - protected SelfHelpSimplifiedSolutionResource() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The resource that is the target of operations. - internal SelfHelpSimplifiedSolutionResource(ArmClient client, SelfHelpSimplifiedSolutionData data) : this(client, data.Id) - { - HasData = true; - _data = data; - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the resource that is the target of operations. - internal SelfHelpSimplifiedSolutionResource(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesApiVersion); - _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient = new SimplifiedSolutionsResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - /// Gets whether or not the current instance has data. - public virtual bool HasData { get; } - - /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. - public virtual SelfHelpSimplifiedSolutionData Data - { - get - { - if (!HasData) - throw new InvalidOperationException("The current instance does not have data, you must call Get first."); - return _data; - } - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); - } - - /// - /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionResource.Get"); - scope.Start(); - try - { - var response = await _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.GetAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new SelfHelpSimplifiedSolutionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Get - /// - /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual Response Get(CancellationToken cancellationToken = default) - { - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionResource.Get"); - scope.Start(); - try - { - var response = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.Get(Id.Parent, Id.Name, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new SelfHelpSimplifiedSolutionResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Creates Simplified Solutions for an Azure subscription using 'solutionId' from Discovery Solutions as the input. <br/><br/> Simplified Solutions API makes the consumption of solutions APIs easier while still providing access to the same powerful solutions rendered in Solutions API. With Simplified Solutions, users don't have to worry about stitching together the article using replacement maps and can use the content in the API response to directly render as HTML content.<br/> - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Create - /// - /// - /// Default Api Version - /// 2024-03-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 required request body for simplified Solutions resource creation. - /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, SelfHelpSimplifiedSolutionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionResource.Update"); - scope.Start(); - try - { - var response = await _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.CreateAsync(Id.Parent, Id.Name, data, cancellationToken).ConfigureAwait(false); - var operation = new SelfHelpArmOperation(new SelfHelpSimplifiedSolutionOperationSource(Client), _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics, Pipeline, _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.CreateCreateRequest(Id.Parent, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Creates Simplified Solutions for an Azure subscription using 'solutionId' from Discovery Solutions as the input. <br/><br/> Simplified Solutions API makes the consumption of solutions APIs easier while still providing access to the same powerful solutions rendered in Solutions API. With Simplified Solutions, users don't have to worry about stitching together the article using replacement maps and can use the content in the API response to directly render as HTML content.<br/> - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName} - /// - /// - /// Operation Id - /// SimplifiedSolutionsResource_Create - /// - /// - /// Default Api Version - /// 2024-03-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 required request body for simplified Solutions resource creation. - /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, SelfHelpSimplifiedSolutionData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionResource.Update"); - scope.Start(); - try - { - var response = _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.Create(Id.Parent, Id.Name, data, cancellationToken); - var operation = new SelfHelpArmOperation(new SelfHelpSimplifiedSolutionOperationSource(Client), _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesClientDiagnostics, Pipeline, _selfHelpSimplifiedSolutionSimplifiedSolutionsResourcesRestClient.CreateCreateRequest(Id.Parent, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - } -} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsCollection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsCollection.cs new file mode 100644 index 000000000000..a7f6e8cc50be --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsCollection.cs @@ -0,0 +1,491 @@ +// 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.SelfHelp +{ + /// + /// 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 GetSelfHelpSimplifiedSolutions method from an instance of . + /// + public partial class SelfHelpSimplifiedSolutionsCollection : ArmCollection + { + private readonly ClientDiagnostics _simplifiedSolutionsResourcesClientDiagnostics; + private readonly SimplifiedSolutionsResources _simplifiedSolutionsResourcesRestClient; + + /// Initializes a new instance of SelfHelpSimplifiedSolutionsCollection for mocking. + protected SelfHelpSimplifiedSolutionsCollection() + { + } + + /// 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 SelfHelpSimplifiedSolutionsCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(SelfHelpSimplifiedSolutionsResource.ResourceType, out string selfHelpSimplifiedSolutionsApiVersion); + _simplifiedSolutionsResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", SelfHelpSimplifiedSolutionsResource.ResourceType.Namespace, Diagnostics); + _simplifiedSolutionsResourcesRestClient = new SimplifiedSolutionsResources(_simplifiedSolutionsResourcesClientDiagnostics, Pipeline, Endpoint, selfHelpSimplifiedSolutionsApiVersion ?? "2024-03-01-preview"); + } + + /// + /// Creates Simplified Solutions for an Azure subscription using 'solutionId' from Discovery Solutions as the input. <br/><br/> Simplified Solutions API makes the consumption of solutions APIs easier while still providing access to the same powerful solutions rendered in Solutions API. With Simplified Solutions, users don't have to worry about stitching together the article using replacement maps and can use the content in the API response to directly render as HTML content.<br/> + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Create. + /// + /// + /// Default Api Version. + /// 2024-03-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. + /// Simplified Solutions Resource Name. + /// The required request body for simplified Solutions resource creation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string simplifiedSolutionsResourceName, SelfHelpSimplifiedSolutionsData data = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); + + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateCreateRequest(Id, simplifiedSolutionsResourceName, SelfHelpSimplifiedSolutionsData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpSimplifiedSolutionsOperationSource(Client), + _simplifiedSolutionsResourcesClientDiagnostics, + 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; + } + } + + /// + /// Creates Simplified Solutions for an Azure subscription using 'solutionId' from Discovery Solutions as the input. <br/><br/> Simplified Solutions API makes the consumption of solutions APIs easier while still providing access to the same powerful solutions rendered in Solutions API. With Simplified Solutions, users don't have to worry about stitching together the article using replacement maps and can use the content in the API response to directly render as HTML content.<br/> + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Create. + /// + /// + /// Default Api Version. + /// 2024-03-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. + /// Simplified Solutions Resource Name. + /// The required request body for simplified Solutions resource creation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string simplifiedSolutionsResourceName, SelfHelpSimplifiedSolutionsData data = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); + + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateCreateRequest(Id, simplifiedSolutionsResourceName, SelfHelpSimplifiedSolutionsData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpSimplifiedSolutionsOperationSource(Client), + _simplifiedSolutionsResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// Simplified Solutions Resource Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); + + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateGetRequest(Id, simplifiedSolutionsResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpSimplifiedSolutionsData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSimplifiedSolutionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// Simplified Solutions Resource Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); + + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateGetRequest(Id, simplifiedSolutionsResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpSimplifiedSolutionsData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSimplifiedSolutionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// Simplified Solutions Resource Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); + + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateGetRequest(Id, simplifiedSolutionsResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSimplifiedSolutionsData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSimplifiedSolutionsData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// Simplified Solutions Resource Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); + + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateGetRequest(Id, simplifiedSolutionsResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSimplifiedSolutionsData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSimplifiedSolutionsData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// Simplified Solutions Resource Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); + + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateGetRequest(Id, simplifiedSolutionsResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSimplifiedSolutionsData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSimplifiedSolutionsData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSimplifiedSolutionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// Simplified Solutions Resource Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string simplifiedSolutionsResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(simplifiedSolutionsResourceName, nameof(simplifiedSolutionsResourceName)); + + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateGetRequest(Id, simplifiedSolutionsResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSimplifiedSolutionsData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSimplifiedSolutionsData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSimplifiedSolutionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsData.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsData.Serialization.cs new file mode 100644 index 000000000000..c24d02fc01be --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsData.Serialization.cs @@ -0,0 +1,196 @@ +// 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.Models; +using Azure.ResourceManager.SelfHelp.Models; + +namespace Azure.ResourceManager.SelfHelp +{ + /// Simplified Solutions response. + public partial class SelfHelpSimplifiedSolutionsData : ResourceData, IJsonModel + { + /// 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(SelfHelpSimplifiedSolutionsData)} 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. + SelfHelpSimplifiedSolutionsData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SelfHelpSimplifiedSolutionsData)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(SelfHelpSimplifiedSolutionsData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSelfHelpSimplifiedSolutionsData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpSimplifiedSolutionsData DeserializeSelfHelpSimplifiedSolutionsData(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(); + SimplifiedSolutionsResourceProperties 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, AzureResourceManagerSelfHelpContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = SimplifiedSolutionsResourceProperties.DeserializeSimplifiedSolutionsResourceProperties(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SelfHelpSimplifiedSolutionsData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerSelfHelpContext.Default); + default: + throw new FormatException($"The model {nameof(SelfHelpSimplifiedSolutionsData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpSimplifiedSolutionsData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SelfHelpSimplifiedSolutionsData)PersistableModelCreateCore(data, options); + + /// 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 DeserializeSelfHelpSimplifiedSolutionsData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SelfHelpSimplifiedSolutionsData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(SelfHelpSimplifiedSolutionsData selfHelpSimplifiedSolutionsData) + { + if (selfHelpSimplifiedSolutionsData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(selfHelpSimplifiedSolutionsData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static SelfHelpSimplifiedSolutionsData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSelfHelpSimplifiedSolutionsData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsData.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsData.cs new file mode 100644 index 000000000000..983e09b69a56 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsData.cs @@ -0,0 +1,113 @@ +// 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; +using Azure.ResourceManager.SelfHelp.Models; + +namespace Azure.ResourceManager.SelfHelp +{ + /// Simplified Solutions response. + public partial class SelfHelpSimplifiedSolutionsData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SelfHelpSimplifiedSolutionsData() + { + } + + /// 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. + /// Simplified Solutions result. + internal SelfHelpSimplifiedSolutionsData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, SimplifiedSolutionsResourceProperties properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// Simplified Solutions result. + internal SimplifiedSolutionsResourceProperties Properties { get; set; } + + /// Solution Id to identify single Simplified Solution. + public string SolutionId + { + get + { + return Properties is null ? default : Properties.SolutionId; + } + set + { + if (Properties is null) + { + Properties = new SimplifiedSolutionsResourceProperties(); + } + Properties.SolutionId = value; + } + } + + /// Client input parameters to run Simplified Solutions. + public IDictionary Parameters + { + get + { + if (Properties is null) + { + Properties = new SimplifiedSolutionsResourceProperties(); + } + return Properties.Parameters; + } + } + + /// The title. + public string Title + { + get + { + return Properties is null ? default : Properties.Title; + } + } + + /// Additional parameter response for Simplified Solutions. + public IReadOnlyDictionary Appendix + { + get + { + if (Properties is null) + { + Properties = new SimplifiedSolutionsResourceProperties(); + } + return Properties.Appendix; + } + } + + /// The HTML content that needs to be rendered and shown to customer. + public string Content + { + get + { + return Properties is null ? default : Properties.Content; + } + } + + /// Status of Simplified Solution provisioning. + public SolutionProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsResource.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsResource.Serialization.cs new file mode 100644 index 000000000000..228eac2872f4 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsResource.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.SelfHelp +{ + /// + public partial class SelfHelpSimplifiedSolutionsResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new SelfHelpSimplifiedSolutionsData(); + + /// 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. + SelfHelpSimplifiedSolutionsData 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, AzureResourceManagerSelfHelpContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + SelfHelpSimplifiedSolutionsData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerSelfHelpContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsResource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsResource.cs new file mode 100644 index 000000000000..ff5d249feadd --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSimplifiedSolutionsResource.cs @@ -0,0 +1,300 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +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.SelfHelp +{ + /// + /// A class representing a SelfHelpSimplifiedSolutions 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 GetSelfHelpSimplifiedSolutions method. + /// + public partial class SelfHelpSimplifiedSolutionsResource : ArmResource + { + private readonly ClientDiagnostics _simplifiedSolutionsResourcesClientDiagnostics; + private readonly SimplifiedSolutionsResources _simplifiedSolutionsResourcesRestClient; + private readonly SelfHelpSimplifiedSolutionsData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Help/simplifiedSolutions"; + + /// Initializes a new instance of SelfHelpSimplifiedSolutionsResource for mocking. + protected SelfHelpSimplifiedSolutionsResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal SelfHelpSimplifiedSolutionsResource(ArmClient client, SelfHelpSimplifiedSolutionsData 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 SelfHelpSimplifiedSolutionsResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string selfHelpSimplifiedSolutionsApiVersion); + _simplifiedSolutionsResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ResourceType.Namespace, Diagnostics); + _simplifiedSolutionsResourcesRestClient = new SimplifiedSolutionsResources(_simplifiedSolutionsResourcesClientDiagnostics, Pipeline, Endpoint, selfHelpSimplifiedSolutionsApiVersion ?? "2024-03-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 SelfHelpSimplifiedSolutionsData 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 scope. + /// The simplifiedSolutionsResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string scope, string simplifiedSolutionsResourceName) + { + string resourceId = $"{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}"; + 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 the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateGetRequest(Id.Parent, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpSimplifiedSolutionsData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSimplifiedSolutionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the simplified Solutions using the applicable solutionResourceName while creating the simplified Solutions. + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateGetRequest(Id.Parent, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpSimplifiedSolutionsData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSimplifiedSolutionsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates Simplified Solutions for an Azure subscription using 'solutionId' from Discovery Solutions as the input. <br/><br/> Simplified Solutions API makes the consumption of solutions APIs easier while still providing access to the same powerful solutions rendered in Solutions API. With Simplified Solutions, users don't have to worry about stitching together the article using replacement maps and can use the content in the API response to directly render as HTML content.<br/> + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Create. + /// + /// + /// Default Api Version. + /// 2024-03-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 required request body for simplified Solutions resource creation. + /// The cancellation token to use. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, SelfHelpSimplifiedSolutionsData data = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateCreateRequest(Id.Parent, Id.Name, SelfHelpSimplifiedSolutionsData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpSimplifiedSolutionsOperationSource(Client), + _simplifiedSolutionsResourcesClientDiagnostics, + 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; + } + } + + /// + /// Creates Simplified Solutions for an Azure subscription using 'solutionId' from Discovery Solutions as the input. <br/><br/> Simplified Solutions API makes the consumption of solutions APIs easier while still providing access to the same powerful solutions rendered in Solutions API. With Simplified Solutions, users don't have to worry about stitching together the article using replacement maps and can use the content in the API response to directly render as HTML content.<br/> + /// + /// + /// Request Path. + /// /{scope}/providers/Microsoft.Help/simplifiedSolutions/{simplifiedSolutionsResourceName}. + /// + /// + /// Operation Id. + /// SimplifiedSolutionsResources_Create. + /// + /// + /// Default Api Version. + /// 2024-03-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 required request body for simplified Solutions resource creation. + /// The cancellation token to use. + public virtual ArmOperation Update(WaitUntil waitUntil, SelfHelpSimplifiedSolutionsData data = default, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _simplifiedSolutionsResourcesClientDiagnostics.CreateScope("SelfHelpSimplifiedSolutionsResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _simplifiedSolutionsResourcesRestClient.CreateCreateRequest(Id.Parent, Id.Name, SelfHelpSimplifiedSolutionsData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpSimplifiedSolutionsOperationSource(Client), + _simplifiedSolutionsResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionCollection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionCollection.cs index 295b803f3f36..f098fc402deb 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionCollection.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionCollection.cs @@ -8,8 +8,10 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.SelfHelp { @@ -20,42 +22,38 @@ namespace Azure.ResourceManager.SelfHelp /// public partial class SelfHelpSolutionCollection : ArmCollection { - private readonly ClientDiagnostics _selfHelpSolutionSolutionResourcesClientDiagnostics; - private readonly SolutionResourcesRestOperations _selfHelpSolutionSolutionResourcesRestClient; + private readonly ClientDiagnostics _solutionResourcesClientDiagnostics; + private readonly SolutionResources _solutionResourcesRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of SelfHelpSolutionCollection for mocking. protected SelfHelpSolutionCollection() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. + /// The identifier of the resource that is the target of operations. internal SelfHelpSolutionCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _selfHelpSolutionSolutionResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", SelfHelpSolutionResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(SelfHelpSolutionResource.ResourceType, out string selfHelpSolutionSolutionResourcesApiVersion); - _selfHelpSolutionSolutionResourcesRestClient = new SolutionResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, selfHelpSolutionSolutionResourcesApiVersion); + TryGetApiVersion(SelfHelpSolutionResource.ResourceType, out string selfHelpSolutionApiVersion); + _solutionResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", SelfHelpSolutionResource.ResourceType.Namespace, Diagnostics); + _solutionResourcesRestClient = new SolutionResources(_solutionResourcesClientDiagnostics, Pipeline, Endpoint, selfHelpSolutionApiVersion ?? "2024-03-01-preview"); } /// /// Creates a solution for the specific Azure resource or subscription using the inputs ‘solutionId and requiredInputs’ from discovery solutions. <br/> Azure solutions comprise a comprehensive library of self-help resources that have been thoughtfully curated by Azure engineers to aid customers in resolving typical troubleshooting issues. These solutions encompass: <br/> (1.) Dynamic and context-aware diagnostics, guided troubleshooting wizards, and data visualizations. <br/> (2.) Rich instructional video tutorials and illustrative diagrams and images. <br/> (3.) Thoughtfully assembled textual troubleshooting instructions. <br/> All these components are seamlessly converged into unified solutions tailored to address a specific support problem area. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Operation Id - /// SolutionResource_Create + /// Operation Id. + /// SolutionResources_Create. /// /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// @@ -63,21 +61,33 @@ internal SelfHelpSolutionCollection(ArmClient client, ResourceIdentifier id) : b /// Solution resource Name. /// The required request body for this solution resource creation. /// The cancellation token to use. + /// is null. /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string solutionResourceName, SelfHelpSolutionData data, CancellationToken cancellationToken = default) + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string solutionResourceName, SelfHelpSolutionData data = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - Argument.AssertNotNull(data, nameof(data)); - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.CreateOrUpdate"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _selfHelpSolutionSolutionResourcesRestClient.CreateAsync(Id, solutionResourceName, data, cancellationToken).ConfigureAwait(false); - var operation = new SelfHelpArmOperation(new SelfHelpSolutionOperationSource(Client), _selfHelpSolutionSolutionResourcesClientDiagnostics, Pipeline, _selfHelpSolutionSolutionResourcesRestClient.CreateCreateRequest(Id, solutionResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateCreateRequest(Id, solutionResourceName, SelfHelpSolutionData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpSolutionOperationSource(Client), + _solutionResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -91,20 +101,16 @@ public virtual async Task> CreateOrUpdate /// Creates a solution for the specific Azure resource or subscription using the inputs ‘solutionId and requiredInputs’ from discovery solutions. <br/> Azure solutions comprise a comprehensive library of self-help resources that have been thoughtfully curated by Azure engineers to aid customers in resolving typical troubleshooting issues. These solutions encompass: <br/> (1.) Dynamic and context-aware diagnostics, guided troubleshooting wizards, and data visualizations. <br/> (2.) Rich instructional video tutorials and illustrative diagrams and images. <br/> (3.) Thoughtfully assembled textual troubleshooting instructions. <br/> All these components are seamlessly converged into unified solutions tailored to address a specific support problem area. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} - /// - /// - /// Operation Id - /// SolutionResource_Create + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// SolutionResources_Create. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// @@ -112,21 +118,33 @@ public virtual async Task> CreateOrUpdate /// Solution resource Name. /// The required request body for this solution resource creation. /// The cancellation token to use. + /// is null. /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string solutionResourceName, SelfHelpSolutionData data, CancellationToken cancellationToken = default) + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string solutionResourceName, SelfHelpSolutionData data = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - Argument.AssertNotNull(data, nameof(data)); - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.CreateOrUpdate"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.CreateOrUpdate"); scope.Start(); try { - var response = _selfHelpSolutionSolutionResourcesRestClient.Create(Id, solutionResourceName, data, cancellationToken); - var operation = new SelfHelpArmOperation(new SelfHelpSolutionOperationSource(Client), _selfHelpSolutionSolutionResourcesClientDiagnostics, Pipeline, _selfHelpSolutionSolutionResourcesRestClient.CreateCreateRequest(Id, solutionResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateCreateRequest(Id, solutionResourceName, SelfHelpSolutionData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpSolutionOperationSource(Client), + _solutionResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -140,38 +158,42 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil w /// Get the solution using the applicable solutionResourceName while creating the solution. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} - /// - /// - /// Operation Id - /// SolutionResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// SolutionResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Solution resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetAsync(string solutionResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.Get"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.Get"); scope.Start(); try { - var response = await _selfHelpSolutionSolutionResourcesRestClient.GetAsync(Id, solutionResourceName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateGetRequest(Id, solutionResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpSolutionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpSolutionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -185,38 +207,42 @@ public virtual async Task> GetAsync(string so /// Get the solution using the applicable solutionResourceName while creating the solution. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} - /// - /// - /// Operation Id - /// SolutionResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// SolutionResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Solution resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Get(string solutionResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.Get"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.Get"); scope.Start(); try { - var response = _selfHelpSolutionSolutionResourcesRestClient.Get(Id, solutionResourceName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateGetRequest(Id, solutionResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpSolutionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpSolutionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -227,39 +253,53 @@ public virtual Response Get(string solutionResourceNam } /// - /// Checks to see if the resource exists in azure. + /// Get the solution using the applicable solutionResourceName while creating the solution. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} - /// - /// - /// Operation Id - /// SolutionResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// SolutionResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Solution resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> ExistsAsync(string solutionResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.Exists"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.Exists"); scope.Start(); try { - var response = await _selfHelpSolutionSolutionResourcesRestClient.GetAsync(Id, solutionResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateGetRequest(Id, solutionResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSolutionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSolutionData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -270,39 +310,53 @@ public virtual async Task> ExistsAsync(string solutionResourceNam } /// - /// Checks to see if the resource exists in azure. + /// Get the solution using the applicable solutionResourceName while creating the solution. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} - /// - /// - /// Operation Id - /// SolutionResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// SolutionResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Solution resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Exists(string solutionResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.Exists"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.Exists"); scope.Start(); try { - var response = _selfHelpSolutionSolutionResourcesRestClient.Get(Id, solutionResourceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateGetRequest(Id, solutionResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSolutionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSolutionData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -313,41 +367,57 @@ public virtual Response Exists(string solutionResourceName, CancellationTo } /// - /// Tries to get details for this resource from the service. + /// Get the solution using the applicable solutionResourceName while creating the solution. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Operation Id - /// SolutionResource_Get + /// Operation Id. + /// SolutionResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Solution resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetIfExistsAsync(string solutionResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.GetIfExists"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.GetIfExists"); scope.Start(); try { - var response = await _selfHelpSolutionSolutionResourcesRestClient.GetAsync(Id, solutionResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateGetRequest(Id, solutionResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSolutionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSolutionData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpSolutionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -358,41 +428,57 @@ public virtual async Task> GetIfExist } /// - /// Tries to get details for this resource from the service. + /// Get the solution using the applicable solutionResourceName while creating the solution. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Operation Id - /// SolutionResource_Get + /// Operation Id. + /// SolutionResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Solution resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual NullableResponse GetIfExists(string solutionResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(solutionResourceName, nameof(solutionResourceName)); - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.GetIfExists"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionCollection.GetIfExists"); scope.Start(); try { - var response = _selfHelpSolutionSolutionResourcesRestClient.Get(Id, solutionResourceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateGetRequest(Id, solutionResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSolutionData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSolutionData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpSolutionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionData.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionData.Serialization.cs index c811d0c1bfa9..498ad3af62cb 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionData.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionData.Serialization.cs @@ -10,16 +10,18 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Models; using Azure.ResourceManager.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp { - public partial class SelfHelpSolutionData : IUtf8JsonSerializable, IJsonModel + /// Solution response. + public partial class SelfHelpSolutionData : ResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,247 +33,114 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpSolutionData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(TriggerCriteria)) - { - writer.WritePropertyName("triggerCriteria"u8); - writer.WriteStartArray(); - foreach (var item in TriggerCriteria) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsCollectionDefined(Parameters)) - { - writer.WritePropertyName("parameters"u8); - writer.WriteStartObject(); - foreach (var item in Parameters) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - if (options.Format != "W" && Optional.IsDefined(SolutionId)) - { - writer.WritePropertyName("solutionId"u8); - writer.WriteStringValue(SolutionId); - } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("provisioningState"u8); - writer.WriteStringValue(ProvisioningState.Value.ToString()); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - if (options.Format != "W" && Optional.IsDefined(Title)) - { - writer.WritePropertyName("title"u8); - writer.WriteStringValue(Title); - } - if (options.Format != "W" && Optional.IsDefined(Content)) - { - writer.WritePropertyName("content"u8); - writer.WriteStringValue(Content); - } - if (options.Format != "W" && Optional.IsDefined(ReplacementMaps)) - { - writer.WritePropertyName("replacementMaps"u8); - writer.WriteObjectValue(ReplacementMaps, options); - } - if (options.Format != "W" && Optional.IsCollectionDefined(Sections)) - { - writer.WritePropertyName("sections"u8); - writer.WriteStartArray(); - foreach (var item in Sections) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - writer.WriteEndObject(); } - SelfHelpSolutionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpSolutionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SelfHelpSolutionData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpSolutionData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpSolutionData(document.RootElement, options); } - internal static SelfHelpSolutionData DeserializeSelfHelpSolutionData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpSolutionData DeserializeSelfHelpSolutionData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - IList triggerCriteria = default; - IDictionary parameters = default; - string solutionId = default; - SolutionProvisioningState? provisioningState = default; - string title = default; - string content = default; - SolutionReplacementMaps replacementMaps = default; - IReadOnlyList sections = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + SolutionResourceProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("triggerCriteria"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(SolutionTriggerCriterion.DeserializeSolutionTriggerCriterion(item, options)); - } - triggerCriteria = array; - continue; - } - if (property0.NameEquals("parameters"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property1 in property0.Value.EnumerateObject()) - { - dictionary.Add(property1.Name, property1.Value.GetString()); - } - parameters = dictionary; - continue; - } - if (property0.NameEquals("solutionId"u8)) - { - solutionId = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("provisioningState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new SolutionProvisioningState(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("title"u8)) - { - title = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("content"u8)) - { - content = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("replacementMaps"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - replacementMaps = SolutionReplacementMaps.DeserializeSolutionReplacementMaps(property0.Value, options); - continue; - } - if (property0.NameEquals("sections"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(SelfHelpSection.DeserializeSelfHelpSection(item, options)); - } - sections = array; - continue; - } - } + properties = SolutionResourceProperties.DeserializeSolutionResourceProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new SelfHelpSolutionData( id, name, - type, + resourceType, systemData, - triggerCriteria ?? new ChangeTrackingList(), - parameters ?? new ChangeTrackingDictionary(), - solutionId, - provisioningState, - title, - content, - replacementMaps, - sections ?? new ChangeTrackingList(), - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -281,15 +150,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - SelfHelpSolutionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpSolutionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SelfHelpSolutionData)PersistableModelCreateCore(data, options); + /// 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpSolutionData(document.RootElement, options); } default: @@ -297,6 +171,26 @@ SelfHelpSolutionData IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(SelfHelpSolutionData selfHelpSolutionData) + { + if (selfHelpSolutionData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(selfHelpSolutionData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static SelfHelpSolutionData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSelfHelpSolutionData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionData.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionData.cs index 9ce085980809..6b61f93867ab 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionData.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionData.cs @@ -13,94 +13,115 @@ namespace Azure.ResourceManager.SelfHelp { - /// - /// A class representing the SelfHelpSolution data model. - /// Solution response. - /// + /// Solution response. public partial class SelfHelpSolutionData : ResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public SelfHelpSolutionData() { - TriggerCriteria = new ChangeTrackingList(); - Parameters = new ChangeTrackingDictionary(); - Sections = new ChangeTrackingList(); } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// Solution request trigger criteria. - /// Client input parameters to run Solution. - /// Solution Id to identify single solution. - /// Status of solution provisioning. - /// The title. - /// The HTML content that needs to be rendered and shown to customer. - /// Solution replacement maps. - /// List of section object. - /// Keeps track of any properties unknown to the library. - internal SelfHelpSolutionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IList triggerCriteria, IDictionary parameters, string solutionId, SolutionProvisioningState? provisioningState, string title, string content, SolutionReplacementMaps replacementMaps, IReadOnlyList sections, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + /// 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. + /// Solution result. + internal SelfHelpSolutionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, SolutionResourceProperties properties) : base(id, name, resourceType, systemData) { - TriggerCriteria = triggerCriteria; - Parameters = parameters; - SolutionId = solutionId; - ProvisioningState = provisioningState; - Title = title; - Content = content; - ReplacementMaps = replacementMaps; - Sections = sections; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } + /// Solution result. + internal SolutionResourceProperties Properties { get; set; } + /// Solution request trigger criteria. - public IList TriggerCriteria { get; } + public IList TriggerCriteria + { + get + { + if (Properties is null) + { + Properties = new SolutionResourceProperties(); + } + return Properties.TriggerCriteria; + } + } + /// Client input parameters to run Solution. - public IDictionary Parameters { get; } + public IDictionary Parameters + { + get + { + if (Properties is null) + { + Properties = new SolutionResourceProperties(); + } + return Properties.Parameters; + } + } + /// Solution Id to identify single solution. - public string SolutionId { get; } + public string SolutionId + { + get + { + return Properties is null ? default : Properties.SolutionId; + } + } + /// Status of solution provisioning. - public SolutionProvisioningState? ProvisioningState { get; } + public SolutionProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + /// The title. - public string Title { get; } + public string Title + { + get + { + return Properties is null ? default : Properties.Title; + } + } + /// The HTML content that needs to be rendered and shown to customer. - public string Content { get; } + public string Content + { + get + { + return Properties is null ? default : Properties.Content; + } + } + /// Solution replacement maps. - public SolutionReplacementMaps ReplacementMaps { get; } + public SolutionReplacementMaps ReplacementMaps + { + get + { + return Properties is null ? default : Properties.ReplacementMaps; + } + } + /// List of section object. - public IReadOnlyList Sections { get; } + public IReadOnlyList Sections + { + get + { + if (Properties is null) + { + Properties = new SolutionResourceProperties(); + } + return Properties.Sections; + } + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResource.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResource.Serialization.cs index 12e75212e068..530f4a52e194 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResource.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.SelfHelp { + /// public partial class SelfHelpSolutionResource : IJsonModel { - private static SelfHelpSolutionData s_dataDeserializationInstance; - private static SelfHelpSolutionData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new SelfHelpSolutionData(); + + /// 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); - SelfHelpSolutionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + SelfHelpSolutionData 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, AzureResourceManagerSelfHelpContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. SelfHelpSolutionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerSelfHelpContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResource.cs index 9890a3de28ea..1607e57130fb 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResource.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResource.cs @@ -6,45 +6,36 @@ #nullable disable using System; -using System.Globalization; +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.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp { /// - /// A Class representing a SelfHelpSolution 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 GetSelfHelpSolutionResource method. - /// Otherwise you can get one from its parent resource using the GetSelfHelpSolution method. + /// A class representing a SelfHelpSolution 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 GetSelfHelpSolutions method. /// public partial class SelfHelpSolutionResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The scope. - /// The solutionResourceName. - public static ResourceIdentifier CreateResourceIdentifier(string scope, string solutionResourceName) - { - var resourceId = $"{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _selfHelpSolutionSolutionResourcesClientDiagnostics; - private readonly SolutionResourcesRestOperations _selfHelpSolutionSolutionResourcesRestClient; + private readonly ClientDiagnostics _solutionResourcesClientDiagnostics; + private readonly SolutionResources _solutionResourcesRestClient; private readonly SelfHelpSolutionData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Help/solutions"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of SelfHelpSolutionResource for mocking. protected SelfHelpSolutionResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal SelfHelpSolutionResource(ArmClient client, SelfHelpSolutionData data) : this(client, data.Id) @@ -53,71 +44,91 @@ internal SelfHelpSolutionResource(ArmClient client, SelfHelpSolutionData data) : _data = data; } - /// Initializes a new instance of the class. + /// 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 SelfHelpSolutionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _selfHelpSolutionSolutionResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string selfHelpSolutionSolutionResourcesApiVersion); - _selfHelpSolutionSolutionResourcesRestClient = new SolutionResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, selfHelpSolutionSolutionResourcesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string selfHelpSolutionApiVersion); + _solutionResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ResourceType.Namespace, Diagnostics); + _solutionResourcesRestClient = new SolutionResources(_solutionResourcesClientDiagnostics, Pipeline, Endpoint, selfHelpSolutionApiVersion ?? "2024-03-01-preview"); + ValidateResourceId(id); } /// Gets whether or not the current instance has data. public virtual bool HasData { get; } /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. public virtual SelfHelpSolutionData 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 scope. + /// The solutionResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string scope, string solutionResourceName) + { + string resourceId = $"{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Get the solution using the applicable solutionResourceName while creating the solution. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Operation Id - /// SolutionResource_Get + /// Operation Id. + /// SolutionResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.Get"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.Get"); scope.Start(); try { - var response = await _selfHelpSolutionSolutionResourcesRestClient.GetAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateGetRequest(Id.Parent, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpSolutionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpSolutionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -131,33 +142,41 @@ public virtual async Task> GetAsync(Cancellat /// Get the solution using the applicable solutionResourceName while creating the solution. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Operation Id - /// SolutionResource_Get + /// Operation Id. + /// SolutionResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.Get"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.Get"); scope.Start(); try { - var response = _selfHelpSolutionSolutionResourcesRestClient.Get(Id.Parent, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateGetRequest(Id.Parent, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpSolutionData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpSolutionResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -171,39 +190,49 @@ public virtual Response Get(CancellationToken cancella /// Update the requiredInputs or additional information needed to execute the solution /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Operation Id - /// SolutionResource_Update + /// Operation Id. + /// SolutionResources_Update. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// 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 required request body for updating a solution resource. + /// The required request body for updating a solution resource. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, SelfHelpSolutionPatch patch, CancellationToken cancellationToken = default) + public virtual async Task> UpdateAsync(WaitUntil waitUntil, SelfHelpSolutionPatch solutionPatchRequestBody = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.Update"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.Update"); scope.Start(); try { - var response = await _selfHelpSolutionSolutionResourcesRestClient.UpdateAsync(Id.Parent, Id.Name, patch, cancellationToken).ConfigureAwait(false); - var operation = new SelfHelpArmOperation(new SelfHelpSolutionOperationSource(Client), _selfHelpSolutionSolutionResourcesClientDiagnostics, Pipeline, _selfHelpSolutionSolutionResourcesRestClient.CreateUpdateRequest(Id.Parent, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateUpdateRequest(Id.Parent, Id.Name, SelfHelpSolutionPatch.ToRequestContent(solutionPatchRequestBody), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpSolutionOperationSource(Client), + _solutionResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -217,39 +246,49 @@ public virtual async Task> UpdateAsync(Wa /// Update the requiredInputs or additional information needed to execute the solution /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}. /// /// - /// Operation Id - /// SolutionResource_Update + /// Operation Id. + /// SolutionResources_Update. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// 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 required request body for updating a solution resource. + /// The required request body for updating a solution resource. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, SelfHelpSolutionPatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Update(WaitUntil waitUntil, SelfHelpSolutionPatch solutionPatchRequestBody = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.Update"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.Update"); scope.Start(); try { - var response = _selfHelpSolutionSolutionResourcesRestClient.Update(Id.Parent, Id.Name, patch, cancellationToken); - var operation = new SelfHelpArmOperation(new SelfHelpSolutionOperationSource(Client), _selfHelpSolutionSolutionResourcesClientDiagnostics, Pipeline, _selfHelpSolutionSolutionResourcesRestClient.CreateUpdateRequest(Id.Parent, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateUpdateRequest(Id.Parent, Id.Name, SelfHelpSolutionPatch.ToRequestContent(solutionPatchRequestBody), context); + Response response = Pipeline.ProcessMessage(message, context); + SelfHelpArmOperation operation = new SelfHelpArmOperation( + new SelfHelpSolutionOperationSource(Client), + _solutionResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -263,32 +302,37 @@ public virtual ArmOperation Update(WaitUntil waitUntil /// Warm up the solution resource by preloading asynchronous diagnostics results into cache /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}/warmup + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}/warmup. /// /// - /// Operation Id - /// SolutionResources_WarmUp + /// Operation Id. + /// SolutionResources_WarmUp. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The required request body for warming up a solution resource. + /// The required request body for warming up a solution resource. /// The cancellation token to use. - public virtual async Task WarmUpAsync(SolutionWarmUpContent content = null, CancellationToken cancellationToken = default) + public virtual async Task WarmUpAsync(SolutionWarmUpContent solutionWarmUpRequestBody = default, CancellationToken cancellationToken = default) { - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.WarmUp"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.WarmUp"); scope.Start(); try { - var response = await _selfHelpSolutionSolutionResourcesRestClient.WarmUpAsync(Id.Parent, Id.Name, content, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateWarmUpRequest(Id.Parent, Id.Name, SolutionWarmUpContent.ToRequestContent(solutionWarmUpRequestBody), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); return response; } catch (Exception e) @@ -302,32 +346,37 @@ public virtual async Task WarmUpAsync(SolutionWarmUpContent content = /// Warm up the solution resource by preloading asynchronous diagnostics results into cache /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}/warmup + /// Request Path. + /// /{scope}/providers/Microsoft.Help/solutions/{solutionResourceName}/warmup. /// /// - /// Operation Id - /// SolutionResources_WarmUp + /// Operation Id. + /// SolutionResources_WarmUp. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The required request body for warming up a solution resource. + /// The required request body for warming up a solution resource. /// The cancellation token to use. - public virtual Response WarmUp(SolutionWarmUpContent content = null, CancellationToken cancellationToken = default) + public virtual Response WarmUp(SolutionWarmUpContent solutionWarmUpRequestBody = default, CancellationToken cancellationToken = default) { - using var scope = _selfHelpSolutionSolutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.WarmUp"); + using DiagnosticScope scope = _solutionResourcesClientDiagnostics.CreateScope("SelfHelpSolutionResource.WarmUp"); scope.Start(); try { - var response = _selfHelpSolutionSolutionResourcesRestClient.WarmUp(Id.Parent, Id.Name, content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionResourcesRestClient.CreateWarmUpRequest(Id.Parent, Id.Name, SolutionWarmUpContent.ToRequestContent(solutionWarmUpRequestBody), context); + Response response = Pipeline.ProcessMessage(message, context); return response; } catch (Exception e) diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultCollection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultCollection.cs new file mode 100644 index 000000000000..326404f441b4 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultCollection.cs @@ -0,0 +1,390 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +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.SelfHelp +{ + /// + /// 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 GetSelfHelpSolutionResults method from an instance of . + /// + public partial class SelfHelpSolutionResultCollection : ArmCollection + { + private readonly ClientDiagnostics _solutionSelfHelpClientDiagnostics; + private readonly SolutionSelfHelp _solutionSelfHelpRestClient; + + /// Initializes a new instance of SelfHelpSolutionResultCollection for mocking. + protected SelfHelpSolutionResultCollection() + { + } + + /// 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 SelfHelpSolutionResultCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(SelfHelpSolutionResultResource.ResourceType, out string selfHelpSolutionResultApiVersion); + _solutionSelfHelpClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", SelfHelpSolutionResultResource.ResourceType.Namespace, Diagnostics); + _solutionSelfHelpRestClient = new SolutionSelfHelp(_solutionSelfHelpClientDiagnostics, Pipeline, Endpoint, selfHelpSolutionResultApiVersion ?? "2024-03-01-preview"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != TenantResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, TenantResource.ResourceType), id); + } + } + + /// + /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. + /// + /// + /// Request Path. + /// /providers/Microsoft.Help/selfHelp/{solutionId}. + /// + /// + /// Operation Id. + /// SolutionResourceSelfHelps_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetSelfHelpSolutionByIdAsync(string solutionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(solutionId, nameof(solutionId)); + + using DiagnosticScope scope = _solutionSelfHelpClientDiagnostics.CreateScope("SelfHelpSolutionResultCollection.GetSelfHelpSolutionById"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionSelfHelpRestClient.CreateGetSelfHelpSolutionByIdRequest(solutionId, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpSolutionResultData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSolutionResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. + /// + /// + /// Request Path. + /// /providers/Microsoft.Help/selfHelp/{solutionId}. + /// + /// + /// Operation Id. + /// SolutionResourceSelfHelps_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetSelfHelpSolutionById(string solutionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(solutionId, nameof(solutionId)); + + using DiagnosticScope scope = _solutionSelfHelpClientDiagnostics.CreateScope("SelfHelpSolutionResultCollection.GetSelfHelpSolutionById"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionSelfHelpRestClient.CreateGetSelfHelpSolutionByIdRequest(solutionId, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpSolutionResultData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSolutionResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. + /// + /// + /// Request Path. + /// /providers/Microsoft.Help/selfHelp/{solutionId}. + /// + /// + /// Operation Id. + /// SolutionResourceSelfHelps_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string solutionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(solutionId, nameof(solutionId)); + + using DiagnosticScope scope = _solutionSelfHelpClientDiagnostics.CreateScope("SelfHelpSolutionResultCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionSelfHelpRestClient.CreateGetSelfHelpSolutionByIdRequest(solutionId, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSolutionResultData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSolutionResultData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. + /// + /// + /// Request Path. + /// /providers/Microsoft.Help/selfHelp/{solutionId}. + /// + /// + /// Operation Id. + /// SolutionResourceSelfHelps_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string solutionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(solutionId, nameof(solutionId)); + + using DiagnosticScope scope = _solutionSelfHelpClientDiagnostics.CreateScope("SelfHelpSolutionResultCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionSelfHelpRestClient.CreateGetSelfHelpSolutionByIdRequest(solutionId, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSolutionResultData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSolutionResultData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. + /// + /// + /// Request Path. + /// /providers/Microsoft.Help/selfHelp/{solutionId}. + /// + /// + /// Operation Id. + /// SolutionResourceSelfHelps_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string solutionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(solutionId, nameof(solutionId)); + + using DiagnosticScope scope = _solutionSelfHelpClientDiagnostics.CreateScope("SelfHelpSolutionResultCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionSelfHelpRestClient.CreateGetSelfHelpSolutionByIdRequest(solutionId, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSolutionResultData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSolutionResultData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSolutionResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. + /// + /// + /// Request Path. + /// /providers/Microsoft.Help/selfHelp/{solutionId}. + /// + /// + /// Operation Id. + /// SolutionResourceSelfHelps_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// + /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string solutionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(solutionId, nameof(solutionId)); + + using DiagnosticScope scope = _solutionSelfHelpClientDiagnostics.CreateScope("SelfHelpSolutionResultCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionSelfHelpRestClient.CreateGetSelfHelpSolutionByIdRequest(solutionId, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpSolutionResultData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpSolutionResultData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSolutionResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultData.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultData.Serialization.cs new file mode 100644 index 000000000000..ff65630457b6 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultData.Serialization.cs @@ -0,0 +1,184 @@ +// 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.Models; +using Azure.ResourceManager.SelfHelp.Models; + +namespace Azure.ResourceManager.SelfHelp +{ + /// Self Help Solution response. + public partial class SelfHelpSolutionResultData : ResourceData, IJsonModel + { + /// 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(SelfHelpSolutionResultData)} 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. + SelfHelpSolutionResultData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SelfHelpSolutionResultData)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(SelfHelpSolutionResultData)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSelfHelpSolutionResultData(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpSolutionResultData DeserializeSelfHelpSolutionResultData(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(); + SolutionsResourcePropertiesSelfHelp 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, AzureResourceManagerSelfHelpContext.Default); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = SolutionsResourcePropertiesSelfHelp.DeserializeSolutionsResourcePropertiesSelfHelp(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SelfHelpSolutionResultData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties, + properties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerSelfHelpContext.Default); + default: + throw new FormatException($"The model {nameof(SelfHelpSolutionResultData)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpSolutionResultData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SelfHelpSolutionResultData)PersistableModelCreateCore(data, options); + + /// 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 DeserializeSelfHelpSolutionResultData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SelfHelpSolutionResultData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static SelfHelpSolutionResultData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSelfHelpSolutionResultData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultData.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultData.cs new file mode 100644 index 000000000000..344ea243cbea --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultData.cs @@ -0,0 +1,92 @@ +// 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; +using Azure.ResourceManager.SelfHelp.Models; + +namespace Azure.ResourceManager.SelfHelp +{ + /// Self Help Solution response. + public partial class SelfHelpSolutionResultData : ResourceData + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SelfHelpSolutionResultData() + { + } + + /// 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. + /// Solution result. + internal SelfHelpSolutionResultData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, SolutionsResourcePropertiesSelfHelp properties) : base(id, name, resourceType, systemData) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; + } + + /// Solution result. + internal SolutionsResourcePropertiesSelfHelp Properties { get; set; } + + /// SolutionId is a unique id to identify a solution. You can retrieve the solution id using the Discovery api - https://learn.microsoft.com/en-us/rest/api/help/discovery-solution/list?view=rest-help-2023-09-01-preview&tabs=HTTP. + public string SolutionId + { + get + { + return Properties is null ? default : Properties.SolutionId; + } + } + + /// The title. + public string Title + { + get + { + return Properties is null ? default : Properties.Title; + } + } + + /// The HTML content that needs to be rendered and shown to customer. + public string Content + { + get + { + return Properties is null ? default : Properties.Content; + } + } + + /// Solution replacement maps. + public ReplacementMapsResult ReplacementMaps + { + get + { + return Properties is null ? default : Properties.ReplacementMaps; + } + } + + /// List of section object. + public IReadOnlyList Sections + { + get + { + if (Properties is null) + { + Properties = new SolutionsResourcePropertiesSelfHelp(); + } + return Properties.Sections; + } + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultResource.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultResource.Serialization.cs new file mode 100644 index 000000000000..74309873b315 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultResource.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.SelfHelp +{ + /// + public partial class SelfHelpSolutionResultResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new SelfHelpSolutionResultData(); + + /// 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. + SelfHelpSolutionResultData 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, AzureResourceManagerSelfHelpContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + SelfHelpSolutionResultData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerSelfHelpContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultResource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultResource.cs new file mode 100644 index 000000000000..1226d31e5283 --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpSolutionResultResource.cs @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +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.SelfHelp +{ + /// + /// A class representing a SelfHelpSolutionResult 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 GetSelfHelpSolutionResults method. + /// + public partial class SelfHelpSolutionResultResource : ArmResource + { + private readonly ClientDiagnostics _solutionSelfHelpClientDiagnostics; + private readonly SolutionSelfHelp _solutionSelfHelpRestClient; + private readonly SelfHelpSolutionResultData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Help/selfHelp"; + + /// Initializes a new instance of SelfHelpSolutionResultResource for mocking. + protected SelfHelpSolutionResultResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal SelfHelpSolutionResultResource(ArmClient client, SelfHelpSolutionResultData 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 SelfHelpSolutionResultResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string selfHelpSolutionResultApiVersion); + _solutionSelfHelpClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ResourceType.Namespace, Diagnostics); + _solutionSelfHelpRestClient = new SolutionSelfHelp(_solutionSelfHelpClientDiagnostics, Pipeline, Endpoint, selfHelpSolutionResultApiVersion ?? "2024-03-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 SelfHelpSolutionResultData 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 solutionId. + public static ResourceIdentifier CreateResourceIdentifier(string solutionId) + { + string resourceId = $"/providers/Microsoft.Help/selfHelp/{solutionId}"; + 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); + } + } + + /// + /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. + /// + /// + /// Request Path. + /// /providers/Microsoft.Help/selfHelp/{solutionId}. + /// + /// + /// Operation Id. + /// SolutionResourceSelfHelps_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _solutionSelfHelpClientDiagnostics.CreateScope("SelfHelpSolutionResultResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionSelfHelpRestClient.CreateGetSelfHelpSolutionByIdRequest(Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpSolutionResultData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSolutionResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets Self Help Solutions for a given solutionId. Self Help Solutions consist of rich instructional video tutorials, links and guides to public documentation related to a specific problem that enables users to troubleshoot Azure issues. + /// + /// + /// Request Path. + /// /providers/Microsoft.Help/selfHelp/{solutionId}. + /// + /// + /// Operation Id. + /// SolutionResourceSelfHelps_Get. + /// + /// + /// Default Api Version. + /// 2024-03-01-preview. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _solutionSelfHelpClientDiagnostics.CreateScope("SelfHelpSolutionResultResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _solutionSelfHelpRestClient.CreateGetSelfHelpSolutionByIdRequest(Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpSolutionResultData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new SelfHelpSolutionResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterCollection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterCollection.cs index 32393889c36a..13a32499a84a 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterCollection.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterCollection.cs @@ -8,8 +8,10 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.SelfHelp { @@ -20,42 +22,38 @@ namespace Azure.ResourceManager.SelfHelp /// public partial class SelfHelpTroubleshooterCollection : ArmCollection { - private readonly ClientDiagnostics _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics; - private readonly TroubleshooterResourcesRestOperations _selfHelpTroubleshooterTroubleshooterResourcesRestClient; + private readonly ClientDiagnostics _troubleshooterResourcesClientDiagnostics; + private readonly TroubleshooterResources _troubleshooterResourcesRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of SelfHelpTroubleshooterCollection for mocking. protected SelfHelpTroubleshooterCollection() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. + /// The identifier of the resource that is the target of operations. internal SelfHelpTroubleshooterCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", SelfHelpTroubleshooterResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(SelfHelpTroubleshooterResource.ResourceType, out string selfHelpTroubleshooterTroubleshooterResourcesApiVersion); - _selfHelpTroubleshooterTroubleshooterResourcesRestClient = new TroubleshooterResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, selfHelpTroubleshooterTroubleshooterResourcesApiVersion); + TryGetApiVersion(SelfHelpTroubleshooterResource.ResourceType, out string selfHelpTroubleshooterApiVersion); + _troubleshooterResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", SelfHelpTroubleshooterResource.ResourceType.Namespace, Diagnostics); + _troubleshooterResourcesRestClient = new TroubleshooterResources(_troubleshooterResourcesClientDiagnostics, Pipeline, Endpoint, selfHelpTroubleshooterApiVersion ?? "2024-03-01-preview"); } /// /// Creates the specific troubleshooter action under a resource or subscription using the ‘solutionId’ and ‘properties.parameters’ as the trigger. <br/> Azure Troubleshooters help with hard to classify issues, reducing the gap between customer observed problems and solutions by guiding the user effortlessly through the troubleshooting process. Each Troubleshooter flow represents a problem area within Azure and has a complex tree-like structure that addresses many root causes. These flows are prepared with the help of Subject Matter experts and customer support engineers by carefully considering previous support requests raised by customers. Troubleshooters terminate at a well curated solution based off of resource backend signals and customer manual selections. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Operation Id - /// TroubleshooterResource_Create + /// Operation Id. + /// TroubleshooterResources_Create. /// /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// @@ -63,23 +61,30 @@ internal SelfHelpTroubleshooterCollection(ArmClient client, ResourceIdentifier i /// Troubleshooter resource Name. /// The required request body for this Troubleshooter resource creation. /// The cancellation token to use. + /// is null. /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string troubleshooterName, SelfHelpTroubleshooterData data, CancellationToken cancellationToken = default) + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string troubleshooterName, SelfHelpTroubleshooterData data = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - Argument.AssertNotNull(data, nameof(data)); - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.CreateOrUpdate"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _selfHelpTroubleshooterTroubleshooterResourcesRestClient.CreateAsync(Id, troubleshooterName, data, cancellationToken).ConfigureAwait(false); - var uri = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.CreateCreateRequestUri(Id, troubleshooterName, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new SelfHelpArmOperation(Response.FromValue(new SelfHelpTroubleshooterResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateCreateRequest(Id, troubleshooterName, SelfHelpTroubleshooterData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + SelfHelpArmOperation operation = new SelfHelpArmOperation(Response.FromValue(new SelfHelpTroubleshooterResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -93,20 +98,16 @@ public virtual async Task> CreateOr /// Creates the specific troubleshooter action under a resource or subscription using the ‘solutionId’ and ‘properties.parameters’ as the trigger. <br/> Azure Troubleshooters help with hard to classify issues, reducing the gap between customer observed problems and solutions by guiding the user effortlessly through the troubleshooting process. Each Troubleshooter flow represents a problem area within Azure and has a complex tree-like structure that addresses many root causes. These flows are prepared with the help of Subject Matter experts and customer support engineers by carefully considering previous support requests raised by customers. Troubleshooters terminate at a well curated solution based off of resource backend signals and customer manual selections. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} - /// - /// - /// Operation Id - /// TroubleshooterResource_Create + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// TroubleshooterResources_Create. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// @@ -114,23 +115,30 @@ public virtual async Task> CreateOr /// Troubleshooter resource Name. /// The required request body for this Troubleshooter resource creation. /// The cancellation token to use. + /// is null. /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string troubleshooterName, SelfHelpTroubleshooterData data, CancellationToken cancellationToken = default) + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string troubleshooterName, SelfHelpTroubleshooterData data = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - Argument.AssertNotNull(data, nameof(data)); - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.CreateOrUpdate"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.CreateOrUpdate"); scope.Start(); try { - var response = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.Create(Id, troubleshooterName, data, cancellationToken); - var uri = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.CreateCreateRequestUri(Id, troubleshooterName, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new SelfHelpArmOperation(Response.FromValue(new SelfHelpTroubleshooterResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateCreateRequest(Id, troubleshooterName, SelfHelpTroubleshooterData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + SelfHelpArmOperation operation = new SelfHelpArmOperation(Response.FromValue(new SelfHelpTroubleshooterResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -144,38 +152,42 @@ public virtual ArmOperation CreateOrUpdate(WaitU /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} - /// - /// - /// Operation Id - /// TroubleshooterResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// TroubleshooterResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Troubleshooter resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetAsync(string troubleshooterName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.Get"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.Get"); scope.Start(); try { - var response = await _selfHelpTroubleshooterTroubleshooterResourcesRestClient.GetAsync(Id, troubleshooterName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateGetRequest(Id, troubleshooterName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpTroubleshooterResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -189,38 +201,42 @@ public virtual async Task> GetAsync(str /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} - /// - /// - /// Operation Id - /// TroubleshooterResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// TroubleshooterResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Troubleshooter resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Get(string troubleshooterName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.Get"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.Get"); scope.Start(); try { - var response = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.Get(Id, troubleshooterName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateGetRequest(Id, troubleshooterName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpTroubleshooterResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -231,39 +247,53 @@ public virtual Response Get(string troubleshoote } /// - /// Checks to see if the resource exists in azure. + /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} - /// - /// - /// Operation Id - /// TroubleshooterResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// TroubleshooterResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Troubleshooter resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> ExistsAsync(string troubleshooterName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.Exists"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.Exists"); scope.Start(); try { - var response = await _selfHelpTroubleshooterTroubleshooterResourcesRestClient.GetAsync(Id, troubleshooterName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateGetRequest(Id, troubleshooterName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpTroubleshooterData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -274,39 +304,53 @@ public virtual async Task> ExistsAsync(string troubleshooterName, } /// - /// Checks to see if the resource exists in azure. + /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} - /// - /// - /// Operation Id - /// TroubleshooterResource_Get + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Operation Id. + /// TroubleshooterResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Troubleshooter resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Exists(string troubleshooterName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.Exists"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.Exists"); scope.Start(); try { - var response = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.Get(Id, troubleshooterName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateGetRequest(Id, troubleshooterName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpTroubleshooterData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -317,41 +361,57 @@ public virtual Response Exists(string troubleshooterName, CancellationToke } /// - /// Tries to get details for this resource from the service. + /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Operation Id - /// TroubleshooterResource_Get + /// Operation Id. + /// TroubleshooterResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Troubleshooter resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetIfExistsAsync(string troubleshooterName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.GetIfExists"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.GetIfExists"); scope.Start(); try { - var response = await _selfHelpTroubleshooterTroubleshooterResourcesRestClient.GetAsync(Id, troubleshooterName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateGetRequest(Id, troubleshooterName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpTroubleshooterData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpTroubleshooterResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -362,41 +422,57 @@ public virtual async Task> GetI } /// - /// Tries to get details for this resource from the service. + /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Operation Id - /// TroubleshooterResource_Get + /// Operation Id. + /// TroubleshooterResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2024-03-01-preview. /// /// /// /// Troubleshooter resource Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual NullableResponse GetIfExists(string troubleshooterName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(troubleshooterName, nameof(troubleshooterName)); - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.GetIfExists"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterCollection.GetIfExists"); scope.Start(); try { - var response = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.Get(Id, troubleshooterName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateGetRequest(Id, troubleshooterName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((SelfHelpTroubleshooterData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpTroubleshooterResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterData.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterData.Serialization.cs index 46647ddd920f..5e2f1862e857 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterData.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterData.Serialization.cs @@ -10,16 +10,18 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Models; using Azure.ResourceManager.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp { - public partial class SelfHelpTroubleshooterData : IUtf8JsonSerializable, IJsonModel + /// Troubleshooter response. + public partial class SelfHelpTroubleshooterData : ResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,181 +33,114 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpTroubleshooterData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(SolutionId)) - { - writer.WritePropertyName("solutionId"u8); - writer.WriteStringValue(SolutionId); - } - if (Optional.IsCollectionDefined(Parameters)) - { - writer.WritePropertyName("parameters"u8); - writer.WriteStartObject(); - foreach (var item in Parameters) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) - { - writer.WritePropertyName("provisioningState"u8); - writer.WriteStringValue(ProvisioningState.Value.ToString()); - } - if (options.Format != "W" && Optional.IsCollectionDefined(Steps)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("steps"u8); - writer.WriteStartArray(); - foreach (var item in Steps) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - writer.WriteEndObject(); } - SelfHelpTroubleshooterData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SelfHelpTroubleshooterData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SelfHelpTroubleshooterData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SelfHelpTroubleshooterData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSelfHelpTroubleshooterData(document.RootElement, options); } - internal static SelfHelpTroubleshooterData DeserializeSelfHelpTroubleshooterData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SelfHelpTroubleshooterData DeserializeSelfHelpTroubleshooterData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - string solutionId = default; - IDictionary parameters = default; - TroubleshooterProvisioningState? provisioningState = default; - IReadOnlyList steps = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + TroubleshooterInstanceProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSelfHelpContext.Default); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("solutionId"u8)) - { - solutionId = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("parameters"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property1 in property0.Value.EnumerateObject()) - { - dictionary.Add(property1.Name, property1.Value.GetString()); - } - parameters = dictionary; - continue; - } - if (property0.NameEquals("provisioningState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new TroubleshooterProvisioningState(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("steps"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(SelfHelpStep.DeserializeSelfHelpStep(item, options)); - } - steps = array; - continue; - } - } + properties = TroubleshooterInstanceProperties.DeserializeTroubleshooterInstanceProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new SelfHelpTroubleshooterData( id, name, - type, + resourceType, systemData, - solutionId, - parameters ?? new ChangeTrackingDictionary(), - provisioningState, - steps ?? new ChangeTrackingList(), - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -215,15 +150,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriter } } - SelfHelpTroubleshooterData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SelfHelpTroubleshooterData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SelfHelpTroubleshooterData)PersistableModelCreateCore(data, options); + /// 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSelfHelpTroubleshooterData(document.RootElement, options); } default: @@ -231,6 +171,26 @@ SelfHelpTroubleshooterData IPersistableModel.Create( } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(SelfHelpTroubleshooterData selfHelpTroubleshooterData) + { + if (selfHelpTroubleshooterData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(selfHelpTroubleshooterData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static SelfHelpTroubleshooterData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSelfHelpTroubleshooterData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterData.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterData.cs index f0d1d4d9bb5c..a3d20fc08cdd 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterData.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterData.cs @@ -13,77 +13,83 @@ namespace Azure.ResourceManager.SelfHelp { - /// - /// A class representing the SelfHelpTroubleshooter data model. - /// Troubleshooter response. - /// + /// Troubleshooter response. public partial class SelfHelpTroubleshooterData : ResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public SelfHelpTroubleshooterData() { - Parameters = new ChangeTrackingDictionary(); - Steps = new ChangeTrackingList(); } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// Solution Id to identify single troubleshooter. - /// Client input parameters to run Troubleshooter Resource. - /// Status of troubleshooter provisioning. - /// List of step object. - /// Keeps track of any properties unknown to the library. - internal SelfHelpTroubleshooterData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string solutionId, IDictionary parameters, TroubleshooterProvisioningState? provisioningState, IReadOnlyList steps, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + /// 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. + /// Troubleshooter Instance properties. + internal SelfHelpTroubleshooterData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, TroubleshooterInstanceProperties properties) : base(id, name, resourceType, systemData) { - SolutionId = solutionId; - Parameters = parameters; - ProvisioningState = provisioningState; - Steps = steps; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } + /// Troubleshooter Instance properties. + internal TroubleshooterInstanceProperties Properties { get; set; } + /// Solution Id to identify single troubleshooter. - public string SolutionId { get; set; } + public string SolutionId + { + get + { + return Properties is null ? default : Properties.SolutionId; + } + set + { + if (Properties is null) + { + Properties = new TroubleshooterInstanceProperties(); + } + Properties.SolutionId = value; + } + } + /// Client input parameters to run Troubleshooter Resource. - public IDictionary Parameters { get; } + public IDictionary Parameters + { + get + { + if (Properties is null) + { + Properties = new TroubleshooterInstanceProperties(); + } + return Properties.Parameters; + } + } + /// Status of troubleshooter provisioning. - public TroubleshooterProvisioningState? ProvisioningState { get; } + public TroubleshooterProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + /// List of step object. - public IReadOnlyList Steps { get; } + public IReadOnlyList Steps + { + get + { + if (Properties is null) + { + Properties = new TroubleshooterInstanceProperties(); + } + return Properties.Steps; + } + } } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterResource.Serialization.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterResource.Serialization.cs index 2f06180a7368..9b9351d9c14d 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterResource.Serialization.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.SelfHelp { + /// public partial class SelfHelpTroubleshooterResource : IJsonModel { - private static SelfHelpTroubleshooterData s_dataDeserializationInstance; - private static SelfHelpTroubleshooterData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new SelfHelpTroubleshooterData(); + + /// 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); - SelfHelpTroubleshooterData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + SelfHelpTroubleshooterData 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, AzureResourceManagerSelfHelpContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. SelfHelpTroubleshooterData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerSelfHelpContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterResource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterResource.cs index 8ab1b3f6db36..31f324790eec 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterResource.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/src/Generated/SelfHelpTroubleshooterResource.cs @@ -6,45 +6,36 @@ #nullable disable using System; -using System.Globalization; +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.SelfHelp.Models; namespace Azure.ResourceManager.SelfHelp { /// - /// A Class representing a SelfHelpTroubleshooter 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 GetSelfHelpTroubleshooterResource method. - /// Otherwise you can get one from its parent resource using the GetSelfHelpTroubleshooter method. + /// A class representing a SelfHelpTroubleshooter 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 GetSelfHelpTroubleshooters method. /// public partial class SelfHelpTroubleshooterResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The scope. - /// The troubleshooterName. - public static ResourceIdentifier CreateResourceIdentifier(string scope, string troubleshooterName) - { - var resourceId = $"{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics; - private readonly TroubleshooterResourcesRestOperations _selfHelpTroubleshooterTroubleshooterResourcesRestClient; + private readonly ClientDiagnostics _troubleshooterResourcesClientDiagnostics; + private readonly TroubleshooterResources _troubleshooterResourcesRestClient; private readonly SelfHelpTroubleshooterData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Help/troubleshooters"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of SelfHelpTroubleshooterResource for mocking. protected SelfHelpTroubleshooterResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal SelfHelpTroubleshooterResource(ArmClient client, SelfHelpTroubleshooterData data) : this(client, data.Id) @@ -53,71 +44,91 @@ internal SelfHelpTroubleshooterResource(ArmClient client, SelfHelpTroubleshooter _data = data; } - /// Initializes a new instance of the class. + /// 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 SelfHelpTroubleshooterResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string selfHelpTroubleshooterTroubleshooterResourcesApiVersion); - _selfHelpTroubleshooterTroubleshooterResourcesRestClient = new TroubleshooterResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, selfHelpTroubleshooterTroubleshooterResourcesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string selfHelpTroubleshooterApiVersion); + _troubleshooterResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SelfHelp", ResourceType.Namespace, Diagnostics); + _troubleshooterResourcesRestClient = new TroubleshooterResources(_troubleshooterResourcesClientDiagnostics, Pipeline, Endpoint, selfHelpTroubleshooterApiVersion ?? "2024-03-01-preview"); + ValidateResourceId(id); } /// Gets whether or not the current instance has data. public virtual bool HasData { get; } /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. public virtual SelfHelpTroubleshooterData 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 scope. + /// The troubleshooterName. + public static ResourceIdentifier CreateResourceIdentifier(string scope, string troubleshooterName) + { + string resourceId = $"{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Operation Id - /// TroubleshooterResource_Get + /// Operation Id. + /// TroubleshooterResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Get"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Get"); scope.Start(); try { - var response = await _selfHelpTroubleshooterTroubleshooterResourcesRestClient.GetAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateGetRequest(Id.Parent, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpTroubleshooterResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -131,33 +142,41 @@ public virtual async Task> GetAsync(Can /// Gets troubleshooter instance result which includes the step status/result of the troubleshooter resource name that is being executed.<br/> Get API is used to retrieve the result of a Troubleshooter instance, which includes the status and result of each step in the Troubleshooter workflow. This API requires the Troubleshooter resource name that was created using the Create API. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Operation Id - /// TroubleshooterResource_Get + /// Operation Id. + /// TroubleshooterResources_Get. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Get"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Get"); scope.Start(); try { - var response = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.Get(Id.Parent, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateGetRequest(Id.Parent, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new SelfHelpTroubleshooterResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -168,45 +187,41 @@ public virtual Response Get(CancellationToken ca } /// - /// Creates the specific troubleshooter action under a resource or subscription using the ‘solutionId’ and ‘properties.parameters’ as the trigger. <br/> Azure Troubleshooters help with hard to classify issues, reducing the gap between customer observed problems and solutions by guiding the user effortlessly through the troubleshooting process. Each Troubleshooter flow represents a problem area within Azure and has a complex tree-like structure that addresses many root causes. These flows are prepared with the help of Subject Matter experts and customer support engineers by carefully considering previous support requests raised by customers. Troubleshooters terminate at a well curated solution based off of resource backend signals and customer manual selections. + /// Uses ‘stepId’ and ‘responses’ as the trigger to continue the troubleshooting steps for the respective troubleshooter resource name. <br/>Continue API is used to provide inputs that are required for the specific troubleshooter to progress into the next step in the process. This API is used after the Troubleshooter has been created using the Create API. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/continue. /// /// - /// Operation Id - /// TroubleshooterResource_Create + /// Operation Id. + /// TroubleshooterResources_Continue. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// 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 required request body for this Troubleshooter resource creation. + /// The required request body for going to next step in Troubleshooter resource. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, SelfHelpTroubleshooterData data, CancellationToken cancellationToken = default) + public virtual async Task ContinueAsync(TroubleshooterContinueContent continueRequestBody = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Update"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Continue"); scope.Start(); try { - var response = await _selfHelpTroubleshooterTroubleshooterResourcesRestClient.CreateAsync(Id.Parent, Id.Name, data, cancellationToken).ConfigureAwait(false); - var uri = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.CreateCreateRequestUri(Id.Parent, Id.Name, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new SelfHelpArmOperation(Response.FromValue(new SelfHelpTroubleshooterResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateContinueRequest(Id.Parent, Id.Name, TroubleshooterContinueContent.ToRequestContent(continueRequestBody), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + return response; } catch (Exception e) { @@ -216,45 +231,41 @@ public virtual async Task> UpdateAs } /// - /// Creates the specific troubleshooter action under a resource or subscription using the ‘solutionId’ and ‘properties.parameters’ as the trigger. <br/> Azure Troubleshooters help with hard to classify issues, reducing the gap between customer observed problems and solutions by guiding the user effortlessly through the troubleshooting process. Each Troubleshooter flow represents a problem area within Azure and has a complex tree-like structure that addresses many root causes. These flows are prepared with the help of Subject Matter experts and customer support engineers by carefully considering previous support requests raised by customers. Troubleshooters terminate at a well curated solution based off of resource backend signals and customer manual selections. + /// Uses ‘stepId’ and ‘responses’ as the trigger to continue the troubleshooting steps for the respective troubleshooter resource name. <br/>Continue API is used to provide inputs that are required for the specific troubleshooter to progress into the next step in the process. This API is used after the Troubleshooter has been created using the Create API. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName} + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/continue. /// /// - /// Operation Id - /// TroubleshooterResource_Create + /// Operation Id. + /// TroubleshooterResources_Continue. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// 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 required request body for this Troubleshooter resource creation. + /// The required request body for going to next step in Troubleshooter resource. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, SelfHelpTroubleshooterData data, CancellationToken cancellationToken = default) + public virtual Response Continue(TroubleshooterContinueContent continueRequestBody = default, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Update"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Continue"); scope.Start(); try { - var response = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.Create(Id.Parent, Id.Name, data, cancellationToken); - var uri = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.CreateCreateRequestUri(Id.Parent, Id.Name, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new SelfHelpArmOperation(Response.FromValue(new SelfHelpTroubleshooterResource(Client, response), response.GetRawResponse()), rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateContinueRequest(Id.Parent, Id.Name, TroubleshooterContinueContent.ToRequestContent(continueRequestBody), context); + Response response = Pipeline.ProcessMessage(message, context); + return response; } catch (Exception e) { @@ -264,35 +275,39 @@ public virtual ArmOperation Update(WaitUntil wai } /// - /// Uses ‘stepId’ and ‘responses’ as the trigger to continue the troubleshooting steps for the respective troubleshooter resource name. <br/>Continue API is used to provide inputs that are required for the specific troubleshooter to progress into the next step in the process. This API is used after the Troubleshooter has been created using the Create API. + /// Ends the troubleshooter action /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/continue + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/end. /// /// - /// Operation Id - /// TroubleshooterResources_Continue + /// Operation Id. + /// TroubleshooterResources_End. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The required request body for going to next step in Troubleshooter resource. /// The cancellation token to use. - public virtual async Task ContinueAsync(TroubleshooterContinueContent content = null, CancellationToken cancellationToken = default) + public virtual async Task EndAsync(CancellationToken cancellationToken = default) { - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Continue"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.End"); scope.Start(); try { - var response = await _selfHelpTroubleshooterTroubleshooterResourcesRestClient.ContinueAsync(Id.Parent, Id.Name, content, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateEndRequest(Id.Parent, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); return response; } catch (Exception e) @@ -303,35 +318,39 @@ public virtual async Task ContinueAsync(TroubleshooterContinueContent } /// - /// Uses ‘stepId’ and ‘responses’ as the trigger to continue the troubleshooting steps for the respective troubleshooter resource name. <br/>Continue API is used to provide inputs that are required for the specific troubleshooter to progress into the next step in the process. This API is used after the Troubleshooter has been created using the Create API. + /// Ends the troubleshooter action /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/continue + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/end. /// /// - /// Operation Id - /// TroubleshooterResources_Continue + /// Operation Id. + /// TroubleshooterResources_End. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The required request body for going to next step in Troubleshooter resource. /// The cancellation token to use. - public virtual Response Continue(TroubleshooterContinueContent content = null, CancellationToken cancellationToken = default) + public virtual Response End(CancellationToken cancellationToken = default) { - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Continue"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.End"); scope.Start(); try { - var response = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.Continue(Id.Parent, Id.Name, content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateEndRequest(Id.Parent, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); return response; } catch (Exception e) @@ -342,34 +361,44 @@ public virtual Response Continue(TroubleshooterContinueContent content = null, C } /// - /// Ends the troubleshooter action + /// Restarts the troubleshooter API using applicable troubleshooter resource name as the input.<br/> It returns new resource name which should be used in subsequent request. The old resource name is obsolete after this API is invoked. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/end + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/restart. /// /// - /// Operation Id - /// TroubleshooterResources_End + /// Operation Id. + /// TroubleshooterResources_Restart. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. - public virtual async Task EndAsync(CancellationToken cancellationToken = default) + public virtual async Task> RestartAsync(CancellationToken cancellationToken = default) { - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.End"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Restart"); scope.Start(); try { - var response = await _selfHelpTroubleshooterTroubleshooterResourcesRestClient.EndAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateRestartRequest(Id.Parent, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(RestartTroubleshooterResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -380,34 +409,44 @@ public virtual async Task EndAsync(CancellationToken cancellationToken } /// - /// Ends the troubleshooter action + /// Restarts the troubleshooter API using applicable troubleshooter resource name as the input.<br/> It returns new resource name which should be used in subsequent request. The old resource name is obsolete after this API is invoked. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/end + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/restart. /// /// - /// Operation Id - /// TroubleshooterResources_End + /// Operation Id. + /// TroubleshooterResources_Restart. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. - public virtual Response End(CancellationToken cancellationToken = default) + public virtual Response Restart(CancellationToken cancellationToken = default) { - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.End"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Restart"); scope.Start(); try { - var response = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.End(Id.Parent, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateRestartRequest(Id.Parent, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(RestartTroubleshooterResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -418,35 +457,50 @@ public virtual Response End(CancellationToken cancellationToken = default) } /// - /// Restarts the troubleshooter API using applicable troubleshooter resource name as the input.<br/> It returns new resource name which should be used in subsequent request. The old resource name is obsolete after this API is invoked. + /// Creates the specific troubleshooter action under a resource or subscription using the ‘solutionId’ and ‘properties.parameters’ as the trigger. <br/> Azure Troubleshooters help with hard to classify issues, reducing the gap between customer observed problems and solutions by guiding the user effortlessly through the troubleshooting process. Each Troubleshooter flow represents a problem area within Azure and has a complex tree-like structure that addresses many root causes. These flows are prepared with the help of Subject Matter experts and customer support engineers by carefully considering previous support requests raised by customers. Troubleshooters terminate at a well curated solution based off of resource backend signals and customer manual selections. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/restart + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Operation Id - /// TroubleshooterResources_Restart + /// Operation Id. + /// TroubleshooterResources_Create. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// 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 required request body for this Troubleshooter resource creation. /// The cancellation token to use. - public virtual async Task> RestartAsync(CancellationToken cancellationToken = default) + public virtual async Task> UpdateAsync(WaitUntil waitUntil, SelfHelpTroubleshooterData data = default, CancellationToken cancellationToken = default) { - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Restart"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Update"); scope.Start(); try { - var response = await _selfHelpTroubleshooterTroubleshooterResourcesRestClient.RestartAsync(Id.Parent, Id.Name, cancellationToken).ConfigureAwait(false); - return response; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateCreateRequest(Id.Parent, Id.Name, SelfHelpTroubleshooterData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + SelfHelpArmOperation operation = new SelfHelpArmOperation(Response.FromValue(new SelfHelpTroubleshooterResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; } catch (Exception e) { @@ -456,35 +510,50 @@ public virtual async Task> RestartAsync(Ca } /// - /// Restarts the troubleshooter API using applicable troubleshooter resource name as the input.<br/> It returns new resource name which should be used in subsequent request. The old resource name is obsolete after this API is invoked. + /// Creates the specific troubleshooter action under a resource or subscription using the ‘solutionId’ and ‘properties.parameters’ as the trigger. <br/> Azure Troubleshooters help with hard to classify issues, reducing the gap between customer observed problems and solutions by guiding the user effortlessly through the troubleshooting process. Each Troubleshooter flow represents a problem area within Azure and has a complex tree-like structure that addresses many root causes. These flows are prepared with the help of Subject Matter experts and customer support engineers by carefully considering previous support requests raised by customers. Troubleshooters terminate at a well curated solution based off of resource backend signals and customer manual selections. /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}/restart + /// Request Path. + /// /{scope}/providers/Microsoft.Help/troubleshooters/{troubleshooterName}. /// /// - /// Operation Id - /// TroubleshooterResources_Restart + /// Operation Id. + /// TroubleshooterResources_Create. /// /// - /// Default Api Version - /// 2024-03-01-preview + /// Default Api Version. + /// 2024-03-01-preview. /// /// - /// Resource - /// + /// 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 required request body for this Troubleshooter resource creation. /// The cancellation token to use. - public virtual Response Restart(CancellationToken cancellationToken = default) + public virtual ArmOperation Update(WaitUntil waitUntil, SelfHelpTroubleshooterData data = default, CancellationToken cancellationToken = default) { - using var scope = _selfHelpTroubleshooterTroubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Restart"); + using DiagnosticScope scope = _troubleshooterResourcesClientDiagnostics.CreateScope("SelfHelpTroubleshooterResource.Update"); scope.Start(); try { - var response = _selfHelpTroubleshooterTroubleshooterResourcesRestClient.Restart(Id.Parent, Id.Name, cancellationToken); - return response; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _troubleshooterResourcesRestClient.CreateCreateRequest(Id.Parent, Id.Name, SelfHelpTroubleshooterData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(SelfHelpTroubleshooterData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + SelfHelpArmOperation operation = new SelfHelpArmOperation(Response.FromValue(new SelfHelpTroubleshooterResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; } catch (Exception e) { diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/tsp-location.yaml b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/tsp-location.yaml index 5966c74efe42..c9ecca714c95 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/tsp-location.yaml +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/tsp-location.yaml @@ -1,5 +1,6 @@ directory: specification/help/resource-manager/Microsoft.Help/Help repo: Azure/azure-rest-api-specs -commit: 52fc376d009c4d96b89cfc410c11a38358a18f5b +commit: 67ee90ea110caeb9cfbea3f353cf08ead638360b additionalDirectories: [] -emitterPackageJsonPath: eng/legacy-emitter-package.json +# emitterPackageJsonPath: eng/legacy-emitter-package.json +emitterPackageJsonPath: "eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json"